Skip to content

Commit

Permalink
Per channel fq2i (#8)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
Matthew Brookhart and Josh Fromm committed Aug 31, 2021
1 parent c31512d commit b43ae30
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/relay/qnn/op/requantize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,13 @@ Expr RequantizeLower(const Expr& input_tensor, const Expr& input_scale,
auto zero_scalar = MakeConstantScalar(DataType::Int(32), 0);
if (!IsEqualScalar(input_zero_point, zero_scalar)) {
// Broadcast input zero point if needed.
int rank = static_cast<int>(input_shape.size());
int axis = (param->axis < 0) ? ((rank > 0) ? rank + param->axis : 0) : param->axis;
Expr input_zero_broadcast = ExpandBiasToMatchAxis(Reshape(input_zero_point,
{
-1,
}),
input_shape.size(), {param->axis});
rank, {axis});
tensor = Subtract(tensor, Cast(input_zero_broadcast, DataType::Int(32)));
}

Expand Down

0 comments on commit b43ae30

Please sign in to comment.