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 10:13:31 UTC
[GitHub] [tvm] manupa-arm commented on a change in pull request #9409: [5/10] Code generation for Depthwise Convolution via CMSIS-NN
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))])
-@pytest.mark.parametrize("enable_bias", [True, False])
@pytest.mark.parametrize("relu_type", ["NONE", "RELU"])
+@pytest.mark.parametrize(
+ "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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org