(program: ExportedProgram, passes)
| 67 | |
| 68 | # pyre-ignore |
| 69 | def 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 | |
| 94 | def parse_compile_spec(compile_specs: List[CompileSpec]) -> Dict[str, Any]: |
no test coverage detected