light_op_schema.h#
Declares the lightweight ONNX operator schema types used by onnx_light.
This header defines the core data structures that onnx_light uses to describe ONNX operators without depending on the full onnx library:
ONNX_LIGHT_NAMESPACE::onnx_op::LightOpSchema, a read-only record that captures a single operator at a specific opset version (name, domain,
since_version, documentation string, formal inputs and outputs, and type constraints).ONNX_LIGHT_NAMESPACE::onnx_op::FormalParameter and ONNX_LIGHT_NAMESPACE::onnx_op::TypeConstraintParam, the building blocks used to describe input/output parameters and their type constraints.
::ONNX_LIGHT_NAMESPACE::onnx_op::TensorType, an enumeration of every element-tensor, sequence-tensor, and optional-tensor type used in type constraints, together with ::ONNX_LIGHT_NAMESPACE::onnx_op::ToTypeString to convert it to the canonical ONNX type string (e.g.
"tensor(float)").A collection of helper functions returning common type sets reused across operator schemas (
FloatTypes(),AllNumericTypes(),AllTensorTypes(),CastTypesVer*(),EqualTypesV*(), etc.).::ONNX_LIGHT_NAMESPACE::onnx_op::StripDocs to obtain a memory-light copy of a schema list with documentation strings cleared, useful in memory-constrained environments.
The schemas produced by the helpers in the sibling operator_sets_*.h headers are aggregated by operator_sets.h via GetAllOnnxOpSchemasWithHistory() and consumed by both documentation generators and the onnx_optim shape inference library.
Constructing a schema with invalid arguments throws a ONNX_LIGHT_NAMESPACE::onnx_op::SchemaError.
-
namespace ONNX_LIGHT_NAMESPACE
-
namespace onnx_op#
Enums
-
enum class TensorType : uint8_t#
Identifies an element or sequence tensor type supported by onnx-light.
Each enumerator corresponds to a concrete ONNX element type or to a sequence-of-tensor or optional-tensor type used in type-constraint definitions. The mapping from an enumerator to its canonical ONNX type string is implemented exhaustively by ToTypeString(); the naming convention is:
kXxx"tensor(xxx)", e.g.kFloat"tensor(float)",kInt64"tensor(int64)",kBfloat16"tensor(bfloat16)".kSeqXxx"seq(tensor(xxx))", e.g.kSeqFloat"seq(tensor(float))". The two map-valued sequences arekSeqMapStringFloat"seq(map(string, float))"andkSeqMapInt64Float"seq(map(int64, float))".kOptXxx"optional(tensor(xxx))"andkOptSeqXxx"optional(seq(tensor(xxx)))".kUndefined"tensor(undefined)".
Values:
-
enumerator kBool#
-
enumerator kString#
-
enumerator kUint8#
-
enumerator kUint16#
-
enumerator kUint32#
-
enumerator kUint64#
-
enumerator kInt8#
-
enumerator kInt16#
-
enumerator kInt32#
-
enumerator kInt64#
-
enumerator kFloat16#
-
enumerator kFloat#
-
enumerator kDouble#
-
enumerator kBfloat16#
-
enumerator kFloat8e4m3fn#
-
enumerator kFloat8e4m3fnuz#
-
enumerator kFloat8e5m2#
-
enumerator kFloat8e5m2fnuz#
-
enumerator kFloat8e8m0#
-
enumerator kFloat4e2m1#
-
enumerator kUint4#
-
enumerator kInt4#
-
enumerator kUint2#
-
enumerator kInt2#
-
enumerator kComplex64#
-
enumerator kComplex128#
-
enumerator kSeqBool#
-
enumerator kSeqString#
-
enumerator kSeqUint8#
-
enumerator kSeqUint16#
-
enumerator kSeqUint32#
-
enumerator kSeqUint64#
-
enumerator kSeqInt8#
-
enumerator kSeqInt16#
-
enumerator kSeqInt32#
-
enumerator kSeqInt64#
-
enumerator kSeqFloat16#
-
enumerator kSeqFloat#
-
enumerator kSeqDouble#
-
enumerator kSeqComplex64#
-
enumerator kSeqComplex128#
-
enumerator kSeqMapStringFloat#
-
enumerator kSeqMapInt64Float#
-
enumerator kOptSeqBool#
-
enumerator kOptSeqString#
-
enumerator kOptSeqUint8#
-
enumerator kOptSeqUint16#
-
enumerator kOptSeqUint32#
-
enumerator kOptSeqUint64#
-
enumerator kOptSeqInt8#
-
enumerator kOptSeqInt16#
-
enumerator kOptSeqInt32#
-
enumerator kOptSeqInt64#
-
enumerator kOptSeqFloat16#
-
enumerator kOptSeqFloat#
-
enumerator kOptSeqDouble#
-
enumerator kOptSeqComplex64#
-
enumerator kOptSeqComplex128#
-
enumerator kOptBool#
-
enumerator kOptString#
-
enumerator kOptUint8#
-
enumerator kOptUint16#
-
enumerator kOptUint32#
-
enumerator kOptUint64#
-
enumerator kOptInt8#
-
enumerator kOptInt16#
-
enumerator kOptInt32#
-
enumerator kOptInt64#
-
enumerator kOptFloat16#
-
enumerator kOptFloat#
-
enumerator kOptDouble#
-
enumerator kOptComplex64#
-
enumerator kOptComplex128#
-
enumerator kUndefined#
Functions
-
const char *ToTypeString(TensorType type)#
Returns the ONNX type-string representation of a TensorType value.
- Parameters:
type – Tensor type enumerator to convert.
- Returns:
Null-terminated string such as
"tensor(float)"or"seq(tensor(int64))".
-
std::vector<TensorType> FloatTypes()#
Returns floating-point tensor types (float16, float, double, bfloat16).
-
std::vector<TensorType> NumericTypesForMathReduction()#
Returns numeric types used in reduction ops (excludes low-precision floats).
-
std::vector<TensorType> NumericTypesForMathReductionIr4()#
Returns numeric types used in reduction ops for IR version 4 and later.
-
std::vector<TensorType> AllNumericTypes()#
Returns all numeric (integer and floating-point) tensor types.
-
std::vector<TensorType> AllNumericTypesIr4()#
Returns all numeric tensor types for IR version 4 and later.
-
std::vector<TensorType> AllTensorTypes()#
Returns all scalar tensor types (no sequence types).
-
std::vector<TensorType> AllTensorSequenceTypes()#
Returns all sequence-of-tensor types.
-
std::vector<TensorType> AllOptionalTypes()#
Returns all optional tensor and optional sequence tensor types. Matches
OpSchema::all_optional_types()from the full ONNX library.
-
std::vector<TensorType> CastTypesVer1And6()#
Returns the Cast input/output types valid for opset versions 1 and 6.
-
std::vector<TensorType> CastTypesVer9()#
Returns the Cast input/output types valid from opset version 9.
-
std::vector<TensorType> CastTypesVer13()#
Returns the Cast input/output types valid from opset version 13.
-
std::vector<TensorType> CastTypesVer19()#
Returns the Cast input/output types valid from opset version 19.
-
std::vector<TensorType> CastTypesVer21()#
Returns the Cast input/output types valid from opset version 21.
-
std::vector<TensorType> CastTypesVer23()#
Returns the Cast input/output types valid from opset version 23.
-
std::vector<TensorType> CastTypesVer24()#
Returns the Cast input/output types valid from opset version 24.
-
std::vector<TensorType> CastTypesVer25()#
Returns the Cast input/output types valid from opset version 25.
-
std::vector<TensorType> EqualTypesV1V7()#
Returns the Equal input types valid for opset versions 1 and 7.
-
std::vector<TensorType> EqualTypesV11()#
Returns the Equal input types valid from opset version 11.
-
std::vector<TensorType> EqualTypesV13()#
Returns the Equal input types valid from opset version 13.
-
std::vector<TensorType> EqualTypesV19()#
Returns the Equal input types valid from opset version 19.
-
std::vector<TensorType> ConcatTypesVer1()#
Returns the Concat input/output types valid for opset version 1 (float16, float, double).
-
std::vector<TensorType> ConcatTypesVer4And11()#
Returns the Concat input/output types valid for opset versions 4 and 11 (matches
OpSchema::all_tensor_types()from the full ONNX library).
-
std::vector<TensorType> ConcatTypesVer13()#
Returns the Concat input/output types valid from opset version 13 (matches
OpSchema::all_tensor_types_ir4()from the full ONNX library).
-
std::vector<LightOpSchema> StripDocs(const std::vector<LightOpSchema> &schemas)#
Returns a copy of
schemaswith all documentation strings replaced by an empty string. Useful when callers want the schema metadata but do not need documentation, saving memory in memory-constrained environments.
Variables
-
constexpr const char *kOnnxDomain = "ai.onnx"#
The standard ONNX operator domain string.
-
struct FormalParameter#
- #include <light_op_schema.h>
Describes a single formal input or output parameter of an ONNX operator.
-
class LightOpSchema#
- #include <light_op_schema.h>
Lightweight, read-only description of an ONNX operator schema at one specific opset version.
A LightOpSchema captures everything that documentation and validation tools need about a single versioned operator: its name, domain, the opset version it was introduced in, its documentation string, the formal inputs and outputs, and the type constraints that govern them.
Public Functions
-
inline LightOpSchema(std::string name, std::string domain, int since_version, std::string doc, std::vector<FormalParameter> inputs, std::vector<FormalParameter> outputs, std::vector<TypeConstraintParam> type_constraints, bool has_function_implementation = false, bool init_doc = true)#
Constructs a schema record for a versioned ONNX operator.
- Parameters:
name – Operator name (e.g. “Add”).
domain – Operator domain (e.g. “ai.onnx”).
since_version – Opset version at which this schema was introduced.
doc – Documentation string (may contain Markdown).
inputs – Ordered list of formal input parameters.
outputs – Ordered list of formal output parameters.
type_constraints – Type constraints referenced by the parameters.
has_function_implementation – Whether the op has a function body.
init_doc – If true (default), the documentation string is stored on the schema. When false, the
docargument is discarded and doc() returns an empty string. This can be used to save memory when documentation is not needed by the consumer.
-
inline int since_version() const#
Returns the opset version at which this schema was introduced.
-
inline const std::vector<FormalParameter> &inputs() const#
Returns the list of formal input parameters.
-
inline const std::vector<FormalParameter> &outputs() const#
Returns the list of formal output parameters.
-
inline const std::vector<TypeConstraintParam> &type_constraints() const#
Returns the type constraints for this schema.
-
inline bool has_function_implementation() const#
Returns true if the operator has a function body implementation.
-
inline LightOpSchema(std::string name, std::string domain, int since_version, std::string doc, std::vector<FormalParameter> inputs, std::vector<FormalParameter> outputs, std::vector<TypeConstraintParam> type_constraints, bool has_function_implementation = false, bool init_doc = true)#
-
class SchemaError : public std::runtime_error#
- #include <light_op_schema.h>
Thrown when a LightOpSchema is constructed with invalid arguments.
Public Functions
-
inline explicit SchemaError(const std::string &message)#
Constructs a SchemaError with the given diagnostic message.
-
inline explicit SchemaError(const std::string &message)#
-
struct TypeConstraintParam#
- #include <light_op_schema.h>
Specifies which tensor types are permitted for a named type parameter.
-
enum class TensorType : uint8_t#
-
namespace onnx_op#