From 10f41b2ce03c58bd858a8fa2a45a341768695bf6 Mon Sep 17 00:00:00 2001 From: Wuwei Lin Date: Fri, 15 Mar 2019 01:10:49 +0800 Subject: [PATCH] [Relay][Quantization] Fix duplicated simulated quantization (#2803) --- python/tvm/relay/quantize/_annotate.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python/tvm/relay/quantize/_annotate.py b/python/tvm/relay/quantize/_annotate.py index 5daf10284a9d..c75746812ecc 100644 --- a/python/tvm/relay/quantize/_annotate.py +++ b/python/tvm/relay/quantize/_annotate.py @@ -112,6 +112,11 @@ def attach_simulated_quantize(data, kind, sign=True, rounding="round"): kind: QAnnotateKind the kind of annotation field. """ + quantize_op = _op.get("relay.op.annotation.simulated_quantize") + if isinstance(data, _expr.Call) and data.op == quantize_op: + if data.attrs.kind == kind and data.attrs.sign == sign and data.attrs.rounding == rounding: + return data + dom_scale = _expr.var("dom_scale") clip_min = _expr.var("clip_min") clip_max = _expr.var("clip_max")