Skip to content

Commit b43ae30

Browse files
Matthew BrookhartJosh Fromm
andauthored
Per channel fq2i (#8)
* WIP support per-channel quantization * more WIP * More WIP * fix issue with per-channel bias_add * Fix fake quantize tests (#4) * Fixed fake quantize issues. * Formatting. * Cleanup unused imports * Fix real int8 tests. * Add Relu * One more little one (#5) * Fixed fake quantize issues. * Formatting. * Cleanup unused imports * Fix real int8 tests. * Fix requantize shape bug. * Non-working Per-channel Dense * Fix legalization for non spatial operators. (#6) * Fix legalization for non spatial operators. * Fix axis checks for end2end functionality. * fix axis normalization fix lint fix lint again * Fix bug in requantize dimension expansion. * Format. Co-authored-by: Josh Fromm <jwfromm@octoml.ai>
1 parent c31512d commit b43ae30

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/relay/qnn/op/requantize.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,13 @@ Expr RequantizeLower(const Expr& input_tensor, const Expr& input_scale,
139139
auto zero_scalar = MakeConstantScalar(DataType::Int(32), 0);
140140
if (!IsEqualScalar(input_zero_point, zero_scalar)) {
141141
// Broadcast input zero point if needed.
142+
int rank = static_cast<int>(input_shape.size());
143+
int axis = (param->axis < 0) ? ((rank > 0) ? rank + param->axis : 0) : param->axis;
142144
Expr input_zero_broadcast = ExpandBiasToMatchAxis(Reshape(input_zero_point,
143145
{
144146
-1,
145147
}),
146-
input_shape.size(), {param->axis});
148+
rank, {axis});
147149
tensor = Subtract(tensor, Cast(input_zero_broadcast, DataType::Int(32)));
148150
}
149151

0 commit comments

Comments
 (0)