CodeGen#
- class torch.fx.graph.CodeGen[source]#
Warning
This API is experimental and is NOT backward-compatible.
- additional_globals()[source]#
If your codegen uses extra global values, add tuples of (identifier,reference to the value) here. For example, return [‘List’, typing.List] if you need
Listin the global context.
- gen_fn_def(free_vars, maybe_return_annotation, *, expanded_def=False)[source]#
Given the free variables and a return annotation, generates the beginning of the FX function. By default, gen_fn_def([‘a’, ‘b’], ‘’) == ‘def {self._func_name}(a, b):’
- Return type:
- generate_output(output_args, *, descs=None, repr_fn=None)[source]#
Given the output arguments, generates the return statement of the FX function. Note: The returned statement should not be indented.
- Return type:
- process_inputs(*args)[source]#
Transforms the inputs so that the graph can take them as arguments, as non-default codegen may result in the inputs to the function being different from the inputs to the graph.
If the graph was directly runnable, this invariant should hold true f.graph.process_outputs(f.graph(*f.graph.process_inputs(*inputs))) == f(*inputs)
- Return type: