-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Conversation
❌ The PR is not created using PR's template. You can refer to this Demo. |
你的PR提交成功,感谢你对开源项目的贡献! |
@@ -1,4 +1,4 @@ | |||
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved. | |||
# Copyright (c) 021 PaddlePaddle Authors. All Rights Reserved. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
请检查一下这里多出的重复代码
|
||
|
||
|
||
import unittest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
请检查这里多出的代码,另外请使用pre-commit工具在提交PR前检查一下
There was a problem hiding this 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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里直接.numpy()不行吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cuda上的数据不能直接使用.numpy()获取数据值
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cuda上的数据应该能拷贝到cpu再转成numpy,这个测试过吗?如果不可以,我再确认下
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里直接.numpy()不行吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cuda上的数据不能直接使用.numpy()获取数据值
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cuda上的数据应该能拷贝到cpu再转成numpy,这个测试过吗?如果不可以,我再确认下
@ImNoBadBoy 可以根据 review 意见修改下~ |
修改第一行同原先本部一样
对无关代码进行删除
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
对代码进行了修改,把重复代码进行了删除
There was a problem hiding this 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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cuda上的数据不能直接使用.numpy()获取数据值
There was a problem hiding this 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) |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cuda上的数据应该能拷贝到cpu再转成numpy,这个测试过吗?如果不可以,我再确认下
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. |
Since you haven't replied for more than a year, we have closed this issue/pr. |
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()