deepC icon indicating copy to clipboard operation
deepC copied to clipboard

Tensor True Div operator output not equal with Numpy (though they are)

Open gunjannandy opened this issue 4 years ago • 0 comments

test / swig / tensorAssignmentOperators.py (Line No. 619, 627, 651)

Here is the snippet of code

# float_tensor /= bool_scalar
  def test_Assignment_True_Div_float_tensor_bool_scalar (self):
    temp_np = self.np_float_0_4.copy()
    temp_np /= True
    temp_dc = self.dc_float_0_4.copy()
    temp_dc /= True
    np.testing.assert_array_equal(temp_np, np.array(temp_dc.data()))

  # float_tensor /= int_scalar (Numpy and Dnnc has same output, but says not equal)
  def test_Assignment_True_Div_float_tensor_int_scalar (self):
    temp_np = self.np_float_0_4.copy()
    temp_np /= 5
    temp_dc = self.dc_float_0_4.copy()
    temp_dc /= 5
    np.testing.assert_array_equal(temp_np, np.array(temp_dc.data()))

  # float_tensor /= float_scalar (Numpy and Dnnc has same output, but says not equal)
  def test_Assignment_True_Div_float_tensor_float_scalar (self):
    temp_np = self.np_float_0_4.copy()
    temp_np /= 5.0
    temp_dc = self.dc_float_0_4.copy()
    temp_dc /= 5.0
    np.testing.assert_array_equal(temp_np, np.array(temp_dc.data()))

  # float_tensor /= float_tensor (Numpy and Dnnc has same output, but says not equal)
  def test_Assignment_True_Div_float_tensor_float_tensor (self):
    temp_np = self.np_float_0_4.copy()
    temp_np /= self.np_float_5_9
    temp_dc = self.dc_float_0_4.copy()
    temp_dc /= self.dc_float_5_9
    np.testing.assert_array_equal(temp_np, np.array(temp_dc.data()))

The tensor<float>/=tensor<bool> works, but tensor<float>/=tensor<int/float/double> doesn't. As output it shows:

gunjan@gunjan-VirtualBox:/Desktop/dnnCompiler/test/swig$ python3 tensorAssignmentOperators.py -v
test_Assignment_True_Div_float_tensor_bool_scalar (__main__.tensorAssignmentOperatorsTest) ... ok
test_Assignment_True_Div_float_tensor_float_scalar (__main__.tensorAssignmentOperatorsTest) ... FAIL
test_Assignment_True_Div_float_tensor_float_tensor (__main__.tensorAssignmentOperatorsTest) ... FAIL
test_Assignment_True_Div_float_tensor_int_scalar (__main__.tensorAssignmentOperatorsTest) ... FAIL

======================================================================
FAIL: test_Assignment_True_Div_float_tensor_float_scalar (__main__.tensorAssignmentOperatorsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tensorAssignmentOperators.py", line 632, in test_Assignment_True_Div_float_tensor_float_scalar
    np.testing.assert_array_equal(temp_np, np.array(temp_dc.data()))
  File "/home/gunjan/.local/lib/python3.6/site-packages/numpy/testing/_private/utils.py", line 913, in assert_array_equal
    verbose=verbose, header='Arrays are not equal')
  File "/home/gunjan/.local/lib/python3.6/site-packages/numpy/testing/_private/utils.py", line 836, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Arrays are not equal

Mismatch: 80%
Max absolute difference: 2.38418579e-08
Max relative difference: nan
 x: array([0. , 0.2, 0.4, 0.6, 0.8])
 y: array([0. , 0.2, 0.4, 0.6, 0.8])

======================================================================
FAIL: test_Assignment_True_Div_float_tensor_float_tensor (__main__.tensorAssignmentOperatorsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tensorAssignmentOperators.py", line 656, in test_Assignment_True_Div_float_tensor_float_tensor
    np.testing.assert_array_equal(temp_np, np.array(temp_dc.data()))
  File "/home/gunjan/.local/lib/python3.6/site-packages/numpy/testing/_private/utils.py", line 913, in assert_array_equal
    verbose=verbose, header='Arrays are not equal')
  File "/home/gunjan/.local/lib/python3.6/site-packages/numpy/testing/_private/utils.py", line 836, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Arrays are not equal

Mismatch: 60%
Max absolute difference: 1.27724239e-08
Max relative difference: nan
 x: array([0.      , 0.166667, 0.285714, 0.375   , 0.444444])
 y: array([0.      , 0.166667, 0.285714, 0.375   , 0.444444])

======================================================================
FAIL: test_Assignment_True_Div_float_tensor_int_scalar (__main__.tensorAssignmentOperatorsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tensorAssignmentOperators.py", line 624, in test_Assignment_True_Div_float_tensor_int_scalar
    np.testing.assert_array_equal(temp_np, np.array(temp_dc.data()))
  File "/home/gunjan/.local/lib/python3.6/site-packages/numpy/testing/_private/utils.py", line 913, in assert_array_equal
    verbose=verbose, header='Arrays are not equal')
  File "/home/gunjan/.local/lib/python3.6/site-packages/numpy/testing/_private/utils.py", line 836, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Arrays are not equal

Mismatch: 80%
Max absolute difference: 2.38418579e-08
Max relative difference: nan
 x: array([0. , 0.2, 0.4, 0.6, 0.8])
 y: array([0. , 0.2, 0.4, 0.6, 0.8])

----------------------------------------------------------------------
Ran 4 tests in 0.052s

FAILED (failures=3)

gunjannandy avatar Sep 14 '19 17:09 gunjannandy