Skip to content
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

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

Open
gunjannandy opened this issue Sep 14, 2019 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@gunjannandy
Copy link
Contributor

gunjannandy commented Sep 14, 2019

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 gunjannandy added the bug Something isn't working label Sep 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants