File tree Expand file tree Collapse file tree 3 files changed +26
-6
lines changed Expand file tree Collapse file tree 3 files changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -196,7 +196,26 @@ def export_to_edge(
196
196
# Export the model and lower it to an EdgeProgramManager (in edge IR), and
197
197
# apply passes specific to Cadence DSP execution. Return both to print the
198
198
# differences.
199
- def export_to_cadence_edge_executorch (
199
+ def export_to_cadence (
200
+ model : torch .nn .Module ,
201
+ inputs : tuple [object , ...],
202
+ dump_graphs : bool = False ,
203
+ output_dir : Optional [str ] = None ,
204
+ opt_level : int = 1 ,
205
+ ) -> EdgeProgramManager :
206
+ edge_prog_manager = export_to_edge (model , inputs )
207
+ cadence_passes = get_cadence_passes (opt_level )
208
+
209
+ # Run a couple required passes for quant/dequant ops
210
+ cadence_prog_manager = edge_prog_manager .transform (
211
+ cast (
212
+ list [Callable [[torch .fx .GraphModule ], Optional [PassResult ]]], cadence_passes
213
+ )
214
+ )
215
+ return cadence_prog_manager
216
+
217
+
218
+ def export_to_executorch_gen_etrecord (
200
219
model : torch .nn .Module ,
201
220
inputs : tuple [object , ...],
202
221
dump_graphs : bool = False ,
Original file line number Diff line number Diff line change 16
16
17
17
from executorch .backends .cadence .aot .compiler import (
18
18
convert_pt2 ,
19
- export_to_cadence_edge_executorch ,
19
+ export_to_executorch_gen_etrecord ,
20
20
fuse_pt2 ,
21
21
)
22
22
@@ -86,8 +86,8 @@ def export_model(
86
86
quantized_model = fuse_pt2 (converted_model , quantizer )
87
87
88
88
# Get edge program after Cadence specific passes
89
- exec_prog : ExecutorchProgramManager = export_to_cadence_edge_executorch (
90
- quantized_model , example_inputs , working_dir
89
+ exec_prog : ExecutorchProgramManager = export_to_executorch_gen_etrecord (
90
+ quantized_model , example_inputs , output_dir = working_dir
91
91
)
92
92
93
93
logging .info ("Final exported graph:\n " )
Original file line number Diff line number Diff line change 1
1
# (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
2
2
3
3
4
- import torch
5
4
import executorch .backends .cadence .aot .ops_registrations # noqa
5
+ import torch
6
6
from executorch .backends .cadence .aot .graph_builder import (
7
7
GraphBuilder ,
8
8
single_op_builder ,
9
9
)
10
+ from executorch .backends .cadence .aot .pass_utils import count_node
10
11
from executorch .exir .dialects ._ops import ops as exir_ops
11
12
from executorch .exir .pass_base import ExportPass
12
13
from later .unittest import TestCase
13
- from executorch . backends . cadence . aot . pass_utils import count_node
14
+
14
15
15
16
class TestGraphBuilder (TestCase ):
16
17
def test_graph_with_single_im2row (self ) -> None :
You can’t perform that action at this time.
0 commit comments