Lowing shape_optimization_pass to paddle/pir/ directory #63572
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Category
Others
PR Types
Others
Description
Pcard-67164
背景:
shape_analysis组件目前在shape_optimization_pass.cc中被隐式关联,且这个文件被显式地打入op_dialect里编译,在pir_transforms target也会编译。前者会被cinnapi.so依赖(以静态库形式),cinnapi.so又会被libpaddle.so依赖,导致libpaddle.so有两条路径会依赖shape_optimization_pass的符号:
①libpaddle.so -> ... -> libpir_transforms.a -> shape_optimization_pass
②libpaddle.so -> cinnapi.so ->op_dialect.a -> shape_optimization_pass;
这里会有全局静态变量重复初始化的问题,导致Pass被重复注册(目前会ENFORCE不允许重复注册)。后续迭代CINN很容易遇到编译问题。
解决方案:
将shape_optimization_pass组件放到paddle/pir/src/dialect/shape目录下,这样就可以放到libpir.so里编译
shape_optimization_pass调用了paddle::dialect::InferSymbolicShapeInterface类,将该interface也迁移到pir命名空间下,同时保留在paddle::dialect中的别名