未验证 提交 570b7389 编写于 作者: M Michał Gallus 提交者: GitHub

Fix OpTester from incorrectly converting uint8 data to utf-8 string (#24854)

test=develop
上级 2ca2b90d
...@@ -308,7 +308,6 @@ class OpTest(unittest.TestCase): ...@@ -308,7 +308,6 @@ class OpTest(unittest.TestCase):
else: else:
tensor.set(self.inputs[var_name], place) tensor.set(self.inputs[var_name], place)
feed_map[var_name] = tensor feed_map[var_name] = tensor
return feed_map return feed_map
def _append_ops(self, block): def _append_ops(self, block):
...@@ -630,24 +629,23 @@ class OpTest(unittest.TestCase): ...@@ -630,24 +629,23 @@ class OpTest(unittest.TestCase):
# computational consistency. # computational consistency.
# When inplace_atol is not None, the inplace check uses numpy.allclose # When inplace_atol is not None, the inplace check uses numpy.allclose
# to check inplace result instead of numpy.array_equal. # to check inplace result instead of numpy.array_equal.
expect_out = np.array(expect_outs[i])
actual_out = np.array(actual_outs[i])
if inplace_atol is not None: if inplace_atol is not None:
self.assertTrue( self.assertTrue(
np.allclose( np.allclose(
np.array(expect_outs[i]), expect_out, actual_out, atol=inplace_atol),
np.array(actual_outs[i]),
atol=inplace_atol),
"Output (" + name + ") has diff at " + str(place) + "Output (" + name + ") has diff at " + str(place) +
" when using and not using inplace" + "\nExpect " + " when using and not using inplace" + "\nExpect " +
str(expect_outs[i]) + "\n" + "But Got" + str(actual_outs[i]) str(expect_out) + "\n" + "But Got" + str(actual_out) +
+ " in class " + self.__class__.__name__) " in class " + self.__class__.__name__)
else: else:
self.assertTrue( self.assertTrue(
np.array_equal( np.array_equal(expect_out, actual_out),
np.array(expect_outs[i]), np.array(actual_outs[i])),
"Output (" + name + ") has diff at " + str(place) + "Output (" + name + ") has diff at " + str(place) +
" when using and not using inplace" + "\nExpect " + " when using and not using inplace" + "\nExpect " +
str(expect_outs[i]) + "\n" + "But Got" + str(actual_outs[i]) str(expect_out) + "\n" + "But Got" + str(actual_out) +
+ " in class " + self.__class__.__name__ + '\n') " in class " + self.__class__.__name__ + '\n')
def _construct_grad_program_from_forward(self, fwd_program, grad_op_desc, def _construct_grad_program_from_forward(self, fwd_program, grad_op_desc,
op_grad_to_var): op_grad_to_var):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册