yobx.torch.interpreter.native_export#

Lowers exported PyTorch programs through the native ONNX graph engines.

class yobx.torch.interpreter.native_export.NativeTorchInterpreter(builder, graph_module, dispatcher=None, raise_list=None)[source]#

Owns FX bookkeeping while native engines own graph and shape state.

ATen lowering only emits native operators. It does not run the legacy FX interpreter, Python shape rules, Python graph builder or Python optimizer. Unsupported operators fail at their FX node instead of falling back.

assert_tensor_metadata(node)[source]#

Discharges only assertions proved by exported tensor metadata.

branch(module, operands, prefix)[source]#

Builds an ONNX If branch with native inference and lexical captures.

broadcast_tensors(tensors, name)[source]#

Expands tensors to a shared runtime shape without promoting their dtypes.

call(node)[source]#

Lowers one supported ATen or higher-order call into native operators.

convolution(op, args, kwargs, outputs)[source]#

Lowers convolution attributes without computing output shapes.

custom(node, args, kwargs, name)[source]#

Calls an explicit custom lowering or rejects an unsupported FX target.

initializer(name, value)[source]#

Adds a parameter or constant as a native tensor initializer.

output_dtype(node)[source]#

Reads PyTorch dtype promotion metadata, not inferred ONNX shapes.

remainder(node, args, outputs)[source]#

Computes floor remainder with exact integer and floating fmod semantics.

resolve(value)[source]#

Resolves FX references without evaluating tensors in Python.

run()[source]#

Lowers all nodes after placeholders have been registered.

shape_tensor(dimensions)[source]#

Builds a runtime shape tensor from scalar values and shape operators.

tensor(value, dtype=None)[source]#

Normalizes scalar inputs and PyTorch-prescribed dtype promotion.

yobx.torch.interpreter.native_export.to_onnx(mod, args=None, kwargs=None, input_names=None, target_opset=None, as_function=False, options=None, verbose=0, return_builder=False, raise_list=None, dynamic_shapes=None, optimize=True, dispatcher=None, large_model=False, external_threshold=1024, export_options=None, return_optimize_report=False, filename=None, inline=True, export_modules_as_functions=False, function_options=None, output_names=None, output_dynamic_shapes=None, validate_onnx=False, return_ep=False)[source]#

Exports a supported Torch program using only native ONNX graph engines.

Tensor arguments, captured parameters, dynamic dimensions, standard ATen operations and torch.cond are supported. Nested argument pytrees, mutations, alternative tracing frontends and module-boundary function preservation are rejected explicitly. Standalone function export promotes weights to function inputs or embeds native Constant nodes.