yobx.xshape.native_shape_inference#
Exposes native symbolic inference without a Python shape-engine fallback.
- class yobx.xshape.native_shape_inference.NativeShapeInference(verbose=0, opset=None)[source]#
Infers ONNX tensor descriptors with a persistent native
ShapesContext.TYPEuses the same native engine but exposes only element types. Unknown operators and incompatible constraints raise the native exception, including when the legacyexc=Falseargument is supplied. Custom inference can be registered directly oncontext.- add_to_constraints(dim_name: str, value: int | str | set[int | str]) None[source]#
Registers one or several native dimension equalities.
- estimate_node_flops(node)[source]#
Estimates arithmetic cost using only native descriptors and values.
- evaluate_cost_with_true_inputs(feeds, cost, exc=False)[source]#
Evaluates symbolic costs against actual input dimensions.
- evaluate_shape(name: str, context: dict[str, int]) tuple[int | None, ...][source]#
Evaluates native expressions and preserves anonymous unknown dimensions.
- get_constant(name, exc=True, computed_value=False, as_shape=False, **kwargs)[source]#
Returns a registered literal without evaluating Python operators.
- get_registered_constraints() dict[str, set[int | str]][source]#
Returns equality constraints recorded by the native engine.
- get_shape(name: str) Tuple[int | str | None, ...][source]#
Returns native dimensions, preserving anonymous dimensions as
None.
- property input_names#
Returns the model input names.
- property main_opset#
Returns the default-domain opset.
- property output_names#
Returns the model output names.
- register_constraint_dimension(dim_name: str, value: int | str | set[int | str]) None[source]#
Registers one or several native dimension equalities.
- run_model(model, functions=None, exc=False, inference=InferenceMode.SHAPE)[source]#
Runs native inference and optionally returns per-node cost statistics.
- run_node(node, exc=False, cost=True)[source]#
Infers a node natively and optionally estimates its arithmetic cost.
- set_device(name: str, device: int, **kwargs) None[source]#
Stores optional device metadata without performing inference.