lhutton1 commented on code in PR #12887:
URL: https://github.com/apache/tvm/pull/12887#discussion_r981032909


##########
src/relay/backend/contrib/ethosn/convert_equivalent.cc:
##########
@@ -39,100 +39,117 @@ namespace relay {
 namespace contrib {
 namespace ethosn {
 
+/*!
+ * \brief Helper class to extract inputs and quantization information from 
binary
+ * elementwise operations ready to convert.
+ */
+class BinaryElementwiseParams {
+ public:
+  static BinaryElementwiseParams ExtractBinaryElementwiseParams(const Call& 
call) {
+    auto params = BinaryElementwiseParams();
+    params.input1 = call->args[0];
+    params.input2 = call->args[1];
+    params.input1_scale = call->args[2];
+    params.input1_zero_point = call->args[3];
+    params.input2_scale = call->args[4];
+    params.input2_zero_point = call->args[5];
+    // Reverse the inputs if the constant is first input
+    if (call->args[0]->IsInstance<ConstantNode>()) {
+      params.input1 = call->args[1];
+      params.input2 = call->args[0];
+      params.input1_scale = call->args[4];
+      params.input1_zero_point = call->args[5];
+      params.input2_scale = call->args[2];
+      params.input2_zero_point = call->args[3];
+    }
+    params.output_scale = call->args[6];
+    params.output_zero_point = call->args[7];
+    return params;
+  }
+
+  Expr input1;
+  Expr input2;
+  Expr input1_scale;
+  Expr input1_zero_point;
+  Expr input2_scale;
+  Expr input2_zero_point;
+  Expr output_scale;
+  Expr output_zero_point;

Review Comment:
   Ah, this isn't actually necessary, the quantization params are not cast to 
Constants at any point - either the value they hold is retrieved from them, or 
they are passed when creating a new operator which expects Expr anyway.



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