manupa-arm commented on a change in pull request #9409:
URL: https://github.com/apache/tvm/pull/9409#discussion_r752091426



##########
File path: tests/python/contrib/test_cmsisnn/test_conv2d.py
##########
@@ -129,8 +128,11 @@ def make_model(
 @pytest.mark.parametrize("kernel_size", [(3, 3)])
 @pytest.mark.parametrize("padding", ["SAME", "VALID"])
 @pytest.mark.parametrize("strides, dilation", [((2, 2), (1, 1)), ((1, 1), (1, 
1))])
[email protected]("enable_bias", [True, False])
 @pytest.mark.parametrize("relu_type", ["NONE", "RELU"])
[email protected](
+    "conv_type, depth_multiplier, enable_bias",
+    [("conv2d", 1, True), ("conv2d", 1, False), ("depthwise", 1, True), 
("depthwise", 3, True)],

Review comment:
       Do we need to run all the tests again for a different depth_multiplier ? 

##########
File path: src/relay/backend/contrib/cmsisnn/generate_constants.cc
##########
@@ -105,11 +105,25 @@ class GenerateConstantsMutator : public MixedModeMutator {
       conv2d_call = requantize_input;
     }
 
-    // Transpose weights: HWIO -> OHWI
     auto* conv2d_attrs = conv2d_call->attrs.as<Conv2DAttrs>();
-    tvm::Attrs new_conv2d_attrs;
-    Expr transposed_kernel =
-        ConvertKernelLayout(conv2d_call->args[1], conv2d_attrs, 
&new_conv2d_attrs);
+    tvm::Attrs new_conv2d_attrs = conv2d_call->attrs;
+    Expr conv2d_kernel = conv2d_call->args[1];
+
+    bool is_depthwise = false;
+    Array<PrimExpr> input_shape = 
conv2d_call->args[0]->type_as<TensorTypeNode>()->shape;
+    Array<PrimExpr> kernel_shape = 
conv2d_call->args[1]->type_as<TensorTypeNode>()->shape;
+    std::string kernel_layout = conv2d_attrs->kernel_layout.c_str();
+    int kernel_pos_o = kernel_layout.find("O");
+    int groups = conv2d_attrs->groups;
+    if (groups == qnn::get_const_int(input_shape[3]) &&
+        groups == qnn::get_const_int(kernel_shape[kernel_pos_o])) {
+      is_depthwise = true;
+    }
+
+    // Transpose weights: HWIO -> OHWI for Conv2D
+    if (!is_depthwise) {

Review comment:
       nit: do we need this seperated out ?  - as opposed to being inside the 
if above




-- 
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