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

[OpAttr]Support to parse Attribute with type(Variable) in 2ONNX #854

Merged
merged 3 commits into from
Aug 16, 2022

Conversation

Aurelius84
Copy link
Contributor

@Aurelius84 Aurelius84 commented Aug 16, 2022

what's New?

  • 适配了主框架的Attribute支持Variable机制,在Concat 单值attr和 Tile 多值attr 验证了机制的正确性
  • 给 Mapper 和 Parser 底层类分别新增了两个必要的接口:IsAttrVar 和 GetAttrVar,用于各个映射mapper的便捷适配
  • 将2ONNX仓库的 framework.proto 更新为最新版本,与主框架保持一致
  • 更新了 .gitignore 配置,自动忽略 python setup.py install 后的文件跟踪,以及tests目录下的类似op_7.ONNX单测产出文件

正确性验证

在此回滚PR上:PaddlePaddle/Paddle#44658 验证了两个单测的正确性:

  • test_auto_scan_concat.py
  • test_auto_scan_tile.py

@@ -590,6 +638,7 @@ void PaddleParser::GetOpAttr(const paddle2onnx::framework::proto::OpDesc& op,
for (auto i = 0; i < op.attrs_size(); ++i) {
if (op.attrs(i).name() == name) {
found = true;
if (IsAttrVar(op, i)) break;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有些Op的Mapper中在构造时,会调用GetAttr获取默认值。当Attribute类型为Var时是无法获取到默认值的,故在此类接口中统一添加 IsAttrVar判断跳过的逻辑。

会在Mapper的OpSetX中自动触发IsAttrVar分支处理。

@jiangjiajun jiangjiajun merged commit 73b075b into PaddlePaddle:develop Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants