Skip to content

Rename convert_pt2 #10378

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

Merged
merged 1 commit into from
Apr 24, 2025
Merged
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: 3 additions & 8 deletions backends/cadence/aot/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,7 @@
from .utils import print_ops_info


# Note: this is not meant as a primary API since it can create inconsistencies
# if the quantizer here is different from the quantizer used to convert. It is
# however useful for unit tests to separate the converted model from the fused
# model, to be able to get reference numerics.
# If this does not apply, please use quantize_and_fuse_pt2 instead.
def convert_pt2(
def prepare_and_convert_pt2(
model: torch.nn.Module,
inputs: tuple[object, ...],
quantizer: CadenceQuantizer,
Expand Down Expand Up @@ -150,7 +145,7 @@ def quantize_pt2(
dump_graphs: bool = False,
) -> torch.fx.GraphModule:
"""
Prepare, convert and fuse the model using the given quantizer.
Trace, prepare, convert and fuse the model using the given quantizer.
If calibration data is provided, it will be used to calibrate the model. If
not, the inputs will be used for calibration instead, which is useful for
unit tests but should not be used for end-to-end use cases.
Expand All @@ -164,7 +159,7 @@ def quantize_pt2(
quantizer = CadenceDefaultQuantizer()

# Get converted graph module
converted_gm = convert_pt2(
converted_gm = prepare_and_convert_pt2(
model, inputs, quantizer, calibration_data, dump_graphs=dump_graphs
)

Expand Down
6 changes: 3 additions & 3 deletions backends/cadence/aot/export_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
from typing import Any, Tuple

from executorch.backends.cadence.aot.compiler import (
convert_pt2,
export_to_executorch_gen_etrecord,
fuse_pt2,
prepare_and_convert_pt2,
)

from executorch.backends.cadence.aot.quantizer.quantizer import CadenceDefaultQuantizer
Expand Down Expand Up @@ -49,13 +49,13 @@ def export_model(
quantizer = CadenceDefaultQuantizer()

# Convert the model
converted_model = convert_pt2(model, example_inputs, quantizer)
converted_model = prepare_and_convert_pt2(model, example_inputs, quantizer)

# Get reference outputs from converted model
ref_outputs = converted_model(*example_inputs)

# Quantize the model (note: quantizer needs to be the same as
# the one used in convert_pt2)
# the one used in prepare_and_convert_pt2)
quantized_model = fuse_pt2(converted_model, quantizer)

# Get edge program after Cadence specific passes
Expand Down
Loading