CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
cinn(dynamic): fix reshape op when accessing shape dialect across fusion op #62503
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
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
❌ The PR is not created using PR's template. You can refer to this Demo. |
const std::vector<Type> &out_type, | ||
const std::vector<std::vector<ir::Dim>> &output_shapes, | ||
const Target &target) { | ||
framework::CINNCompute cast_compute( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generate_shape_compute
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
paddle/cinn/hlir/op/elementwise.cc
Outdated
std::shared_ptr<framework::OpStrategy> StrategyForGenerateShape( | ||
const framework::NodeAttr &attrs, | ||
const std::vector<ir::Tensor> &inputs, | ||
const std::vector<Type> &out_type, | ||
const std::vector<std::vector<int>> &output_shapes, | ||
const Target &target) { | ||
framework::CINNCompute cast_compute( | ||
[=](lang::Args args, lang::RetValue *ret) { | ||
CHECK(!args.empty()) | ||
<< "The input arguments of Cast compute is empty! Please check.\n"; | ||
CINNValuePack pack_args = args[0]; | ||
CHECK_GE(pack_args.size(), 1U) | ||
<< "at least 1 input tensors for Cast compute\n"; | ||
Expr A = pack_args[0]; | ||
CHECK(A.as_tensor()); | ||
CHECK(!output_shapes.empty()); | ||
auto tensor_A = A.as_tensor_ref(); | ||
auto stages = CreateStages({tensor_A}); | ||
VLOG(3) << "A shape: " << utils::Join(tensor_A->shape, ", ") | ||
<< ", output_shapes: " << utils::Join(output_shapes[0], ", "); | ||
CHECK_EQ(pack_args.size(), 2U); | ||
std::string tensor_name = pack_args[1].operator std::string(); | ||
ir::Tensor out(ir::_Tensor_::Make(tensor_name, | ||
tensor_A->type(), | ||
{ | ||
Expr(1), | ||
}, | ||
{ | ||
Expr(1), | ||
})); | ||
std::vector<CINNValue> res; | ||
stages->InsertLazily(out); | ||
res.push_back(CINNValue(out)); | ||
CHECK(!out_type.empty()) | ||
<< "Output type of Cast is empty! Please check.\n"; | ||
res.push_back(CINNValue(stages)); | ||
*ret = CINNValuePack{res}; | ||
}); | ||
|
||
auto strategy = std::make_shared<framework::OpStrategy>(); | ||
strategy->AddImpl(cast_compute, lang::PackedFunc(), "strategy.store.x86", 1); | ||
return strategy; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GenerateShape应该不会在静态shape场景下出现,这个接口是不没有用?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已移除
paddle/cinn/hlir/op/elementwise.cc
Outdated
.set_attr<cinn::hlir::framework::OpPatternKind>( | ||
"OpPattern", cinn::hlir::framework::OpPatternKind::kElementWise) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以标记成no fuse类型的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
if (op.name() == "cinn_op.generate_shape") { | ||
return true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
试试去掉这里可以work吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已移除,work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM,下个PR将IR_ENFORCE换成PADDLE__ENFORCE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR types
Others
PR changes
Others
Description
Pcard-78120
fix reshape op when accessing shape dialect across fusion op