[BugFix]Fix set_attr modify underly type #47500
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 types
Bug fixes
PR changes
Others
Describe
修复了当保存的模型包含一些反向算子时(如batch_norm_grad),在 _inference_optimize 函数修改
is_test
属性会导致其 attr_type 错误地由BOOL
变成INT
,会导致预测执行时报错。Pybind11 在似乎会将 Python端的True以 Int的形式传递给 C++ 后端。但我看了OpDesc::SetAttr 是包含这部分处理逻辑的,但前向算子是生效的,反向算子似乎没有按照预期生效,为了统一解决,这里修改为显式地调用
_set_bool_attr
: