Skip to content

Commit e845de7

Browse files
JacobSzwejbkafacebook-github-bot
authored andcommitted
delete exir.capture from some more places
Summary: a bunch of misc places using exir.capture that shouldnt be anymore. Differential Revision: D55766467
1 parent 88b6cd2 commit e845de7

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

exir/tests/test_quantization.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
import torch
1212
import torchvision
13-
from executorch import exir
14-
from executorch.exir import EdgeCompileConfig
13+
from executorch.exir import EdgeCompileConfig, to_edge
1514
from executorch.exir.passes.quant_fusion_pass import QuantFusionPass
1615
from executorch.exir.passes.spec_prop_pass import SpecPropPass
1716
from torch.ao.ns.fx.utils import compute_sqnr
@@ -29,6 +28,7 @@
2928
get_symmetric_quantization_config,
3029
XNNPACKQuantizer,
3130
)
31+
from torch.export import export
3232
from torch.testing import FileCheck
3333
from torch.testing._internal.common_quantized import override_quantized_engine
3434

@@ -70,19 +70,17 @@ def test_resnet(self) -> None:
7070
compile_config = EdgeCompileConfig(
7171
_check_ir_validity=False,
7272
)
73-
m = (
74-
exir.capture(m, example_inputs)
75-
.to_edge(config=compile_config)
76-
.transform(QuantFusionPass(), SpecPropPass())
77-
)
73+
m = to_edge(
74+
export(m, example_inputs), compile_config=compile_config
75+
).transform([QuantFusionPass(), SpecPropPass()])
7876

79-
after_quant_result = m(*example_inputs)[0]
77+
after_quant_result = m.exported_program().module()(*example_inputs)[0]
8078
FileCheck().check(
8179
"executorch_exir_dialects_edge__ops_quantized_decomposed_quantize_per_tensor"
8280
).check(
8381
"executorch_exir_dialects_edge__ops_quantized_decomposed_dequantize_per_tensor"
8482
).run(
85-
m.exported_program.graph_module.code
83+
m.exported_program().graph_module.code
8684
)
8785
# after_quant_fusion_result = m(*example_inputs)[0]
8886

test/models/generate_linear_out_bundled_program.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import executorch.exir as exir
2020

2121
import torch
22-
from executorch.exir import ExecutorchBackendConfig
22+
from executorch.exir import ExecutorchBackendConfig, to_edge
2323

2424
from executorch.exir.passes import MemoryPlanningPass, ToOutVarPass
2525
from executorch.exir.print_program import pretty_print
@@ -30,6 +30,7 @@
3030
)
3131

3232
from executorch.test.models.linear_model import LinearModel
33+
from torch.export import export
3334

3435

3536
def main() -> None:
@@ -38,21 +39,17 @@ def main() -> None:
3839
trace_inputs = (torch.ones(2, 2, dtype=torch.float),)
3940

4041
# Trace to FX Graph.
41-
exec_prog = (
42-
exir.capture(model, trace_inputs)
43-
.to_edge()
44-
.to_executorch(
45-
config=ExecutorchBackendConfig(
46-
memory_planning_pass=MemoryPlanningPass(),
47-
to_out_var_pass=ToOutVarPass(),
48-
)
42+
exec_prog = to_edge(export(model, trace_inputs)).to_executorch(
43+
config=ExecutorchBackendConfig(
44+
memory_planning_pass=MemoryPlanningPass(),
45+
to_out_var_pass=ToOutVarPass(),
4946
)
5047
)
5148
# Emit in-memory representation.
52-
pretty_print(exec_prog.program)
49+
pretty_print(exec_prog.executorch_program)
5350

5451
# Serialize to flatbuffer.
55-
exec_prog.program.version = 0
52+
exec_prog.executorch_program.version = 0
5653

5754
# Create test sets
5855
method_test_cases: List[MethodTestCase] = []
@@ -66,7 +63,6 @@ def main() -> None:
6663
]
6764

6865
bundled_program = BundledProgram(exec_prog, method_test_suites)
69-
pretty_print(bundled_program)
7066

7167
bundled_program_flatbuffer = serialize_from_bundled_program_to_flatbuffer(
7268
bundled_program
@@ -76,7 +72,7 @@ def main() -> None:
7672
subprocess.run(["hg", "root"], stdout=subprocess.PIPE).stdout.decode().strip()
7773
)
7874
with open(
79-
f"{fbsource_base_path}/fbcode/executorch/test/models/linear_out_bundled_program.pte",
75+
f"{fbsource_base_path}/fbcode/executorch/test/models/linear_out_bundled_program.bpte",
8076
"wb",
8177
) as file:
8278
file.write(bundled_program_flatbuffer)

0 commit comments

Comments
 (0)