@@ -503,23 +503,23 @@ def to_executorch(
503503 """
504504 Lower the model to executorch and get an ExecutorchProgram.
505505 """
506- # QuantFusionPass is not necessary because we set do_quant_fusion_and_const_prop=True
507- # in ExecutorchBackendConfig
508- to_executorch_passes = [
509- # If there are Linear operations left in the graph, let's execute
510- # them with the optimized op_linear rather than materializing a
511- # transpose followed by a regular op_mm.
512- # TODO: ConvertToLinearPass is not a sound pass and we should fix it
513- # https://github.com/pytorch/executorch/issues/10499
514- ConvertToLinearPass (),
515- ]
506+ to_executorch_passes = []
516507 if passes :
517508 # pyre-fixme[6]: In call `list.extend`, for 1st positional argument,
518509 # expected `Iterable[Union[ConvertToLinearPass, QuantFusionPass]]` but
519510 # got `List[ExportPass]
520511 to_executorch_passes .extend (passes )
521512
522513 assert self .edge_manager , "Need to run export_to_edge() first"
514+
515+ # If there are Linear operations left in the graph, let's execute
516+ # them with the optimized op_linear rather than materializing a
517+ # transpose followed by a regular op_mm.
518+ # TODO: ConvertToLinearPass is not a sound pass and must be called before
519+ # const propagation. It requires fixing:
520+ # https://github.com/pytorch/executorch/issues/10499
521+ self .edge_manager .transform ([ConvertToLinearPass ()])
522+
523523 self .export_program = self .edge_manager .to_executorch (
524524 ExecutorchBackendConfig (
525525 extract_delegate_segments = True ,
0 commit comments