Skip to content
Open
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
10 changes: 4 additions & 6 deletions examples/qualcomm/custom_op/custom_ops_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,13 @@ def annotate_custom(gm: torch.fx.GraphModule) -> None:
This function is specific for custom op.
The source_fn of the rewritten nn module turns out to be "my_ops.mul3.default"
"""
from executorch.backends.qualcomm.quantizer.annotators import (
_is_annotated,
QUANT_ANNOTATION_KEY,
)

from executorch.backends.qualcomm.quantizer.annotators import _is_annotated
from executorch.backends.qualcomm.quantizer.qconfig import (
get_ptq_per_channel_quant_config,
)
from torch.fx import Node
from torchao.quantization.pt2e.quantizer import QuantizationAnnotation
from torchao.quantization.pt2e.quantizer.quantizer import Q_ANNOTATION_KEY

quantization_config = get_ptq_per_channel_quant_config()
for node in gm.graph.nodes:
Expand All @@ -95,7 +92,7 @@ def annotate_custom(gm: torch.fx.GraphModule) -> None:
input_spec = quantization_config.input_activation
input_qspec_map[input_act] = input_spec

node.meta[QUANT_ANNOTATION_KEY] = QuantizationAnnotation(
node.meta[Q_ANNOTATION_KEY] = QuantizationAnnotation(
input_qspec_map=input_qspec_map,
output_qspec=quantization_config.output_activation,
_annotated=True,
Expand Down Expand Up @@ -235,6 +232,7 @@ def main(args):
f"--output_folder_path {output_data_folder}",
]
)

subprocess.run(
runner_cmd,
# stdout=subprocess.PIPE,
Expand Down
Loading