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

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

FranklandJack commented on code in PR #13920:
URL: https://github.com/apache/tvm/pull/13920#discussion_r1098942435


##########
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:
   Yeah good shout. I've tried to replace some code duplication throughout this file, so let me konw if that's what you had in mind :D 



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