Skip to content

[PIR] Adaptation of TestNoBackwardAPIStatic.test_unique* - #62794

Merged
SigureMo merged 4 commits into
PaddlePaddle:developfrom
gouzil:fix_test_zero_dim_4
Mar 17, 2024
Merged

SigureMo merged 4 commits into
PaddlePaddle:developfrom
gouzil:fix_test_zero_dim_4

Conversation

@gouzil

@gouzil gouzil commented Mar 17, 2024

Copy link
Copy Markdown
Collaborator

PR types

Bug fixes

PR changes

Others

Description

适配 test/legacy_test/test_zero_dim_no_backward_api.py 下的 TestNoBackwardAPIStatic.test_unique_consecutive和TestNoBackwardAPIStatic.test_unique,改为测试执行后的结果

我们在这里不能直接使用 Value 进行比较,一个是unique_consecutive,一个是uniform

相关链接:

@paddle-bot

paddle-bot Bot commented Mar 17, 2024

Copy link
Copy Markdown

你的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 Mar 17, 2024
self.assertEqual(inverse, 0)
self.assertEqual(counts, 1)
self.assertEqual(res[0].shape, (1,))
res = self.exe.run(prog, fetch_list=[x, y, inverse, counts])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
res = self.exe.run(prog, fetch_list=[x, y, inverse, counts])
x_res, y_res, inverse_res, counts_res = self.exe.run(prog, fetch_list=[x, y, inverse, counts])

这样一目了然,不然下面取下标还得看 0、1、2、3 分别是啥

self.assertEqual(counts, 1)
self.assertEqual(res[0].shape, (1,))
res = self.exe.run(prog, fetch_list=[x, y, inverse, counts])
self.assertEqual(res[0], res[1])

@SigureMo SigureMo Mar 17, 2024 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

合理,原来代码就是个隐藏的 bug,Variable == Variable 返回 Variable,bool(Variable) 永远为 True

Comment on lines +500 to +501
self.assertEqual(res[2], 0)
self.assertEqual(res[3], 1)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这里修改也是合理的,原来就是 bug

self.assertEqual(inverse, 0)
self.assertEqual(counts, 1)
self.assertEqual(res[0].shape, (1,))
res = self.exe.run(prog, fetch_list=[x, y, index, inverse, counts])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

同上,使用名字吧

SigureMo
SigureMo previously approved these changes Mar 17, 2024

@SigureMo SigureMo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTMeow 🐾

@SigureMo
SigureMo merged commit a2dd9e4 into PaddlePaddle:develop Mar 17, 2024
@gouzil
gouzil deleted the fix_test_zero_dim_4 branch April 9, 2024 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants