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

【PIR API adaptor No.174】 Migrate paddle.randint_like into pir #58953

Merged
merged 31 commits into from
Nov 30, 2023

Conversation

enkilee
Copy link
Contributor

@enkilee enkilee commented Nov 13, 2023

PR types

Others

PR changes

APIs

Description

Copy link

paddle-bot bot commented Nov 13, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added the contributor External developers label Nov 13, 2023
@luotao1 luotao1 added the HappyOpenSource 快乐开源活动issue与PR label Nov 13, 2023
@enkilee
Copy link
Contributor Author

enkilee commented Nov 17, 2023

2023-11-17 12:46:24 ======================================================================
2023-11-17 12:46:24 ERROR: test_static_api_with_float32 (test_randint_like.TestRandintLikeAPI)
2023-11-17 12:46:24 ----------------------------------------------------------------------
2023-11-17 12:46:24 Traceback (most recent call last):
2023-11-17 12:46:24   File "/workspace/Paddle/build/python/paddle/pir_utils.py", line 115, in impl
2023-11-17 12:46:24     func(*args, **kwargs)
2023-11-17 12:46:24   File "/workspace/Paddle/build/test/legacy_test/test_randint_like.py", line 138, in test_static_api_with_float32
2023-11-17 12:46:24     outs5 = exe.run(
2023-11-17 12:46:24   File "/workspace/Paddle/build/python/paddle/base/executor.py", line 1707, in run
2023-11-17 12:46:24     res = self._run_pir_impl(
2023-11-17 12:46:24   File "/workspace/Paddle/build/python/paddle/base/executor.py", line 2020, in _run_pir_impl
2023-11-17 12:46:24     self._pir_feed_data(program, feed, scope)
2023-11-17 12:46:24   File "/workspace/Paddle/build/python/paddle/base/executor.py", line 1328, in _pir_feed_data
2023-11-17 12:46:24     cur_feed = feed[feed_target_name]
2023-11-17 12:46:24 KeyError: 'x_bool'

@0x45f @MarioLulab 大佬帮忙看下?为什么会出现这种错误,改了几种都不行

@MarioLulab
Copy link
Contributor

executor.py

收到,我在尝试复现。有结果了及时回复你~

@MarioLulab
Copy link
Contributor

MarioLulab commented Nov 19, 2023

2023-11-17 12:46:24 ======================================================================
2023-11-17 12:46:24 ERROR: test_static_api_with_float32 (test_randint_like.TestRandintLikeAPI)
2023-11-17 12:46:24 ----------------------------------------------------------------------
2023-11-17 12:46:24 Traceback (most recent call last):
2023-11-17 12:46:24   File "/workspace/Paddle/build/python/paddle/pir_utils.py", line 115, in impl
2023-11-17 12:46:24     func(*args, **kwargs)
2023-11-17 12:46:24   File "/workspace/Paddle/build/test/legacy_test/test_randint_like.py", line 138, in test_static_api_with_float32
2023-11-17 12:46:24     outs5 = exe.run(
2023-11-17 12:46:24   File "/workspace/Paddle/build/python/paddle/base/executor.py", line 1707, in run
2023-11-17 12:46:24     res = self._run_pir_impl(
2023-11-17 12:46:24   File "/workspace/Paddle/build/python/paddle/base/executor.py", line 2020, in _run_pir_impl
2023-11-17 12:46:24     self._pir_feed_data(program, feed, scope)
2023-11-17 12:46:24   File "/workspace/Paddle/build/python/paddle/base/executor.py", line 1328, in _pir_feed_data
2023-11-17 12:46:24     cur_feed = feed[feed_target_name]
2023-11-17 12:46:24 KeyError: 'x_bool'

@0x45f @MarioLulab 大佬帮忙看下?为什么会出现这种错误,改了几种都不行

我已在本地复现并 fix 了。请将test/legacy_test/test_randint_like.py 里所有的 Program 修改为 paddle.static.Program, program_guard 修改为 paddle.static.program_guard。
因为这和我们单测的执行机制有关系,单测在加入test_with_pir_api装饰器后,会执行一次老ir再执行一次新ir,这里有一个Program的切换过程,Program切换在paddle.static.Program这种情况下是可以切换的,但是如果提前通过import导入Program,由于Program已经导进来了,会造成无法正常切换Program

@enkilee
Copy link
Contributor Author

enkilee commented Nov 20, 2023

收到

Copy link
Contributor

@MarioLulab MarioLulab left a comment

Choose a reason for hiding this comment

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

nice work~
但是 test/legacy_test/test_zero_dim_tensor.py 里的 TestNoBackwardAPIStatic 还有 test_randint_and_randint_like 单测,麻烦也一起适配一下吧

test/legacy_test/test_randint_like.py Show resolved Hide resolved
@enkilee
Copy link
Contributor Author

enkilee commented Nov 21, 2023

2023-11-21 13:59:49 ======================================================================
2023-11-21 13:59:49 ERROR: test_randint_and_randint_like (test_zero_dim_tensor.TestNoBackwardAPIStatic)
2023-11-21 13:59:49 ----------------------------------------------------------------------
2023-11-21 13:59:49 Traceback (most recent call last):
2023-11-21 13:59:49   File "C:\home\workspace\Paddle\build\python\paddle\pir_utils.py", line 115, in impl
2023-11-21 13:59:49     func(*args, **kwargs)
2023-11-21 13:59:49   File "C:\home\workspace\Paddle\build\test\legacy_test\test_zero_dim_tensor.py", line 5815, in test_randint_and_randint_like
2023-11-21 13:59:49     out3 = paddle.randint(-10, 10, self.shape)
2023-11-21 13:59:49   File "C:\home\workspace\Paddle\build\python\paddle\tensor\random.py", line 997, in randint
2023-11-21 13:59:49     shape = paddle.utils.convert_shape_to_list(shape)
2023-11-21 13:59:49   File "C:\home\workspace\Paddle\build\python\paddle\utils\layers_utils.py", line 490, in convert_shape_to_list
2023-11-21 13:59:49     shape = [x.item(0) if isinstance(x, Variable) else x for x in shape]
2023-11-21 13:59:49   File "C:\home\workspace\Paddle\build\python\paddle\utils\layers_utils.py", line 490, in <listcomp>
2023-11-21 13:59:49     shape = [x.item(0) if isinstance(x, Variable) else x for x in shape]
2023-11-21 13:59:49   File "C:\home\workspace\cache\python_venv\lib\site-packages\decorator.py", line 231, in fun
2023-11-21 13:59:49     args, kw = fix(args, kw, sig)
2023-11-21 13:59:49   File "C:\home\workspace\cache\python_venv\lib\site-packages\decorator.py", line 203, in fix
2023-11-21 13:59:49     ba = sig.bind(*args, **kwargs)
2023-11-21 13:59:49   File "C:\Python310\lib\inspect.py", line 3177, in bind
2023-11-21 13:59:49     return self._bind(args, kwargs)
2023-11-21 13:59:49   File "C:\Python310\lib\inspErrors while running CTest
2023-11-21 13:59:49 ect.py", line 3098, in _bind
2023-11-21 13:59:49     raise TypeError('too many positional arguments') from None
2023-11-21 13:59:49 TypeError: too many positional arguments

@enkilee enkilee closed this Nov 21, 2023
@enkilee
Copy link
Contributor Author

enkilee commented Nov 21, 2023

2023-11-21 13:59:49 ======================================================================
2023-11-21 13:59:49 ERROR: test_randint_and_randint_like (test_zero_dim_tensor.TestNoBackwardAPIStatic)
2023-11-21 13:59:49 ----------------------------------------------------------------------
2023-11-21 13:59:49 Traceback (most recent call last):
2023-11-21 13:59:49   File "C:\home\workspace\Paddle\build\python\paddle\pir_utils.py", line 115, in impl
2023-11-21 13:59:49     func(*args, **kwargs)
2023-11-21 13:59:49   File "C:\home\workspace\Paddle\build\test\legacy_test\test_zero_dim_tensor.py", line 5815, in test_randint_and_randint_like
2023-11-21 13:59:49     out3 = paddle.randint(-10, 10, self.shape)
2023-11-21 13:59:49   File "C:\home\workspace\Paddle\build\python\paddle\tensor\random.py", line 997, in randint
2023-11-21 13:59:49     shape = paddle.utils.convert_shape_to_list(shape)
2023-11-21 13:59:49   File "C:\home\workspace\Paddle\build\python\paddle\utils\layers_utils.py", line 490, in convert_shape_to_list
2023-11-21 13:59:49     shape = [x.item(0) if isinstance(x, Variable) else x for x in shape]
2023-11-21 13:59:49   File "C:\home\workspace\Paddle\build\python\paddle\utils\layers_utils.py", line 490, in <listcomp>
2023-11-21 13:59:49     shape = [x.item(0) if isinstance(x, Variable) else x for x in shape]
2023-11-21 13:59:49   File "C:\home\workspace\cache\python_venv\lib\site-packages\decorator.py", line 231, in fun
2023-11-21 13:59:49     args, kw = fix(args, kw, sig)
2023-11-21 13:59:49   File "C:\home\workspace\cache\python_venv\lib\site-packages\decorator.py", line 203, in fix
2023-11-21 13:59:49     ba = sig.bind(*args, **kwargs)
2023-11-21 13:59:49   File "C:\Python310\lib\inspect.py", line 3177, in bind
2023-11-21 13:59:49     return self._bind(args, kwargs)
2023-11-21 13:59:49   File "C:\Python310\lib\inspErrors while running CTest
2023-11-21 13:59:49 ect.py", line 3098, in _bind
2023-11-21 13:59:49     raise TypeError('too many positional arguments') from None
2023-11-21 13:59:49 TypeError: too many positional arguments

@enkilee enkilee reopened this Nov 21, 2023
python/paddle/tensor/random.py Outdated Show resolved Hide resolved
python/paddle/tensor/random.py Outdated Show resolved Hide resolved
python/paddle/utils/layers_utils.py Outdated Show resolved Hide resolved
@enkilee
Copy link
Contributor Author

enkilee commented Nov 24, 2023

@MarioLulab randint的0维好像有问题

@MarioLulab
Copy link
Contributor

@MarioLulab randint的0维好像有问题

请问具体是什么问题呢?有报错栈吗

@enkilee
Copy link
Contributor Author

enkilee commented Nov 27, 2023

@MarioLulab 您好:

@MarioLulab randint的0维好像有问题

请问具体是什么问题呢?有报错栈吗

2023-11-21 13:59:49 
2023-11-21 13:59:49 ERROR: test_randint_and_randint_like (test_zero_dim_tensor.TestNoBackwardAPIStatic)
2023-11-21 13:59:49 ----------------------------------------------------------------------
2023-11-21 13:59:49 Traceback (most recent call last):
2023-11-21 13:59:49   File "C:\home\workspace\Paddle\build\python\paddle\pir_utils.py", line 115, in impl
2023-11-21 13:59:49     func(*args, **kwargs)
2023-11-21 13:59:49   File "C:\home\workspace\Paddle\build\test\legacy_test\test_zero_dim_tensor.py", line 5815, in test_randint_and_randint_like
2023-11-21 13:59:49     out3 = paddle.randint(-10, 10, self.shape)
2023-11-21 13:59:49   File "C:\home\workspace\Paddle\build\python\paddle\tensor\random.py", line 997, in randint
2023-11-21 13:59:49     shape = paddle.utils.convert_shape_to_list(shape)
2023-11-21 13:59:49   File "C:\home\workspace\Paddle\build\python\paddle\utils\layers_utils.py", line 490, in convert_shape_to_list
2023-11-21 13:59:49     shape = [x.item(0) if isinstance(x, Variable) else x for x in shape]
2023-11-21 13:59:49   File "C:\home\workspace\Paddle\build\python\paddle\utils\layers_utils.py", line 490, in <listcomp>
2023-11-21 13:59:49     shape = [x.item(0) if isinstance(x, Variable) else x for x in shape]
2023-11-21 13:59:49   File "C:\home\workspace\cache\python_venv\lib\site-packages\decorator.py", line 231, in fun
2023-11-21 13:59:49     args, kw = fix(args, kw, sig)
2023-11-21 13:59:49   File "C:\home\workspace\cache\python_venv\lib\site-packages\decorator.py", line 203, in fix
2023-11-21 13:59:49     ba = sig.bind(*args, **kwargs)
2023-11-21 13:59:49   File "C:\Python310\lib\inspect.py", line 3177, in bind
2023-11-21 13:59:49     return self._bind(args, kwargs)
2023-11-21 13:59:49   File "C:\Python310\lib\inspErrors while running CTest
2023-11-21 13:59:49 ect.py", line 3098, in _bind
2023-11-21 13:59:49     raise TypeError('too many positional arguments') from None
2023-11-21 13:59:49 TypeError: too many positional arguments

所以在zero_dim那里,我把randint_like和randint分开了。试着改了下randint的,发现不行,就分开了。

Copy link
Contributor

@MarioLulab MarioLulab left a comment

Choose a reason for hiding this comment

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

LGTM

python/paddle/tensor/random.py Show resolved Hide resolved
python/paddle/tensor/random.py Outdated Show resolved Hide resolved
@0x45f 0x45f merged commit f45fe2a into PaddlePaddle:develop Nov 30, 2023
@enkilee enkilee deleted the pir-api-174 branch December 14, 2023 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource 快乐开源活动issue与PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants