File tree Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -196,7 +196,26 @@ def export_to_edge(
196196# Export the model and lower it to an EdgeProgramManager (in edge IR), and
197197# apply passes specific to Cadence DSP execution. Return both to print the
198198# 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 (
200219 model : torch .nn .Module ,
201220 inputs : tuple [object , ...],
202221 dump_graphs : bool = False ,
Original file line number Diff line number Diff line change 1616
1717from executorch .backends .cadence .aot .compiler import (
1818 convert_pt2 ,
19- export_to_cadence_edge_executorch ,
19+ export_to_executorch_gen_etrecord ,
2020 fuse_pt2 ,
2121)
2222
@@ -86,8 +86,8 @@ def export_model(
8686 quantized_model = fuse_pt2 (converted_model , quantizer )
8787
8888 # 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
9191 )
9292
9393 logging .info ("Final exported graph:\n " )
You can’t perform that action at this time.
0 commit comments