Repository navigation
Dynamically bind dtype - #62508
Merged
Merged
Dynamically bind dtype #62508
Conversation
|
你的PR提交成功,感谢你对开源项目的贡献! |
… fix the dtype check in `monkey_patch_math_tensor.py` to also consider `core.DataType` in addition to `core.VarDesc.VarType`.
…move unnecessary code
28 tasks done
Fixes an issue where the comparison of variable dtypes was incorrect in the `monkey_patch_tensor` function. The comparison now correctly checks the dtype of the variable.
SigureMo
reviewed
Mar 11, 2024
…de, dtype should always be DataType
…type conversion cause a cache miss error
0x45f
approved these changes
Mar 12, 2024
YuanRisheng
reviewed
Mar 12, 2024
Comment on lines
+860
to
+863
| if (var_tensor->IsType<paddle::framework::Vocab>()) { | ||
| return ToPyObject(phi::DataType::UNDEFINED); | ||
| } else if (var_tensor->IsType<paddle::framework::Strings>()) { | ||
| return ToPyObject(phi::DataType::PSTRING); |
Collaborator
There was a problem hiding this comment.
PR的修改对当前的代码执行应该是没有影响,不过当前pir下的DataType里并没有RAW和STRING类型,需要讨论确认在动态图模式下,此修改对相关模型执行的影响
Aurelius84
reviewed
Mar 13, 2024
| return ToPyObject(framework::proto::VarType::RAW); | ||
| } else if (var_tensor->IsType<paddle::framework::Strings>()) { | ||
| return ToPyObject(framework::proto::VarType::STRING); | ||
| if (FLAGS_enable_pir_api) { |
Collaborator
There was a problem hiding this comment.
下面这个分支里的逻辑,后续可以考虑抽离成一个函数,避免if-for的多层嵌套
Aurelius84
approved these changes
Mar 13, 2024
28 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Others
PR changes
Others
Description
目前框架内有两套dtype的表示,一套是老静态图的VarType,一套是PIR下的DataType。动态图在c++端底层的dtype都是DataType,但是之前应该是为了兼容,所以动态图python的dtype也还是VarType类型。
这个pr主要是想修改python端的paddle.dtype,在PIR下paddle.dtype返回的是DataType类型;在老静态图下返回的是VarType类型。
通过将动态图切分成 PIR 和非 PIR 模式,以确保在任何一种情况下 dtype 都是动静统一的,以免添加众多繁杂的转换、特殊处理逻辑,在不久的将来,左侧的
not use_pir_api场景就可以完全废弃掉了Important
本 PR 主要影响是在开启
FLAGS_enable_pir_api=True场景下动态图的行为(含动转静),当然,CI 上目前没有这种测试(除动转静单测,动转静单测整体还是跑在动态图下,因此会测到部分动态图相关逻辑),因此测试可能是不全面的,这就需要未来去逐渐针对适配升级,不过当前 PR 已经手动在部分 Seg、Detection 模型上测试开启FLAGS_enable_pir_api=True通过,更多的场景可能需要在合入后联动「SOT+PIR」模型测试一同测试和修复(就目前经验而言,这类问题修复非常快)参考 #62146