MCPcopy Create free account
hub / github.com/pytorch/executorch / apply_passes

Function apply_passes

backends/vulkan/vulkan_preprocess.py:69–91  ·  view source on GitHub ↗
(program: ExportedProgram, passes)

Source from the content-addressed store, hash-verified

67
68# pyre-ignore
69def apply_passes(program: ExportedProgram, passes) -> ExportedProgram:
70 for p in passes:
71 if isinstance(p, MemoryPlanningPass) and hasattr(p, "run"):
72 p.run(program.graph_module)
73
74 elif issubclass(type(p), ExportPass) or issubclass(type(p), PassBase):
75 # Some passes require the ep to be provided. However, since the ep may be
76 # updated with each pass applied, the ep must be set right before calling
77 # the pass. _exported_program is the attribute used by XNNPACK and Vulkan
78 # passes to store the exported program.
79 if hasattr(p, "_exported_program"):
80 p._exported_program = program
81
82 program = _transform(program, p, override_verifiers=[_any_op])
83 # See the application of this function in exir/program/_program.py for more
84 # details on why this step is necessary.
85 if isinstance(p, SpecPropPass):
86 p.update_placeholder_tensor_specs(program, program.graph_module)
87
88 else:
89 program = p(program)
90
91 return program
92
93
94def parse_compile_spec(compile_specs: List[CompileSpec]) -> Dict[str, Any]:

Callers 1

preprocessMethod · 0.85

Calls 3

_transformFunction · 0.90
runMethod · 0.45

Tested by

no test coverage detected