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

Function _transform

exir/program/_program.py:223–247  ·  view source on GitHub ↗

Transforms the program according to the provided passes. Args: self: The ExportedProgram instance to transform *passes: A sequence of passes to apply to the program override_verifiers: Optional list of verifier classes to use instead of the default verifiers.

(
    self,
    *passes: PassType,
    override_verifiers: None | list[Type[Verifier]] = None,
)

Source from the content-addressed store, hash-verified

221
222
223def _transform(
224 self,
225 *passes: PassType,
226 override_verifiers: None | list[Type[Verifier]] = None,
227) -> "ExportedProgram":
228 """
229 Transforms the program according to the provided passes.
230
231 Args:
232 self: The ExportedProgram instance to transform
233 *passes: A sequence of passes to apply to the program
234 override_verifiers: Optional list of verifier classes to use instead of the default verifiers.
235 This is needed if the transforms yields illegal graph that the default verifier cannot handle.
236
237 Returns:
238 ExportedProgram: A new ExportedProgram with the transformations applied, or self if no changes were made
239 """
240 # A user friendly check to avoid vararg surprises, PEP 3102
241 assert not any(
242 isinstance(p, (list, Verifier)) for p in passes
243 ), f"Expected all passes to be of PassType, not list or Verifier. Use override_verifiers kwarg instead. Got: {list(passes)}"
244
245 return _transform_with_pass_manager(
246 self, PassManager(list(passes)), override_verifiers
247 )
248
249
250def _transform_with_pass_manager(

Callers 13

programMethod · 0.90
captureFunction · 0.90
transformMethod · 0.90
runMethod · 0.90
transformMethod · 0.90
transformMethod · 0.90
preprocessMethod · 0.90
apply_passesFunction · 0.90
transformMethod · 0.85
_generate_edge_programFunction · 0.85

Calls 2

PassManagerClass · 0.90

Tested by 3

transformMethod · 0.72