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 aonnx.ValueInfoProto.- Parameters:
vip – an ONNX value-info descriptor
- Returns:
tuple
(name, elem_type, shape)where shape isNonewhen no shape information is present, and otherwise a tuple whose elements areintfor static dimensions, a non-emptystrfor 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
nameis astrdtypeis anumpy.dtypeinstance, a numpy scalar-type class (e.g.np.float32), or anything accepted bynp.dtype(...)shapeis atupleorlistwhose 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.ValueInfoProtoobjects, or(name, dtype, shape)tuples. A pandasDataFrameis expanded column-by-column: each column is registered as a separate 1-D ONNX graph input (named after the column), and an ONNXUnsqueeze+Concatnode 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;
Nonedefaults to{0: "batch"}
- Returns:
the resolved list of input names (same length as args)