File tree Expand file tree Collapse file tree 3 files changed +7
-13
lines changed Expand file tree Collapse file tree 3 files changed +7
-13
lines changed Original file line number Diff line number Diff line change @@ -895,7 +895,6 @@ def _to_edge_and_lower_llama_xnnpack(
895895 if gen_tag_fn is not None :
896896 from executorch .exir .passes .external_constants_pass import (
897897 delegate_external_constants_pass_unlifted ,
898- external_constants_pass ,
899898 )
900899
901900 assert (
@@ -906,18 +905,12 @@ def _to_edge_and_lower_llama_xnnpack(
906905 gen_tag_fn = gen_tag_fn ,
907906 )
908907
909- # Also add a pass for 'to_executorch' to tag weights that aren't delegated.
910- additional_passes .append (
911- partial (external_constants_pass , gen_tag_fn = gen_tag_fn )
912- )
913-
914908 builder = builder .to_edge_transform_and_lower (partitioners )
915909 if verbose :
916910 print_delegation_info (builder .edge_manager .exported_program ().graph_module )
917911
918- # we need builder.export_program
919-
920- return builder .to_executorch (passes = additional_passes )
912+ # Add gen_tag_fn to tag non-delegated weights as well.
913+ return builder .to_executorch (passes = additional_passes , external_constants_tag = gen_tag_fn )
921914
922915
923916def _to_edge_and_lower_llama_openvino (
Original file line number Diff line number Diff line change @@ -839,13 +839,11 @@ def edge_to_executorch_passes(
839839 Get the pre memory planning passes based on the method name, if the pass is not in the dict, use the default pass.
840840 """
841841 passes : List [PassType ] = [
842- SpecPropPass (),
843842 # ExecuTorch backend ops are unable to handle unbacked symints. So after
844843 # this pass, passes cannot be Interpreter-based, because it will fail if
845844 # there exists an unbacked symint operation.
846845 * config .passes ,
847- # config.passes may contain external_constants_pass. This pass has to
848- # run after SpecPropPass, which populates tensor names.
846+ SpecPropPass (),
849847 EdgeToBackendOpsPass (),
850848 RemoveGraphAssertsPass (),
851849 ] + pre_memory_planning_passes (config , name )
Original file line number Diff line number Diff line change @@ -473,7 +473,9 @@ def to_edge_transform_and_lower(
473473 return self
474474
475475 def to_executorch (
476- self , passes : Optional [List [ExportPass ]] = None
476+ self ,
477+ passes : Optional [List [ExportPass ]] = None ,
478+ external_constants_tag : Optional [Callable [[torch .fx .Node ], Optional [str ]]] = None ,
477479 ) -> "LLMEdgeManager" :
478480 """
479481 Lower the model to executorch and get an ExecutorchProgram.
@@ -506,6 +508,7 @@ def to_executorch(
506508 do_quant_fusion_and_const_prop = True ,
507509 memory_planning_pass = MemoryPlanningPass (alloc_graph_input = False ),
508510 sym_shape_eval_pass = ConstraintBasedSymShapeEvalPass (),
511+ external_constants = external_constants_tag ,
509512 )
510513 )
511514 logging .info (
You can’t perform that action at this time.
0 commit comments