lhutton1 commented on code in PR #12950:
URL: https://github.com/apache/tvm/pull/12950#discussion_r984410551


##########
src/relay/backend/contrib/cmsisnn/relay_to_tir.cc:
##########
@@ -133,6 +133,22 @@ class RelayToTIRVisitor : public MixedModeMutator {
     } else {
       conv2d_call = requantize_input;
     }
+    int32_t dtype_bits = 
conv2d_call->args[0]->type_as<TensorTypeNode>()->dtype.bits();
+
+    // Determine bitwidth of buffers based on input dtype
+    int32_t input_bits = 8;
+    int32_t filter_bits = 8;
+    int32_t bias_bits = 32;
+    int32_t output_bits = 8;
+    int32_t context_buffer_bits = 8;
+    bool is_int16 = false;
+    if (dtype_bits == 16) {
+      is_int16 = true;
+      input_bits = 16;
+      bias_bits = 64;
+      output_bits = 16;
+      context_buffer_bits = 16;
+    }

Review Comment:
   Might be a good idea to produce an error if say `dtype_bits=32`?



##########
python/tvm/relay/op/contrib/cmsisnn.py:
##########
@@ -145,12 +143,29 @@ def check_qnn_conv2d(pattern):
         ):
             is_depthwise = True
 
+        # check if dtypes are supported for the following entities
+        # (input_dtype, weight_dtype, bias_dtype, out_dtype, pattern_dtype)
+        are_dtypes_valid = False
+        if bias_add:
+            bias_dtype = bias_add.args[1].checked_type.dtype
+        else:
+            bias_dtype = "int32" if conv2d_input.checked_type.dtype == "int8" 
else "int64"
+        valid_dtypes = None
+        if conv2d_input.checked_type.dtype == "int8":
+            valid_dtypes = ("int8", "int8", "int32", "int32", "int8")
+        elif conv2d_input.checked_type.dtype == "int16":
+            valid_dtypes = ("int16", "int8", "int64", "int64", "int16")
+        if (
+            conv2d_input.checked_type.dtype,

Review Comment:
   nit: since its used a few times, probably worth making it a variable?



##########
tests/python/contrib/test_cmsisnn/test_conv2d.py:
##########
@@ -249,23 +256,25 @@ def test_conv2d_symmetric_padding_int8(
     kernel_size = (3, 3)
     strides = (1, 1)
     dilation = (1, 1)
-    dtype = "int8"
     groups = 1
-    weight_format = "HWIO"
+    input_zero_point = input_zero_point if dtype == "int8" else 0

Review Comment:
   Curious, why is this needed?



##########
tests/python/contrib/test_cmsisnn/test_conv2d.py:
##########
@@ -915,13 +943,15 @@ def test_relay_conv2d_cmsisnn_depthwise_int8(
 
 def parameterize_for_invalid_model(test):
     """Generates non int8 inputs"""

Review Comment:
   nit: update docstring



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to