-
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
【NPU】Fix elementwise_div_grad op #31753
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ class TestElementwiseDiv(OpTest): | |
def setUp(self): | ||
self.set_npu() | ||
self.op_type = "elementwise_div" | ||
self.place = paddle.NPUPlace(0) | ||
self.place = paddle.NPUPlace(5) | ||
|
||
self.init_dtype() | ||
np.random.seed(SEED) | ||
|
@@ -56,12 +56,24 @@ def init_dtype(self): | |
def test_check_output(self): | ||
self.check_output_with_place(self.place, check_dygraph=False) | ||
|
||
# TODO(ascendrc): Div grad test | ||
# def test_check_grad(self): | ||
# if self.dtype == np.float16: | ||
# return | ||
# self.check_grad(['X'], 'Out') | ||
# | ||
def test_check_grad_normal(self): | ||
self.check_grad_with_place( | ||
self.place, ['X', 'Y'], | ||
'Out', | ||
max_relative_error=0.007, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. max_relative_error = 0.005 是否能过测试? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 精度只能到0.007,已在表格记录 |
||
check_dygraph=False) | ||
|
||
def test_check_grad_ingore_x(self): | ||
self.check_grad_with_place( | ||
self.place, ['Y'], | ||
'Out', | ||
max_relative_error=0.007, | ||
no_grad_set=set("X"), | ||
check_dygraph=False) | ||
|
||
def test_check_grad_ingore_y(self): | ||
self.check_grad_with_place( | ||
self.place, ['X'], 'Out', no_grad_set=set("Y"), check_dygraph=False) | ||
|
||
|
||
@unittest.skipIf(not paddle.is_compiled_with_npu(), | ||
|
@@ -70,7 +82,7 @@ class TestElementwiseDivFp16(OpTest): | |
def setUp(self): | ||
self.set_npu() | ||
self.op_type = "elementwise_div" | ||
self.place = paddle.NPUPlace(0) | ||
self.place = paddle.NPUPlace(5) | ||
|
||
self.init_dtype() | ||
np.random.seed(SEED) | ||
|
@@ -123,7 +135,7 @@ def _test(self, run_npu=True): | |
e = paddle.multiply(a, b) | ||
f = paddle.multiply(c, d) | ||
f.stop_gradient = True | ||
g = paddle.divide(e, f) | ||
g = fluid.layers.elementwise_div(e, f) | ||
|
||
fc_1 = fluid.layers.fc(input=g, size=128) | ||
prediction = fluid.layers.fc(input=fc_1, size=2, act='softmax') | ||
|
@@ -134,7 +146,7 @@ def _test(self, run_npu=True): | |
sgd.minimize(loss) | ||
|
||
if run_npu: | ||
place = paddle.NPUPlace(0) | ||
place = paddle.NPUPlace(5) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 同上:5 -> 0 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fix |
||
else: | ||
place = paddle.CPUPlace() | ||
|
||
|
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.place = paddle.NPUPlace(5)
->
self.place = paddle.NPUPlace(0)
请改用0号卡,之后CI 测试不一定有5号卡。
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.
fix