yobx.helpers.to_onnx_helper#

yobx.helpers.to_onnx_helper.extract_value_info_proto(vip: ValueInfoProto) Tuple[str, int, Tuple | None][source]#

Extract (name, elem_type, shape) from a onnx.ValueInfoProto.

Parameters:

vip – an ONNX value-info descriptor

Returns:

tuple (name, elem_type, shape) where shape is None when no shape information is present, and otherwise a tuple whose elements are int for static dimensions, a non-empty str for symbolic dimensions, and an auto-generated name such as "_unk_0_" for dimensions with no value and no symbolic name.

yobx.helpers.to_onnx_helper.is_arg_tuple_spec(arg: Any) bool[source]#

Return True if arg is a (name, dtype, shape) input specification.

Supported format:

('input_name', np.float32, ('N', 4))

where

  • name is a str

  • dtype is a numpy.dtype instance, a numpy scalar-type class (e.g. np.float32), or anything accepted by np.dtype(...)

  • shape is a tuple or list whose elements are integers (static dimensions) or strings (symbolic dimensions).

yobx.helpers.to_onnx_helper.register_inputs(g: GraphBuilderExtendedProtocol, args: Tuple[Any, ...], input_names: Sequence[str] | None, dynamic_shapes: Tuple[Dict[int, str]] | None) List[str][source]#

Resolve input_names and register each input with the graph builder g.

Parameters:
  • g – graph builder (GraphBuilderExtendedProtocol)

  • args – input descriptors — numpy arrays, pandas DataFrames, onnx.ValueInfoProto objects, or (name, dtype, shape) tuples. A pandas DataFrame is expanded column-by-column: each column is registered as a separate 1-D ONNX graph input (named after the column), and an ONNX Unsqueeze + Concat node sequence assembles them back into a 2-D matrix (batch, n_cols) that is passed to the converter under the resolved input name.

  • input_names – optional explicit names; overrides names embedded in ValueInfoProto / tuple descriptors when provided. For DataFrame args this controls the name of the assembled 2-D tensor, not the per-column input names.

  • dynamic_shapes – per-input axis-to-symbol mapping used only for numpy-array and DataFrame inputs; None defaults to {0: "batch"}

Returns:

the resolved list of input names (same length as args)