From f06693eaa898277032c2a7286db655434d55153b Mon Sep 17 00:00:00 2001 From: Josh Fromm Date: Mon, 13 May 2019 16:00:41 -0700 Subject: [PATCH] Added a check for viable quantization layers to annotation. --- 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 9bf546fcdadfc..2f79d7110ab6d 100644 --- a/python/tvm/relay/quantize/_annotate.py +++ b/python/tvm/relay/quantize/_annotate.py @@ -163,6 +163,11 @@ def conv2d_rewrite(ref_call, new_args, ctx): _set_conv_counter(cnt + 1) return None + # Check if the kernel is suitable for quantization, post warning if not. + in_channels = new_args[1].data.shape[1] + if in_channels % 4 != 0: + print("Conv layer %d may not be suitable for quantization. Consider leaving it FP." %cnt) + _set_conv_counter(cnt + 1) lhs_expr, lhs_kind = _get_expr_kind(new_args[0])