shape_traditionalml.h#

Shape-inference functions for ONNX operators in the ai.onnx.ml (traditional machine-learning) family.

namespace ONNX_LIGHT_NAMESPACE
namespace onnx_optim
namespace shapes
namespace traditionalml#

Functions

void ComputeShapeBinarizer(ShapesContext &ctx, const NodeProto &node, const char *x)#

Computes the output :cpp:class:OptimTensor of a Binarizer node and stores it in ctx.

Binarizer (ai.onnx.ml) is an element-wise operator: the output tensor has the exact same shape and element type as the input — only the values change (each element becomes 1 if it is strictly greater than the threshold attribute, 0 otherwise).

Parameters:
  • ctx – In/out context. Must already contain an entry for x; on return it also contains an entry for node.output(0).

  • node – The Binarizer NodeProto whose output should be described. node.op_type() must be "Binarizer" and node must declare at least one output.

  • x – Name of the input value to read from ctx. Must be present in ctx.

Throws:
  • std::invalid_argument – if node.op_type() is not "Binarizer" or if node has no output.

  • std::out_of_range – if x is not present in ctx.

void ComputeShapeLabelEncoder(ShapesContext &ctx, const NodeProto &node, const char *x)#

Computes the output :cpp:class:OptimTensor of a LabelEncoder node and stores it in ctx.

LabelEncoder (ai.onnx.ml) is a one-to-one mapping from input keys to output values, so the output shape always matches the input shape. The output dtype is determined by which of the values_* attributes is set:

  • values_tensor — dtype is the tensor’s data_type;

  • values_strings — dtype is string;

  • values_int64s — dtype is int64;

  • values_floats — dtype is float.

Exactly one of these attributes must be set; an error is raised otherwise.

Parameters:
  • ctx – In/out context. Must already contain an entry for x; on return it also contains an entry for node.output(0).

  • node – The LabelEncoder NodeProto whose output should be described. node.op_type() must be "LabelEncoder" and node must declare at least one output.

  • x – Name of the input value to read from ctx. Must be present in ctx.

Throws:
  • std::invalid_argument – if node.op_type() is not "LabelEncoder", if node has no output, or if the attributes do not specify exactly one of the allowed values_* forms.

  • std::out_of_range – if x is not present in ctx.

Variables

constexpr const char *kOnnxMlDomain = "ai.onnx.ml"#

Canonical domain string for the ai.onnx.ml operator set.