Skip to content
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

Support load state_dict from save_params/persistables #27298

Conversation

chenwhql
Copy link
Contributor

@chenwhql chenwhql commented Sep 14, 2020

PR types

New features

PR changes

APIs

Describe

支持使用paddle.load接口从save_params/save_persistables载入state_dict

前提:所给目录下找不到的*.pdparams并且找不到*.pdopt, 并且找不到静态图的模型文件__model__

  • 分散存储为多个参数文件:
    • 从目录读取文件名列表后载入
      • 如果存在非参数文件,load时报错(除非手动添加文件,一般不会有)
  • 存储为一个参数文件:
    • 暂不支持,建议使用io.load_program_state
      • 因为这种存储丢失了变量信息和实际tensor的映射,用户需要在动态图下构建这些信息比较复杂,不如在静态图下使用
      • 这种情况下,也能够正常载入,但仅会载入文件的第一个tensor,由于load op支持seek配置载入数据的位置,默认文件可以不被完全使用,这种case暂时不支持很好地报错提示

@chenwhql chenwhql merged commit c23f09f into PaddlePaddle:develop Sep 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants