Skip to content

Commit 16a1555

Browse files
committed
update unit tests
1 parent ffb5c63 commit 16a1555

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

tests/test_backend.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3357,16 +3357,25 @@ def func(base_matrix, diag, k):
33573357
@check_opset_min_version(10)
33583358
@check_tf_min_version("1.14")
33593359
def test_fakequant_with_min_max(self):
3360-
x_val = np.random.random(size=[3, 3]).astype(np.float32) * 2048. - 1024.
33613360
def func(x):
33623361
ret = fake_quant_with_min_max_args(
33633362
x, min=-1024, max=1024, num_bits=8, narrow_range=False, name=None)
33643363
return tf.identity(ret, name=_TFOUTPUT)
3364+
3365+
x_val = np.random.random(size=[4, 3]).astype(np.float32) * 2048. - 1024.
3366+
x_val0 = np.abs(x_val)
3367+
self._run_test_case(func, [_OUTPUT], {_INPUT: x_val0})
33653368
self._run_test_case(func, [_OUTPUT], {_INPUT: x_val})
33663369

33673370

33683371
if __name__ == '__main__':
3369-
# cl = BackendTests()
3370-
# cl.setUp()
3371-
# cl.test_fakequant_with_min_max()
3372+
#cl = BackendTests()
3373+
#cl.setUp()
3374+
#cl.test_fakequant_with_min_max()
3375+
#import cProfile
3376+
#cProfile.run('unittest_main()', 'restats')
33723377
unittest_main()
3378+
#import pstats
3379+
#from pstats import SortKey
3380+
#p = pstats.Stats('restats')
3381+
#p.sort_stats(SortKey.CUMULATIVE).print_stats()

tf2onnx/onnx_opset/quantize.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ def version_11(cls, ctx, node, **kwargs):
4444
"Unable to convert node FakeQuantWithMinMaxArgs with "
4545
"num_bits=%r" % num_bits)
4646

47-
scale = (amax - amin) / (2 ** num_bits - 1)
48-
min_adj = scale * int(amin / scale)
49-
max_adj = amax + min_adj - amin
5047
if 0 < amin < amax:
5148
min_adj = 0
5249
max_adj = amax - amin

0 commit comments

Comments
 (0)