-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
【WIP】update for infer config #13524
base: main
Are you sure you want to change the base?
【WIP】update for infer config #13524
Conversation
tools/infer/utility.py
Outdated
if paddle.__version__ == "0.0.0" or paddle.__version__ >= "3.0.0": | ||
model_path = model_dir | ||
model_prefix = file_name | ||
config = inference.Config(model_path, model_prefix) | ||
else: | ||
config = inference.Config(model_file_path, params_file_path) |
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.
这里的改动,是为了适配 PIR 启用后,存储下来的模型文件的变化吧?
正确的判断应该使用 API, 而不是版本号,因为,即便是在 3.0.0 及后续的版本下,也可以通过环境变量来设定是否使用 PIR 。
我不太确定应该用 paddle.framework.in_pir_mode()
还是用paddle.framework.in_pir_executor_mode
来判断。
另外,根据我的理解,如果使用 inference.Config(model_path, model_prefix)
的话,paddle.load
就会自己对新旧模式兼容了?
cc: @phlrain @Aurelius84
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.
是的,为了适应PIR。 根据现在的说明文档,inference.Config 只在3.0 以上生效,因此在版本号小于3.0时无法自动判断。
注意:如果套件库需要兼容支持paddle2.x ,需要按照版本做分支处理(config 的新接口只在3.0 beta 版之后提供)
环境变量的使用方式我再确认一下~
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.
注意:如果套件库需要兼容支持paddle2.x ,需要按照版本做分支处理(config 的新接口只在3.0 beta 版之后提供)
这个说明是来自哪儿?
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.
这个说明是来自哪儿?
是内部的开发文档
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.
我查到了,是新的版本下 inference Config 才能支持传入的是模型目录名的原因吧。
真是令人头大~
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
|
* update infer/utility.py to support json format model * merge from #13524 * fix bug * fix bug * Update tools/infer/utility.py Co-authored-by: jzhang533 <[email protected]> * fix codestyle --------- Co-authored-by: jzhang533 <[email protected]>
att