Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
enhance int8 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xinyu-intel committed Nov 25, 2019
1 parent 11edb70 commit 0bd5d15
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions tests/python/quantization/test_quantization.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,8 @@ def check_quantized_conv(data_shape, kernel, num_filter, pad, stride, no_bias, q
if no_bias:
assert_almost_equal(output.asnumpy(), qoutput.asnumpy(), atol = 1)
else:
# with adding bias, accuracy loss should not be greater than one
diff = mx.nd.abs(output - qoutput.astype(output.dtype))
cond = mx.nd.lesser(2, diff).sum().asscalar()
assert cond == 0
# with adding bias, accuracy loss should not be greater than two
assert_almost_equal(output.asnumpy(), qoutput.astype(output.dtype).asnumpy(), atol = 2)

for qdtype in ['int8', 'uint8']:
check_quantized_conv((3, 4, 28, 28), (3, 3), 128, (1, 1), (1, 1), True, qdtype)
Expand Down Expand Up @@ -496,10 +494,8 @@ def maxabs(a, b):
if no_bias:
assert_almost_equal(output.asnumpy(), qoutput.asnumpy())
else:
# with adding bias, accuracy loss should not be greater than one
diff = mx.nd.abs(output - qoutput.astype(output.dtype))
cond = mx.nd.lesser(2, diff).sum().asscalar()
assert cond == 0
# with adding bias, accuracy loss should not be greater than two
assert_almost_equal(output.asnumpy(), qoutput.astype(output.dtype).asnumpy(), atol = 2)

for qdtype in ['int8', 'uint8']:
if is_test_for_mkldnn():
Expand Down

0 comments on commit 0bd5d15

Please sign in to comment.