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

Enhance Check mechanism and Support single tuple/list of fetch_list in Executor #35726

Merged
merged 4 commits into from
Sep 15, 2021

Conversation

Aurelius84
Copy link
Contributor

@Aurelius84 Aurelius84 commented Sep 14, 2021

PR types

Bug fixes

PR changes

APIs

Describe

Enhance Check mechanism of fetch_list in Executor

在下面的case中,如果传入的fetch_list值为[(var1, var2, var3)],且var1.shape[0]=-1时,执行会进入无限循环中。

此PR修复了此问题,对fetch_list接受的参数类型兼容性扩展支持:

  • 支持fetch_list=[tuple]或者fetch_list=[list],但tuple和list必须是单层的
  • _split_optimize_ops_in_fetch_list添加必要的类型检查,避免进入死循环

复现代码:

import paddle
import numpy as np
from inspect import isfunction

paddle.enable_static()
paddle.set_device('cpu')

main_program = paddle.static.Program()
start_program = paddle.static.Program()
main_program.random_seed = 222
start_program.random_seed = 222

feed = {
    "x":  np.array([[0], [0], [1], [0]], dtype='float32')
}


with paddle.utils.unique_name.guard():
    with paddle.static.program_guard(main_program=main_program, startup_program=start_program):
        x = paddle.static.data(name='x', shape=[4, 1], dtype='float32')
        output = paddle.unique_consecutive(x, return_inverse=True, return_counts=True, axis=0)
        exe = paddle.static.Executor(paddle.CPUPlace())
        exe.run(start_program)
        res = exe.run(
            main_program,
            feed=feed,
            fetch_list=[output],
            return_numpy=True
        )
        print(res)

@paddle-bot-old
Copy link

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

@Aurelius84 Aurelius84 changed the title Enhance Check mechanism of fetch_list in Executor Enhance Check mechanism and Support single tuple/list of fetch_list in Executor Sep 14, 2021
@Aurelius84 Aurelius84 merged commit cae050e into PaddlePaddle:develop Sep 15, 2021
AnnaTrainingG pushed a commit to AnnaTrainingG/Paddle that referenced this pull request Sep 29, 2021
…n Executor (PaddlePaddle#35726)

* Enhance Check mechanism of fetch_list in Executor

* support single tuple

* fix typo

* fix typo
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