Skip to content

Tie quantization of add operands and result together #3091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions backends/arm/arm_quantizer_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,11 +780,11 @@ def _annotate_add(
if _is_annotated([add_node]):
continue

input_act0 = add_node.args[0]
input_act_qspec = get_input_act_qspec(quantization_config)
output_act_qspec = get_output_act_qspec(quantization_config)
shared_with_input0_qspec = SharedQuantizationSpec((input_act0, add_node))

input_qspec_map = {}
input_act0 = add_node.args[0]
if isinstance(input_act0, Node):
if _is_input_large_scalar(input_act0, gm):
continue
Expand All @@ -798,11 +798,14 @@ def _annotate_add(
continue
if _is_input_non_float_tensor(input_act1):
continue
input_qspec_map[input_act1] = input_act_qspec
if input_act0 is not input_act1:
input_qspec_map[input_act1] = shared_with_input0_qspec
else:
input_qspec_map[input_act1] = input_act_qspec

add_node.meta["quantization_annotation"] = QuantizationAnnotation(
input_qspec_map=input_qspec_map,
output_qspec=output_act_qspec,
output_qspec=shared_with_input0_qspec,
_annotated=True,
)
return annotated_partitions
Expand Down
2 changes: 1 addition & 1 deletion examples/arm/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ function setup_vela() {
if [[ ! -e ethos-u-vela ]]; then
git clone https://review.mlplatform.org/ml/ethos-u/ethos-u-vela
repo_dir="${root_dir}/ethos-u-vela"
base_rev=b90666d9b43f4b5223bb4dcecdbee87b2ad757c2
base_rev=92240e7979018a197b42aab2da16dc002d86f224
patch_repo
fi
cd "${root_dir}/ethos-u-vela"
Expand Down