You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/11/18 11:16:07 UTC

[GitHub] [tvm] ashutosh-arm commented on a change in pull request #9409: [5/10] Code generation for Depthwise Convolution via CMSIS-NN

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



##########
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:
       Not really, will move it inside.




-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org