CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[Fix] Keep inference model output keys same order with dynamic model #63791
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
[Fix] Keep inference model output keys same order with dynamic model #63791
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
2d581bb
to
7dea0f6
Compare
python/paddle/utils/layers_utils.py
Outdated
@@ -145,7 +145,7 @@ def _sorted(dict_): | |||
Returns a sorted list of the dict keys, with error if keys not sortable. | |||
""" | |||
try: | |||
return sorted(dict_.keys()) | |||
return list(dict_.keys()) | |||
except TypeError: | |||
raise TypeError("nest only supports dicts with sortable keys.") |
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.
这个函数是不是可以删了,下面 160 行直接调用 list(iterable.keys())
就好,160 行上面的注释也可以删了,_sequence_like
同样
另外可以按照注释里所说的情况加个单测看看 map_structure
、pack_sequence_as
等 API 是否还符合预期,这个 flatten
也测一下吧
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.
这个函数是不是可以删了,下面 160 行直接调用
list(iterable.keys())
就好,160 行上面的注释也可以删了,_sequence_like
同样另外可以按照注释里所说的情况加个单测看看
map_structure
、pack_sequence_as
等 API 是否还符合预期,这个flatten
也测一下吧
已添加单测
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.
可以单独测一下 pack_sequence_as
和 map_structure
吧,这俩我更担心会有问题,很多地方都在使用这俩函数
python/paddle/utils/layers_utils.py
Outdated
# ordered and plain dicts (e.g., flattening a dict but using a | ||
# corresponding `OrderedDict` to pack it back). | ||
for key in _sorted(iterable): | ||
# NOTE: Keep order unchanged as python dict is ordered since python3.7 |
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.
3.6+ 吧?
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.
已修改
e3eaab5
to
4dde7fc
Compare
4dde7fc
to
b176c29
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.
PR Category
Inference
PR Types
Bug fixes
Description
Pcard-75624
Keep output order of exported inference model same with dynamic model.
before:
after: