Repository navigation
[WIP][CodeStyle] use np.testing.assert_allclose instead of assertTrue(np.allclose(...)) in op_test - #46695
[WIP][CodeStyle] use np.testing.assert_allclose instead of assertTrue(np.allclose(...)) in op_test#46695SigureMo wants to merge 4 commits into
Conversation
|
你的PR提交成功,感谢你对开源项目的贡献! |
|
很抱歉,经过我们的反复讨论,你的PR暂未达到合入标准,请阅读飞桨原生算子开发规范,你可以重新提交新的PR,我们先将此PR关闭,感谢你的贡献。 |
|
很抱歉,经过我们的反复讨论,你的PR暂未达到合入标准,请阅读飞桨原生算子开发规范,你可以重新提交新的PR,我们先将此PR关闭,感谢你的贡献。 |
| rtol=self.rtol, | ||
| atol=self.atol, | ||
| equal_nan=self.equal_nan) | ||
| } |
There was a problem hiding this comment.
2022-10-01 17:28:28 ======================================================================
2022-10-01 17:28:28 FAIL: test_check_output (test_isclose_op.TestIscloseOpFloat64)
2022-10-01 17:28:28 ----------------------------------------------------------------------
2022-10-01 17:28:28 Traceback (most recent call last):
2022-10-01 17:28:28 File "/workspace/Paddle/build/python/paddle/fluid/tests/unittests/test_isclose_op.py", line 228, in test_check_output
2022-10-01 17:28:28 self.check_output(check_eager=True)
2022-10-01 17:28:28 File "/workspace/Paddle/build/python/op_test.py", line 1799, in check_output
2022-10-01 17:28:28 check_eager=check_eager)
2022-10-01 17:28:28 File "/workspace/Paddle/build/python/op_test.py", line 1664, in check_output_with_place
2022-10-01 17:28:28 static_checker.check()
2022-10-01 17:28:28 File "/workspace/Paddle/build/python/op_test.py", line 1494, in check
2022-10-01 17:28:28 self.compare_outputs_with_expects()
2022-10-01 17:28:28 File "/workspace/Paddle/build/python/op_test.py", line 1484, in compare_outputs_with_expects
2022-10-01 17:28:28 self.compare_single_output_with_expect(out_name, expect)
2022-10-01 17:28:28 File "/workspace/Paddle/build/python/op_test.py", line 1465, in compare_single_output_with_expect
2022-10-01 17:28:28 self._compare_numpy(name, actual_np, expect_np)
2022-10-01 17:28:28 File "/workspace/Paddle/build/python/op_test.py", line 1448, in _compare_numpy
2022-10-01 17:28:28 " in " + self.checker_name)
2022-10-01 17:28:28 File "/opt/_internal/cpython-3.7.0/lib/python3.7/site-packages/numpy/testing/_private/utils.py", line 1531, in assert_allclose
2022-10-01 17:28:28 verbose=verbose, header=header, equal_nan=equal_nan)
2022-10-01 17:28:28 File "/opt/_internal/cpython-3.7.0/lib/python3.7/site-packages/numpy/testing/_private/utils.py", line 763, in assert_array_compare
2022-10-01 17:28:28 raise AssertionError(msg)
2022-10-01 17:28:28 AssertionError:
2022-10-01 17:28:28 Not equal to tolerance rtol=1e-05, atol=0
2022-10-01 17:28:28 Output (Out) has diff at Place(cpu) in static checker
2022-10-01 17:28:28 (shapes (1,), (1, 1) mismatch)
2022-10-01 17:28:28 x: array([ True])
2022-10-01 17:28:28 y: array([[ True]])
2022-10-01 17:28:28
所有的 expect 都比 actual 多一个维度,因此删掉外层 np.array([...])
| (2, 5, 3, 2, 2, 3, 4, 2)).astype("bool") | ||
| } | ||
| self.attrs = {'reduce_all': True, 'dim': (2, 3, 4)} | ||
| self.attrs = {'dim': (2, 3, 4)} |
There was a problem hiding this comment.
2022-10-01 17:31:33 ======================================================================
2022-10-01 17:31:33 FAIL: test_check_output (test_reduce_op.TestAll8DOp)
2022-10-01 17:31:33 ----------------------------------------------------------------------
2022-10-01 17:31:33 Traceback (most recent call last):
2022-10-01 17:31:33 File "/workspace/Paddle/build/python/paddle/fluid/tests/unittests/test_reduce_op.py", line 365, in test_check_output
2022-10-01 17:31:33 self.check_output(check_eager=True)
2022-10-01 17:31:33 File "/workspace/Paddle/build/python/op_test.py", line 1799, in check_output
2022-10-01 17:31:33 check_eager=check_eager)
2022-10-01 17:31:33 File "/workspace/Paddle/build/python/op_test.py", line 1664, in check_output_with_place
2022-10-01 17:31:33 static_checker.check()
2022-10-01 17:31:33 File "/workspace/Paddle/build/python/op_test.py", line 1494, in check
2022-10-01 17:31:33 self.compare_outputs_with_expects()
2022-10-01 17:31:33 File "/workspace/Paddle/build/python/op_test.py", line 1484, in compare_outputs_with_expects
2022-10-01 17:31:33 self.compare_single_output_with_expect(out_name, expect)
2022-10-01 17:31:33 File "/workspace/Paddle/build/python/op_test.py", line 1465, in compare_single_output_with_expect
2022-10-01 17:31:33 self._compare_numpy(name, actual_np, expect_np)
2022-10-01 17:31:33 File "/workspace/Paddle/build/python/op_test.py", line 1448, in _compare_numpy
2022-10-01 17:31:33 " in " + self.checker_name)
2022-10-01 17:31:33 File "/opt/_internal/cpython-3.7.0/lib/python3.7/site-packages/numpy/testing/_private/utils.py", line 1531, in assert_allclose
2022-10-01 17:31:33 verbose=verbose, header=header, equal_nan=equal_nan)
2022-10-01 17:31:33 File "/opt/_internal/cpython-3.7.0/lib/python3.7/site-packages/numpy/testing/_private/utils.py", line 763, in assert_array_compare
2022-10-01 17:31:33 raise AssertionError(msg)
2022-10-01 17:31:33 AssertionError:
2022-10-01 17:31:33 Not equal to tolerance rtol=1e-05, atol=1e-05
2022-10-01 17:31:33 Output (Out) has diff at Place(cpu) in static checker
2022-10-01 17:31:33 (shapes (1,), (2, 5, 3, 4, 2) mismatch)
2022-10-01 17:31:33 x: array([False])
2022-10-01 17:31:33 y: array([[[[[False, False],
2022-10-01 17:31:33 [False, False],
2022-10-01 17:31:33 [False, False],...
reduce_all 会使维度为 [1]
Paddle/paddle/phi/infermeta/unary.cc
Lines 2701 to 2722 in 0929bc8
因此这里需要移除 reduce_all 参数(或者设为默认值 False)才能与 NumPy 计算的 expect 一致
|
很抱歉,经过我们的反复讨论,你的PR暂未达到合入标准,请阅读飞桨原生算子开发规范,你可以重新提交新的PR,我们先将此PR关闭,感谢你的贡献。 |
PR types
Others
PR changes
Others
Describe
一些非
self.assertTrue开头的「漏网之鱼」,如self.op_test.assertTrue做 #46686 时发现报错信息非常不友好,因此修一下
emmm,本地单测运行出了点问题,本地不方便调试,之后再说