huajsj commented on code in PR #11431:
URL: https://github.com/apache/tvm/pull/11431#discussion_r881008635


##########
src/relay/backend/contrib/cmsisnn/relay_to_tir.cc:
##########
@@ -757,7 +778,10 @@ class RelayToTIRVisitor : public MixedModeMutator {
   static constexpr int32_t kScaledDiffIntegerBits = 5;
   static constexpr int32_t kInputBits = 5;
   static constexpr double kBeta = 1.0;
+  /*! \brief Unique id for context buffer needed by CMSIS-NN layers. */
   int32_t context_buffer_id_;
+  /*! \brief Skip arguments in the call to global partitioned function. */
+  std::list<int32_t> skip_call_args_;

Review Comment:
   list find complexity is O(n), unordered_set should be a better replacement.



##########
src/relay/backend/contrib/cmsisnn/relay_to_tir.cc:
##########
@@ -742,11 +748,26 @@ class RelayToTIRVisitor : public MixedModeMutator {
                                                GetRef<Function>(func));
         }
 
+        // Drop out the redundant arguments and their arg_types from the call 
to the global
+        // partitioned function.
         Array<Expr> args;
+        Array<Type> arg_types;
+        auto* func_type = new_global_var->checked_type_.as<FuncTypeNode>();
+        int arg_id = -1;
         for (const auto& arg : call->args) {
+          ++arg_id;
+          if (std::find(skip_call_args_.begin(), skip_call_args_.end(), 
arg_id) !=
+              skip_call_args_.end()) {
+            continue;
+          }
           args.push_back(VisitExpr(arg));
+          arg_types.push_back(func_type->arg_types[arg_id]);
         }
-
+        if (!skip_call_args_.empty()) {

Review Comment:
   "if (arg_types.size() != func_type->arg_types.size()) " ?



##########
src/relay/backend/contrib/cmsisnn/relay_to_tir.cc:
##########
@@ -141,18 +141,24 @@ class RelayToTIRVisitor : public MixedModeMutator {
     // %3 = qnn.requantize(%2, %input_scale_const_4, %cmsisnn_shift_const_5,
     //                     %output_scale_scalar, %output_zero_point_scalar)
     // clip(%3, a_min=%min_scalar, a_max=%max_scalar)
+    int filter_scale_pos = 3;

Review Comment:
   const int filter_scale_pos = 3.



##########
src/relay/backend/contrib/cmsisnn/relay_to_tir.cc:
##########
@@ -141,18 +141,24 @@ class RelayToTIRVisitor : public MixedModeMutator {
     // %3 = qnn.requantize(%2, %input_scale_const_4, %cmsisnn_shift_const_5,
     //                     %output_scale_scalar, %output_zero_point_scalar)
     // clip(%3, a_min=%min_scalar, a_max=%max_scalar)
+    int filter_scale_pos = 3;
+    int input_scale_pos = 4;

Review Comment:
   comments what is 3,4 



##########
src/relay/backend/contrib/cmsisnn/relay_to_tir.cc:
##########
@@ -742,11 +748,26 @@ class RelayToTIRVisitor : public MixedModeMutator {
                                                GetRef<Function>(func));
         }
 
+        // Drop out the redundant arguments and their arg_types from the call 
to the global
+        // partitioned function.

Review Comment:
   Drop out the redundant arguments, and the arg_types from the global 
partitioned function call



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