Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cinn子图单测中reshape不生效 #62976

Closed
WintersMontagne10335 opened this issue Mar 25, 2024 · 3 comments
Closed

cinn子图单测中reshape不生效 #62976

WintersMontagne10335 opened this issue Mar 25, 2024 · 3 comments
Assignees
Labels
PFCC Paddle Framework Contributor Club,https://github.com/PaddlePaddle/community/tree/master/pfcc status/close 已关闭 type/bug-report 报bug

Comments

@WintersMontagne10335
Copy link
Contributor

WintersMontagne10335 commented Mar 25, 2024

bug 描述

# Paddle/test/ir/pir/cinn/sub_graphs/test_sub_graph_54.py
# var_17.shape : [32, 32, 2]
var_18 = paddle.tensor.manipulation.reshape(var_17, [1, -1, 2])
# 预期 var_18.shape : [1, 1024, 2]
# 实际 var_18.shape : [32, 32, 2]

复现步骤

git clone -b issue_reshape --single-branch https://github.com/WintersMontagne10335/Paddle # 注意不是paddle官方仓库
cd Paddle
mkdir build
cd build
cmake .. -DWITH_CINN=ON -DWITH_GPU=ON
make -j
pip install python/dist/paddlepaddle_gpu-xxx.whl

cd ../test/ir/pir/cinn/sub_graphs/
FLAGS_cinn_new_group_scheduler=1 FLAGS_enable_pir_api=1 FLAGS_cinn_bucket_compile=1 FLAGS_group_schedule_tiling_first=1 FLAGS_cudnn_deterministic=true python test_sub_graph_54.py 
# 即可看到简单报错信息

# 可通过以下指令查看日志
GLOG_v=6 FLAGS_cinn_new_group_scheduler=1 FLAGS_enable_pir_api=1 FLAGS_cinn_bucket_compile=1 FLAGS_group_schedule_tiling_first=1 FLAGS_cudnn_deterministic=true python test_sub_graph_54.py > err.log 2>&1
# 日志信息保存在了本目录 err.log 中

已有工作

排除 ReshapeOpInferSymbolicShape 内部逻辑错误的原因。

  • ReshapeOpInferSymbolicShapeshape_analysis->GetShapeOrDataForValue(op->operand_source(1)) 存在问题。按逻辑应为 [1, 1024, 2][1, -1, 2],实际为 [32, 32, 1]。可能是上游某个环节不对。

查看日志,可知,op->operand_source(1) 依赖于 full_int_array

    (%41) = "pd_op.full_int_array" () {dtype:(pd_op.DataType)int64,place:(pd_op.Place)Place(cpu),stop_gradient:[true],value:[(Int64)1,(Int64)2,(Int64)-1]} : () -> builtin.tensor<3xi64>
    (%42, %43) = "pd_op.reshape" (%40, %41) {stop_gradient:[true,true]} : (builtin.tensor<-1x-1x2xf32>, builtin.tensor<3xi64>) -> builtin.tensor<1x2x-1xf32>, builtin.tensor<0x-1x-1x2xi64>

但是,暂时无法定位到具体哪里出了问题。这条线暂时搁置。

其余子图的单测中,也存在 reshape ,如 test_sub_graph_6.py ,但是该子图单测的 reshape 生效了。

对比出错子图单测 test_sub_graph_54.pytest_sub_graph_6.py 日志,有一处疑点:test_sub_graph_6 可能未调用 ReshapeOpInferSymbolicShape (日志中未找到 ReshapeOpInferSymbolicShape 内部打印出来的信息)。

推进到这里推进不下去了。

其他补充信息 Additional Supplementary Information

No response

@Aurelius84
Copy link
Contributor

可以在你本地编译的build目录下检索一个pd_op.cc这个文件,以" NonzeroOp::" 为关键字检索下是否有对应的Nonzero::InferSymbolicShape 这个函数的

@WintersMontagne10335
Copy link
Contributor Author

可以在你本地编译的build目录下检索一个pd_op.cc这个文件,以" NonzeroOp::" 为关键字检索下是否有对应的Nonzero::InferSymbolicShape 这个函数的

这个 issue 里是另一个错误(囧),是不是回复错地方了~

@Aurelius84
Copy link
Contributor

抱歉,回复错了

@paddle-bot paddle-bot bot added the PFCC Paddle Framework Contributor Club,https://github.com/PaddlePaddle/community/tree/master/pfcc label Mar 25, 2024
@paddle-bot paddle-bot bot added status/close 已关闭 and removed status/new-issue 新建 labels Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PFCC Paddle Framework Contributor Club,https://github.com/PaddlePaddle/community/tree/master/pfcc status/close 已关闭 type/bug-report 报bug
Projects
None yet
Development

No branches or pull requests

3 participants