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

[MKLDNN] fix int8 elemwise add ut #17166

Merged
merged 2 commits into from
Dec 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions tests/python/quantization/test_quantization.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,11 @@ def check_quantized_elemwise_add(data_shape, qtype):
elemwise_add_int8_exe.arg_dict[qarg_names[4]][:] = data_low
elemwise_add_int8_exe.arg_dict[qarg_names[5]][:] = data_high
qoutput, min_range, max_range = elemwise_add_int8_exe.forward()
min_val = min_range.asnumpy().tolist()[0]
max_val = max_range.asnumpy().tolist()[0]

fp32_rslt = output.asnumpy()
int8_rslt = qoutput.asnumpy()*max_val/0x7fffffff
assert_almost_equal(int8_rslt, int8_rslt, atol = 1e-4)
int8_rslt = qoutput.astype(output.dtype)*max_range/0x7fffffff
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How this factor works for both INT32 and INT8output?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test only covers int32 output.

diff = mx.nd.abs(output - int8_rslt)
cond = mx.nd.lesser(2, diff).sum().asscalar()
assert cond == 0

for qtype in ['int8', 'uint8']:
check_quantized_elemwise_add((4, 6), qtype)
Expand Down