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

【Hackathon 33】Modified the case where Tensor cannot be used on DCU #41695

Closed
wants to merge 4 commits into from

Conversation

ImNoBadBoy
Copy link

@ImNoBadBoy ImNoBadBoy commented Apr 12, 2022

PR types

【Hackathon 33 曙光算子修复】PR提交
#40300

PR changes

修改了四个文件
test_trunc_op.py
test_where_op.py
test_yolo_box_op.py
test_zeros_like_op.py

Describe

test_trunc_op.py

vim /public/home/acv2h3zdq0/Paddle/build/python/paddle/fluid/tests/unittests/test_trunc_op.py
42 self.check_output()
45 self.check_grad(['X'], 'Out', numeric_grad_delta=1e-5)

test_where_op.py

vim /public/home/acv2h3zdq0/Paddle/build/python/paddle/fluid/tests/unittests/test_where_op.py
251 assert np.array_equal(out.cpu().numpy(), np.where(cond_i, x_i, y_i))
269 result = result.cpu().numpy()
270 expect = np.where(cond.cpu(), a.cpu(), b.cpu())

test_yolo_box_op.py
没有修改直接测试通过

test_zeros_like_op.py

vim /public/home/acv2h3zdq0/Paddle/build/python/paddle/fluid/tests/unittests/test_zeros_like_op.py

73 if core.is_compiled_with_cuda():
74 self.assertEqual((out.cpu().numpy() == np.zeros(shape, dtype)).all(),True)
75 else:
76 self.assertEqual((out.numpy() == np.zeros(shape, dtype)).all(),True)

78 if core.is_compiled_with_cuda():
79 self.assertEqual((out.cpu().numpy() == np.zeros(shape, dtype)).all(), True)
80 else:
81 self.assertEqual((out.numpy() == np.zeros(shape, dtype)).all(), True)

83 if core.is_compiled_with_cuda():
84 self.assertEqual((out.cpu().numpy() == np.zeros(shape, dtype)).all(), True)
85 else:
86 self.assertEqual((out.numpy() == np.zeros(shape, dtype)).all(), True)
87 paddle.enable_static()

@CLAassistant
Copy link

CLAassistant commented Apr 12, 2022

CLA assistant check
All committers have signed the CLA.

@paddle-bot-old paddle-bot-old bot added contributor External developers status: proposed labels Apr 12, 2022
@paddle-bot-old
Copy link

❌ The PR is not created using PR's template. You can refer to this Demo.
Please use PR's template, it helps save our maintainers' time so that more developers get helped.

@paddle-bot-old
Copy link

你的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.

@@ -1,4 +1,4 @@
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
# Copyright (c) 021 PaddlePaddle Authors. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

这里不需要修改


if __name__ == "__main__":
unittest.main()
m __future__ import print_function
Copy link
Contributor

Choose a reason for hiding this comment

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

请检查一下这里多出的重复代码




import unittest
Copy link
Contributor

Choose a reason for hiding this comment

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

请检查这里多出的代码,另外请使用pre-commit工具在提交PR前检查一下

Copy link
Author

Choose a reason for hiding this comment

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

已经删除了

@@ -248,7 +248,7 @@ def test_api(self):
y = fluid.dygraph.to_variable(y_i)
cond = fluid.dygraph.to_variable(cond_i)
out = paddle.where(cond, x, y)
assert np.array_equal(out.numpy(), np.where(cond_i, x_i, y_i))
assert np.array_equal(out.cpu().numpy(), np.where(cond_i, x_i, y_i))
Copy link
Contributor

Choose a reason for hiding this comment

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

这里直接.numpy()不行吗?

Copy link
Author

Choose a reason for hiding this comment

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

cuda上的数据不能直接使用.numpy()获取数据值

Copy link
Contributor

Choose a reason for hiding this comment

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

cuda上的数据应该能拷贝到cpu再转成numpy,这个测试过吗?如果不可以,我再确认下

Copy link
Author

Choose a reason for hiding this comment

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

对的,我们单测通过了

self.assertEqual((out.numpy() == np.zeros(shape, dtype)).all(),
True)
if core.is_compiled_with_cuda():
self.assertEqual((out.cpu().numpy() == np.zeros(shape, dtype)).all(),True)
Copy link
Contributor

Choose a reason for hiding this comment

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

这里直接.numpy()不行吗?

Choose a reason for hiding this comment

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

cuda上的数据不能直接使用.numpy()获取数据值

Copy link
Contributor

Choose a reason for hiding this comment

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

cuda上的数据应该能拷贝到cpu再转成numpy,这个测试过吗?如果不可以,我再确认下

@TCChenlong
Copy link
Contributor

@ImNoBadBoy 可以根据 review 意见修改下~

修改第一行同原先本部一样
对无关代码进行删除
Copy link
Author

@ImNoBadBoy ImNoBadBoy left a comment

Choose a reason for hiding this comment

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

对代码进行了修改,把重复代码进行了删除

Copy link
Author

@ImNoBadBoy ImNoBadBoy left a comment

Choose a reason for hiding this comment

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

您好已经按照您的要求进行了修改

@@ -248,7 +248,7 @@ def test_api(self):
y = fluid.dygraph.to_variable(y_i)
cond = fluid.dygraph.to_variable(cond_i)
out = paddle.where(cond, x, y)
assert np.array_equal(out.numpy(), np.where(cond_i, x_i, y_i))
assert np.array_equal(out.cpu().numpy(), np.where(cond_i, x_i, y_i))
Copy link
Author

Choose a reason for hiding this comment

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

cuda上的数据不能直接使用.numpy()获取数据值

Copy link
Contributor

@ronny1996 ronny1996 left a comment

Choose a reason for hiding this comment

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

cuda上的数据应该能拷贝到cpu再转成numpy,这个测试过吗?如果不可以,我再确认下

self.assertEqual((out.numpy() == np.zeros(shape, dtype)).all(),
True)
if core.is_compiled_with_cuda():
self.assertEqual((out.cpu().numpy() == np.zeros(shape, dtype)).all(),True)
Copy link
Contributor

Choose a reason for hiding this comment

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

cuda上的数据应该能拷贝到cpu再转成numpy,这个测试过吗?如果不可以,我再确认下

@@ -248,7 +248,7 @@ def test_api(self):
y = fluid.dygraph.to_variable(y_i)
cond = fluid.dygraph.to_variable(cond_i)
out = paddle.where(cond, x, y)
assert np.array_equal(out.numpy(), np.where(cond_i, x_i, y_i))
assert np.array_equal(out.cpu().numpy(), np.where(cond_i, x_i, y_i))
Copy link
Contributor

Choose a reason for hiding this comment

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

cuda上的数据应该能拷贝到cpu再转成numpy,这个测试过吗?如果不可以,我再确认下

@paddle-bot-old
Copy link

paddle-bot-old bot commented May 3, 2022

Sorry to inform you that 1c7b152's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually.

@paddle-bot
Copy link

paddle-bot bot commented Aug 29, 2023

Since you haven't replied for more than a year, we have closed this issue/pr.
If the problem is not solved or there is a follow-up one, please reopen it at any time and we will continue to follow up.
由于您超过一年未回复,我们将关闭这个issue/pr。
若问题未解决或有后续问题,请随时重新打开,我们会继续跟进。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants