CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[CINN]support InferSymbolicShape without data #66343
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]support InferSymbolicShape without data #66343
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
if (!type.isa<::pir::DenseTensorType>()) { | ||
// TODO(Hongqing-work): check if tensor array is needed | ||
return false; | ||
} | ||
auto tensor_type = type.dyn_cast<::pir::DenseTensorType>(); | ||
|
||
if (tensor_type) { |
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.
这里的if逻辑是不重复了?
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.
是的,已删除仅保留TODO注释
return res; | ||
} | ||
|
||
bool IsShapeSupported(const ::pir::Operation& op) { |
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.
ShapeSupported语义上有些不清晰
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.
已修改为!CauseNewSymboliShape的语义
if (FLAGS_disable_dyshape_in_train) { | ||
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.
这里的判断是否还有必要?
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.
这个FLAG是起到禁止符号推导的作用,如果仍然有保留这个FLAG的需求就有必要,后续可以考虑是否所有情况开启符号推导
@@ -81,22 +81,46 @@ std::vector<T> GetVectorAttr(const ::pir::Operation *op, | |||
return vec_res; | |||
} | |||
|
|||
inline bool HasCompleteData(const ShapeOrData &shapeordata) { |
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.
Complete理解起来也不够直观,可以再加些注释说明
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.
已添加
for (const auto &shape_data : shape_or_data_list) { | ||
if (shape_data.data()) { | ||
expand_shape.emplace_back(shape_data.data()->at(0)); | ||
} else { | ||
infer_context->SetSymbolForValueByStaticShape(out()); | ||
return; |
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.
这里会不会多一些冗余的新符号?
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.
这里是直接调用infer_context的接口,根据静态shape来设置,是对没有data的处理,所以确实可能新增符号。如果新增符号会触发后续的fall_back。
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.
expand由于infermeta缺少信息,输出的所有维度一般都是动态的,按目前PR的逻辑是会给这些维度都用一个新符号,但我们遇到的情况是shape的data中只有部分维度没有找到符号,其他的维度上可以使用原来的符号,如果都换成新符号了等于是丢失了多个约束信息。
217e3f4
to
7231fa2
Compare
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 for const cast
* [CINN]support InferSymbolicShape without data * fix * fix * fix
PR Category
CINN
PR Types
Improvements
Description
Pcard-67164
This PR adds support for InferSymbolicShape without data.