Skip to content

ir_op

torch_to_nnef.torch_graph.ir_op

Abstractions used in torch_to_nnef internal graph Operations IR.

(decoupled from PyTorch and NNEF)

The goal is that these elements are: - extracted/parsed from PyTorch graph operations - translated to NNEF graph operations

InputsAlignBetweenAtenAndTorch

Mapping inputs between Python torch.$1 and cpp aten::$2.

Because function arguments are not 1 to 1

TorchOp dataclass

TorchOp(kind: str, module_path: str, inputs: T.List[Data], outputs: T.List[TtupleOrVar], scope: str, op_ref: T.Optional[T.Callable], call_name: T.Optional[str])
call_op
call_op()

Produce operation output based on traced inputs with real torch call.

This operation call is done via self.args arguments (for now). Which means that we need to have all args needed in parameters order, following at least 1 underling torch operation signature.

NOTE: we use a different approach than original torch.onnx which pass parameter by keyword arguments, this is due to the fact that we are not aware of argument name being provided in exported graph ( from what we understand torch.onnx solve this via explicit rerouting of all signatures, which might be a bit bulky in most case ).

realise_output_type_and_size
realise_output_type_and_size(approx: bool = True) -> bool

Trace output and try to find type shape and constant realisation.

update_call_op_arg_kwargs
update_call_op_arg_kwargs(args)

Custom adaptation to call aten fn with torch exposed py fn.