jackwish commented on a change in pull request #4629: [QNN] Channel wise 
quantization - Quantize & Requantize
URL: https://github.com/apache/incubator-tvm/pull/4629#discussion_r363581404
 
 

 ##########
 File path: src/relay/qnn/util.h
 ##########
 @@ -124,6 +125,33 @@ static inline int64_t get_const_int(const tvm::Expr& x) {
 Expr FixedPointMultiply(Expr tensor, double multiplier, const 
Array<IndexExpr>& input_shape,
                         const std::string& rounding);
 
+/*
+ * \brief Fixed point multiplication between integer tensor with floating point
+ scalar where the input tensor is per-axis/per-channel quantized..
+ * \param tensor The quantized input tensor of dtype int64.
+ * \param multiplier The scalar multiplier.
+ * \param input_shape Shape of the input tensor.
+ * \param axis The axis along which the input tensor is quantized. Default 
value is -1 which
+ corresponds to the last axis.
+ * \param rounding "UPWARD" or "TONEAREST". The rounding direction when the 
value
+ is midway between" "two representable values.
+ * \return The sequence of Relay ops for fixed point multiplication.
+
+ * \note Original compuation is scale_fp32 * quantized_tensor.  To convert into
+ *       integer computation, the multiplication with fp32 vector can be
+ *       replaced by multiplication with an int vector and then right shifting
+ *       the result. This approximates the floating point computation with a
+ *       fixed point computation.
+ *
+ *       Computation of fixed point multiplication is consist of following
+ steps:
+ *       1) Multiply the fixed point multiplier with quantized tensor.
+ *       2) Round the result.
+ *       3) Right shift the result
+ */
+Expr FixedPointMultiplyPerChannel(Expr tensor, std::vector<double> multiplier,
 
 Review comment:
   Naming things... If we are using this name, maybe name `axis` to be 
`channel_axis`? Otherwise, maybe we can remove `channel` semantic from the 
naming.

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


With regards,
Apache Git Services

Reply via email to