[Quantization][RELAY] Add check against NCHWc ops in the quantization pass (#2646)
authoreqy <eqy@cs.washington.edu>
Fri, 22 Feb 2019 06:29:52 +0000 (22:29 -0800)
committerziheng <ziheng@apache.org>
Fri, 22 Feb 2019 06:29:52 +0000 (22:29 -0800)
* check in

* fix typo

* fix typo

* change message

* change message

* typo

* lint

python/tvm/relay/quantize/_annotate.py

index 7eb8af57a70b6954bc5580c1e1a40d4052071e7c..912aa9a0a23c2247a5720f63e3dc912dfadce241 100644 (file)
@@ -1,6 +1,7 @@
 #pylint: disable=unused-argument
 """Internal module for registering attribute for annotation."""
 from __future__ import absolute_import
+import warnings
 
 import topi
 from . import _quantize
@@ -118,6 +119,14 @@ def attach_simulated_quantize(data, kind, sign=True, rounding="round"):
         data, dom_scale, clip_min, clip_max, kind, sign, rounding)
 
 
+@register_annotate_function("nn.contrib_conv2d_NCHWc")
+def conv2d_nchwc_rewrite(ref_call, new_args, ctx):
+    warnings.warn("NCHWc layout Conv2D detected, please use a lower "
+                  "optimization level before applying the quantization "
+                  "pass as quantization will have no effect here...")
+    return None
+
+
 @register_annotate_function("nn.conv2d")
 def conv2d_rewrite(ref_call, new_args, ctx):
     """Rewrite function for conv2d. Lhs of conv will be quantized to