FX lowering¶
- class torch_lattice.artifact.fx.LatticeArtifactInterpreter(module, builder)[source]¶
Bases:
InterpreterLower an FX graph by interpreting it with symbolic lattice values.
- Parameters:
module (fx.GraphModule)
builder (TorchLatticeArtifactBuilder)
- call_module(target, args, kwargs)[source]¶
Execute a
call_modulenode and return the result.- Parameters:
- Return type:
- Return
Any: The value returned by the module invocation
Note
Backwards-compatibility for this API is guaranteed.
- call_function(target, args, kwargs)[source]¶
Execute a
call_functionnode and return the result.- Parameters:
- Return type:
- Return
Any: The value returned by the function invocation
Note
Backwards-compatibility for this API is guaranteed.
- class torch_lattice.artifact.fx.LatticeTracer[source]¶
Bases:
TracerFX tracer that preserves supported lattice modules and ops.
- is_leaf_module(module, module_qualified_name)[source]¶
A method to specify whether a given
nn.Moduleis a “leaf” module.Leaf modules are the atomic units that appear in the IR, referenced by
call_modulecalls. By default, Modules in the PyTorch standard library namespace (torch.nn) are leaf modules. All other modules are traced through and their constituent ops are recorded, unless specified otherwise via this parameter.- Parameters:
m (Module) – The module being queried about
module_qualified_name (
str) – The path to root of this module. For example, if you have a module hierarchy where submodulefoocontains submodulebar, which contains submodulebaz, that module will appear with the qualified namefoo.bar.bazhere.module (Module)
- Return type:
Note
Backwards-compatibility for this API is guaranteed.
- torch_lattice.artifact.fx.lower_fx_artifact(builder, model, inputs=None)[source]¶
- Return type:
- Parameters:
builder (TorchLatticeArtifactBuilder)
model (Module)
inputs (Iterable[ArtifactValue] | None)