d-smirnov commented on a change in pull request #7206:
URL: https://github.com/apache/tvm/pull/7206#discussion_r553995726



##########
File path: python/tvm/relay/op/contrib/arm_compute_lib.py
##########
@@ -19,12 +19,15 @@
 import numpy as np
 import tvm
 
+import tvm._ffi

Review comment:
       Done

##########
File path: python/tvm/relay/op/contrib/arm_compute_lib.py
##########
@@ -71,6 +74,61 @@ def partition_for_arm_compute_lib(mod, params=None):
     return seq(mod)
 
 
+@tvm._ffi.register_func("relay.ext.arm_compute_lib.optimize")

Review comment:
       Done

##########
File path: python/tvm/relay/op/contrib/arm_compute_lib.py
##########
@@ -71,6 +74,61 @@ def partition_for_arm_compute_lib(mod, params=None):
     return seq(mod)
 
 
+@tvm._ffi.register_func("relay.ext.arm_compute_lib.optimize")
+def preprocess_module(mod):
+    """
+        Pre-process a module containing functions ready for ACL codegen. For 
now we enforce OHWI
+        kernel layout and fold the transforms away.
+
+    `   Parameters

Review comment:
       Done

##########
File path: src/relay/backend/contrib/arm_compute_lib/codegen.cc
##########
@@ -126,7 +127,7 @@ class ACLJSONSerializer : public 
backend::contrib::JSONSerializer {
       nodes.activation = current_call;
       current_call = current_call->args[0].as<CallNode>();
     }
-    if (backend::IsOp(current_call, "nn.bias_add")) {
+    if (backend::IsOp(current_call, "add")) {

Review comment:
       It will be "lowered" (not sure I am using correct terminology) to add on 
time when the runtime is invoked

##########
File path: src/runtime/contrib/arm_compute_lib/acl_runtime.cc
##########
@@ -269,6 +268,64 @@ class ACLRuntime : public JSONRuntimeBase {
     layer->function = function;
   }
 
+  /*!
+   * \brief Create a 2D depthwise convolution layer.
+   *
+   * \param layer The ACL layer to build. Containing inputs, outputs and the 
ACL function.
+   * \param node The JSON representation of the operator.
+   * \param mm The ACL conv2d layer can request auxiliary memory from TVM.
+   */
+  void CreateDepthwiseConvolution2DLayer(
+      CachedLayer* layer, const JSONGraphNode& node,
+      const std::shared_ptr<arm_compute::MemoryManagerOnDemand>& mm) {
+    std::vector<std::string> padding = 
node.GetAttr<std::vector<std::string>>("padding");
+    std::vector<std::string> strides = 
node.GetAttr<std::vector<std::string>>("strides");
+    std::vector<std::string> dilation = 
node.GetAttr<std::vector<std::string>>("dilation");
+    arm_compute::PadStrideInfo pad_stride_info = MakeACLPadStride(padding, 
strides);
+
+    arm_compute::ActivationLayerInfo act_info;
+    if (node.HasAttr("activation_type")) {
+      std::string activation_type = 
node.GetAttr<std::vector<std::string>>("activation_type")[0];
+      act_info = MakeACLActivationInfo(activation_type);
+    }
+
+    arm_compute::Size2D dilation_2d(std::stoi(dilation[0]), 
std::stoi(dilation[1]));
+
+    // Collect inputs and outputs, handling both nn.conv2d and qnn.conv2d 
cases.
+    std::vector<JSONGraphNodeEntry> inputs = node.GetInputs();
+    size_t num_inputs = inputs.size();
+    bool has_bias;
+    if (node.GetOpName() == "qnn.depthwise_conv2d") {
+      CHECK(num_inputs >= 8U && num_inputs <= 9U)
+          << "Quantized convolution requires 9 inputs with a bias, 8 inputs 
without.";
+      has_bias = num_inputs == 9;
+      layer->inputs.push_back(MakeACLTensorFromJSONEntry(inputs[0], 
&inputs[4], &inputs[2]));
+      layer->inputs.push_back(MakeACLTensorFromJSONEntry(inputs[1], 
&inputs[5], &inputs[3]));
+      if (has_bias) {
+        layer->inputs.push_back(MakeACLTensorFromJSONEntry(inputs[6]));
+      }
+      layer->outputs.push_back(
+          MakeACLTensorFromJSONNode(node, &inputs[6 + has_bias], &inputs[7 + 
has_bias]));
+    } else {
+      CHECK(num_inputs >= 2U && num_inputs <= 3U)

Review comment:
       Yes it should. Thank you.

##########
File path: src/runtime/contrib/arm_compute_lib/acl_runtime.cc
##########
@@ -269,6 +268,64 @@ class ACLRuntime : public JSONRuntimeBase {
     layer->function = function;
   }
 
+  /*!
+   * \brief Create a 2D depthwise convolution layer.
+   *
+   * \param layer The ACL layer to build. Containing inputs, outputs and the 
ACL function.
+   * \param node The JSON representation of the operator.
+   * \param mm The ACL conv2d layer can request auxiliary memory from TVM.
+   */
+  void CreateDepthwiseConvolution2DLayer(
+      CachedLayer* layer, const JSONGraphNode& node,
+      const std::shared_ptr<arm_compute::MemoryManagerOnDemand>& mm) {
+    std::vector<std::string> padding = 
node.GetAttr<std::vector<std::string>>("padding");
+    std::vector<std::string> strides = 
node.GetAttr<std::vector<std::string>>("strides");
+    std::vector<std::string> dilation = 
node.GetAttr<std::vector<std::string>>("dilation");
+    arm_compute::PadStrideInfo pad_stride_info = MakeACLPadStride(padding, 
strides);
+
+    arm_compute::ActivationLayerInfo act_info;
+    if (node.HasAttr("activation_type")) {
+      std::string activation_type = 
node.GetAttr<std::vector<std::string>>("activation_type")[0];
+      act_info = MakeACLActivationInfo(activation_type);
+    }
+
+    arm_compute::Size2D dilation_2d(std::stoi(dilation[0]), 
std::stoi(dilation[1]));
+
+    // Collect inputs and outputs, handling both nn.conv2d and qnn.conv2d 
cases.
+    std::vector<JSONGraphNodeEntry> inputs = node.GetInputs();
+    size_t num_inputs = inputs.size();
+    bool has_bias;
+    if (node.GetOpName() == "qnn.depthwise_conv2d") {
+      CHECK(num_inputs >= 8U && num_inputs <= 9U)

Review comment:
       Yes it should. Thank you.




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

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


Reply via email to