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

paddle.save/load program #32336

Merged
merged 1 commit into from
Apr 20, 2021
Merged

Conversation

hbwx24
Copy link
Contributor

@hbwx24 hbwx24 commented Apr 18, 2021

PR types

Function optimization

PR changes

APIs

Describe

支持保存加载Program.
示例:

def test_save_load_program(self):
    paddle.enable_static()
    
    layer = LinearNet()
    data = paddle.static.data(
        name='x_static_save', shape=(None, IMAGE_SIZE), dtype='float32')
    y_static = layer(data)
    main_program = paddle.static.default_main_program()
    startup_program = paddle.static.default_startup_program()
    origin_main = main_program.desc.serialize_to_string()
    origin_startup = startup_program.desc.serialize_to_string()
    path1 = "test_paddle_save_load_program/main_program.pdmodel"
    path2 = "test_paddle_save_load_program/startup_program.pdmodel"
    paddle.save(main_program, path1)
    paddle.save(startup_program, path2)

    load_main = paddle.load(path1).desc.serialize_to_string()
    load_startup = paddle.load(path2).desc.serialize_to_string()
    print(origin_main == load_main)
    print(origin_startup == load_startup)

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

Copy link
Contributor

@chenwhql chenwhql left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@chenwhql chenwhql merged commit e0a52fd into PaddlePaddle:develop Apr 20, 2021
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