zhaoyang-star commented on code in PR #12116: URL: https://github.com/apache/tvm/pull/12116#discussion_r925321487
########## src/relay/qnn/op/leaky_relu.cc: ########## @@ -82,42 +87,62 @@ Expr QnnLeakyReluCanonicalize(const Attrs& attrs, const Array<Expr>& new_args, // by a small alpha value < 1. // // We assume the same scale and zero point for alpha and the input tensor. - // Let T = s(q_t - z) where q_t is the input arg[0] - // Then, the quantized value of alpha * T is: - // q(a * T, s, z) = [(a * T) / s] + z = a * s(q_t - z) / s + z = a * (q_t - z) + z - // = a * q_t + (1 - a) * z + // LeakyReLU can be written in terms of respective quantized tensors, scales and + // zero points as // - // We return the quantized value of alpha * T for all values q_t < input_zero_point. - - ICHECK_EQ(new_args.size(), 3); - Expr quantized_data = Cast(new_args[0], DataType::Int(32)); + // scale_o * (Q_o - zp_o) = alpha * scale_i * (Q_i - zp_i) when Q_i < zp_i (1) + // Q_o = Q_i when Q_i >= zp_i (2) Review Comment: Yes, I misunderstood it when `Q_i >= zp_i`. Have fixed equation (2) . -- 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]
