-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[Typing][B-52] Add type annotations for python/paddle/onnx/export.py
#66862
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
python/paddle/onnx/export.py
Outdated
class _ConfigsList(TypedDict): | ||
output_spec: NotRequired[list[Tensor]] | ||
with_hook: NotRequired[bool] | ||
combine_params: NotRequired[bool] | ||
clip_extra: NotRequired[bool] | ||
skip_forward: NotRequired[bool] | ||
input_names_after_prune: NotRequired[list[str]] |
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.
能不能直接用 python/paddle/jit/api.py
的 _SaveOptions
?
另外,@SigureMo 这个 _SaveOptions
的 output_spec
是不是 Sequence[Tensor | int]
?
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.
我看了下,不太一样。那个多了个参数skip_prune_program
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.
paddleonnx/utils.py那边:
supported_configs = { "output_spec", "with_hook", "combine_params", "clip_extra", "skip_forward", "input_names_after_prune", }
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.
嗯 感觉应该是 paddle2onnx
对齐 paddle
?
@Zheng-Bicheng 大佬,帮忙看看?!这个 supported_configs
具体有哪些?🫠
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.
@Jiang-Jia-Jun 大佬帮忙看看呢?这部分代码不是我写的,我不太了解。
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.
我看了下,不太一样。那个多了个参数skip_prune_program
那个是新增的参数,只不过是 paddle2onnx 没有跟进而已,比如在那之前加的 input_names_after_prune
就跟进在 paddle2onnx 加了,因为当时 CI 挂了,后面的参数 skip_prune_program
估计是因为 CI 也没挂就没人管了
paddle2onnx 加这个检查(paddle_jit_save_configs
)基本没啥意义,反而两个 repo 之间协同会麻烦很多,建议删了
这里直接对齐 jit.save 的 Options
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.
这个 _SaveOptions 的 output_spec 是不是 Sequence[Tensor | int] ?
嗯,我改一下
python/paddle/onnx/export.py
Outdated
def export( | ||
layer: Layer, | ||
path: str, | ||
input_spec: list[InputSpec | Tensor] | None = None, |
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.
这里也可以参考 python/paddle/jit/api.py
的 save
input_spec: Sequence[InputSpec | paddle.Tensor | object] | None = None,
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.
我看参数说明里写的只有list,没有tuple,也没有python built-in variables
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.
整个调用逻辑,最后走的是 paddle.jit.save
,个人感觉以这个为准?
@SigureMo @Zheng-Bicheng 两位大佬怎么看?
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.
整个调用逻辑,最后走的是 paddle.jit.save ,个人感觉以这个为准?
大佬,我觉得理论上也应该是这样的,但是最好还是让佳军(@Jiang-Jia-Jun)再确认下,这部分代码应该比较古老了。
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.
@Zheng-Bicheng |
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.
LGTM
PR Category
User Experience
PR Types
Improvements
Description
B52