Skip to content
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
8 changes: 2 additions & 6 deletions backends/arm/test/misc/test_extract_io_params_tosa.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,12 @@ def test_roundtrip_extracts_io_params(builder_method, quantizer_cls, partitioner
operator_config = get_symmetric_quantization_config(is_qat=True)
quantizer.set_global(operator_config)

exported = torch.export.export_for_training(
mod, copy.deepcopy(example_inputs), strict=True
)
exported = torch.export.export(mod, copy.deepcopy(example_inputs), strict=True)
prepared = prepare_pt2e(exported.module(), quantizer)
_ = prepared(*example_inputs)

converted = convert_pt2e(prepared)
final_export = torch.export.export_for_training(
converted, example_inputs, strict=True
)
final_export = torch.export.export(converted, example_inputs, strict=True)
partitioner = partitioner_cls(compile_spec)
edge_prog = to_edge_transform_and_lower(final_export, partitioner=[partitioner])

Expand Down
7 changes: 3 additions & 4 deletions backends/cortex_m/test/test_replace_quant_nodes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# Copyright 2025 Arm Limited and/or its affiliates.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
Expand All @@ -16,7 +17,7 @@
ReplaceQuantNodesPass,
)
from executorch.exir.dialects._ops import ops as exir_ops
from torch.export import export, export_for_training
from torch.export import export
from torch.fx import GraphModule
from torchao.quantization.pt2e.observer import HistogramObserver
from torchao.quantization.pt2e.quantize_pt2e import convert_pt2e, prepare_pt2e
Expand Down Expand Up @@ -125,9 +126,7 @@ def forward(self, x):
example_inputs = (torch.randn(10, 11, 12),)

# Step 1: Export and quantize the model
exported_model = export_for_training(
model.eval(), example_inputs, strict=True
).module()
exported_model = export(model.eval(), example_inputs, strict=True).module()
prepared_model = prepare_pt2e(exported_model, AddQuantizer())
quantized_model = convert_pt2e(prepared_model)

Expand Down
4 changes: 2 additions & 2 deletions docs/source/backends-arm-ethos-u.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ compile_spec = ArmCompileSpecBuilder().ethosu_compile_spec(
).build()

# Post training quantization
graph_module = torch.export.export_for_training(mobilenet_v2, example_inputs).module()
graph_module = torch.export.export(mobilenet_v2, example_inputs).module()
quantizer = EthosUQuantizer(compile_spec)
operator_config = get_symmetric_quantization_config(is_per_channel=False)
quantizer.set_global(operator_config)
graph_module = prepare_pt2e(graph_module, quantizer)
graph_module(*example_inputs)
graph_module = convert_pt2e(graph_module)
exported_program = torch.export.export_for_training(graph_module, example_inputs)
exported_program = torch.export.export(graph_module, example_inputs)

# Lower the exported program to the Ethos-U backend and save pte file.
edge_program_manager = to_edge_transform_and_lower(
Expand Down
6 changes: 3 additions & 3 deletions examples/arm/aot_arm_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ def quantize_model(args, model: torch.nn.Module, example_inputs, compile_spec):
args.evaluate_config,
)
# Wrap quantized model back into an exported_program
exported_program = torch.export.export_for_training(
exported_program = torch.export.export(
model_int8, example_inputs, strict=args.strict_export
)

Expand Down Expand Up @@ -795,9 +795,9 @@ def transform_for_cortex_m_backend(edge):
)
model = original_model.eval()

# export_for_training under the assumption we quantize, the exported form also works
# export under the assumption we quantize, the exported form also works
# in to_edge if we don't quantize
exported_program = torch.export.export_for_training(
exported_program = torch.export.export(
model, example_inputs, strict=args.strict_export
)
model = exported_program.module()
Expand Down
4 changes: 2 additions & 2 deletions examples/arm/ethos_u_minimal_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"\n",
"model = Add()\n",
"model = model.eval()\n",
"exported_program = torch.export.export_for_training(model, example_inputs)\n",
"exported_program = torch.export.export(model, example_inputs)\n",
"graph_module = exported_program.module()\n",
"\n",
"_ = graph_module.print_readable()"
Expand Down Expand Up @@ -112,7 +112,7 @@
"_ = quantized_graph_module.print_readable()\n",
"\n",
"# Create a new exported program using the quantized_graph_module\n",
"quantized_exported_program = torch.export.export_for_training(quantized_graph_module, example_inputs)"
"quantized_exported_program = torch.export.export(quantized_graph_module, example_inputs)"
]
},
{
Expand Down
Loading