You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "ashutosh-arm (via GitHub)" <gi...@apache.org> on 2023/02/06 17:18:26 UTC

[GitHub] [tvm] ashutosh-arm commented on a diff in pull request #13920: Add CMSIS-NN int16 add and mul operator support

ashutosh-arm commented on code in PR #13920:
URL: https://github.com/apache/tvm/pull/13920#discussion_r1097680531


##########
src/relay/backend/contrib/cmsisnn/relay_to_tir.cc:
##########
@@ -587,10 +587,11 @@ class RelayToTIRVisitor : public MixedModeMutator {
   }
 
   void EmitMul(const GlobalVar& global_var, const Expr& expr) {
-    int32_t output_min = std::numeric_limits<int8_t>::min();
-    int32_t output_max = std::numeric_limits<int8_t>::max();
     const auto& pattern = ParseBinaryElementwiseOpClipPattern(expr);
     Call mul_call = pattern.binary_op;
+    const auto bit_width = mul_call->type_as<TensorTypeNode>()->dtype.bits();
+    int32_t output_min = -(1 << (bit_width - 1));
+    int32_t output_max = (1 << (bit_width - 1)) - 1;

Review Comment:
   nit: Can we save`std::numeric_limits()` as part of the class and use it where needed? Looks more standard than bit based calculations.



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