sym_map.h#
Lightweight description of an ONNX map(K,V) value used by onnx_shapes shape-inference passes.
The onnx_shapes stack already exposes :cpp:class:SymTensor and :cpp:class:SymSequence to describe tensor- and sequence-typed values flowing through a graph. Operators such as ZipMap, CastMap or DictVectorizer (from the ai.onnx.ml domain) consume or produce map values, so a matching descriptor is needed.
:cpp:class:SymMap is the analogue of :cpp:class:SymTensor and :cpp:class:SymSequence for map values. An ONNX map(K,V) value associates scalar keys of a fixed key type (INT64 or STRING per the ONNX spec) with values of a fixed value type V. This descriptor records the key :cpp:type:TensorType, the value :cpp:type:TensorType, and the value’s :cpp:class:SymShape (for value types that are themselves tensors, e.g. map(int64, tensor) is not part of the ONNX spec today but the shape is kept for forward-compatibility with per-value tensor shapes).
Like :cpp:class:SymTensor and :cpp:class:SymSequence it is a small, value-typed, non-owning descriptor: it never allocates the underlying data.
-
namespace onnx_light
Alias that makes onnx-light headers compatible with code that references
ONNX_LIGHT_NAMESPACE(the macro used in the standard onnx package).Set to
ONNX_LIGHT_NAMESPACEso both names resolve to the same namespace.Symbol-visibility attribute for the public onnx-light C++ API.
Maps the upstream compatibility macro to onnx-light’s explicit proto ABI annotation. This keeps declarations from vendored ONNX headers visible when
lib_onnx_protouses hidden visibility by default.Namespace alias so that ONNX C++ code (and consumers such as onnxruntime) that refers to the literal
onnxnamespace — rather than theONNX_NAMESPACEmacro — resolves to the onnx-light namespace. The standard onnx package lives innamespace onnx; onnx-light usesonnx_light(via ONNX_LIGHT_NAMESPACE), so this alias keeps onnx-light a true drop-in. It is only introduced when the onnx-light namespace differs fromonnx.-
namespace core
-
namespace symbolic#
-
class SymMap#
- #include <sym_map.h>
Descriptor for an ONNX
map(K,V)value. A map carries a key :cpp:type:TensorType(conceptuallyINT64orSTRINGper the ONNX spec, though this descriptor does not enforce that constraint) and a value :cpp:type:TensorTypetogether with an optional :cpp:class:SymShapedescribing the shape of each value.When the key or value dtype is not known (e.g. for the output of an operator whose map type depends on an attribute that has not been resolved yet), the descriptor stores :cpp:enumerator:
TensorType::kUndefinedfor the corresponding field. Callers can use :cpp:func:HasKeyTypeand :cpp:func:HasValueDtypeto distinguish “unknown” from “explicitly undefined”.Public Functions
-
SymMap() = default#
Default constructs a map descriptor with unknown key type, unknown value dtype, and no recorded value shape.
-
inline SymMap(TensorType key_type, TensorType value_dtype, SymShape value_shape = SymShape())#
Constructs a map descriptor from a known key type, a known value dtype, and an optional value shape (defaults to a scalar, rank-0 shape).
-
inline TensorType KeyType() const noexcept#
Key type of the map. Returns :cpp:enumerator:
TensorType::kUndefinedwhen the key type is unknown (see :cpp:func:HasKeyType).
-
inline TensorType ValueDtype() const noexcept#
Value dtype of the map. Returns :cpp:enumerator:
TensorType::kUndefinedwhen the value dtype is unknown (see :cpp:func:HasValueDtype).
-
inline const SymShape &ValueShape() const noexcept#
Shape of each value stored in the map. Defaults to a scalar (rank-0) shape for the common case where values are single numbers or strings.
-
inline bool HasKeyType() const noexcept#
truewhen a key type has been recorded for this map.
-
inline bool HasValueDtype() const noexcept#
truewhen a value dtype has been recorded for this map.
-
inline void SetKeyType(TensorType key_type) noexcept#
Replaces the recorded key type. Passing :cpp:enumerator:
TensorType::kUndefinedclears the key type.
-
inline void SetValueDtype(TensorType value_dtype) noexcept#
Replaces the recorded value dtype. Passing :cpp:enumerator:
TensorType::kUndefinedclears the value dtype.
Private Members
-
TensorType key_type_ = TensorType::kUndefined#
-
TensorType value_dtype_ = TensorType::kUndefined#
-
bool has_key_type_ = false#
-
bool has_value_dtype_ = false#
-
SymMap() = default#
-
class SymMap#
-
namespace symbolic#
-
namespace core