-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
[Inference] inplace all reshape op #49146
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
@@ -88,6 +88,7 @@ pass_library(conv_elementwise_add_act_fuse_pass inference) | |||
pass_library(conv_elementwise_add2_act_fuse_pass inference) | |||
pass_library(conv_elementwise_add_fuse_pass inference) | |||
pass_library(transpose_flatten_concat_fuse_pass inference) | |||
pass_library(inplace_op_var_pass inference) |
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.
pass的名字通用?不是只针对reshape?
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.
目前已知的 reshape和squeeze操作都可以inplace,可能还有其他算子
AddStatis(found_subgraph_count); | ||
} | ||
|
||
void InplaceOpVarPass::MapToReshape(ir::Graph* graph) const { |
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.
map?是不是考虑改变下map_depthwise_conv_to_conv_pass的功能,将其改成一个通用的pass专门做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.
收到,下个pr将map类的操作规范到一个pass里
def generate_shape(val): | ||
return np.array(val).astype(np.int32) | ||
|
||
x_shape = draw( |
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.
这个单测被执行了吗?draw从哪里import的?
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.
执行了,draw是autoscan单测框架引入的hypothesis库提供的
… inplace_reshape
703a98a
to
5059e8d
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
PR types
Performance optimization
PR changes
Others
Describe
inplace reshape op.
不可以inplace的Reshape2规则如下:
在
TNT_small
模型上会有问题,存在以下结构的错误转换;判断reshape2算子输入是否被多个算子用到,如果是则不转换。此外本pr修复了reshape infer shape func中不支持inplace的逻辑;
发现可以进一步优化的场景 TODO:
LeVit
模型中存在多个reshape2算子串联,可通过fuse仅保留最后一个Reshape;