include_optional_kernels.h#
-
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.
Defined as empty because onnx-light does not require explicit
__declspec(dllexport)or__attribute__((visibility("default")))annotations — visibility is controlled at the shared-library level. The macro is provided so that vendored ONNX headers that decorate their declarations withONNX_APIcompile without modification.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 onnx_kernels
-
namespace kernel
-
class Optional : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_optional_kernels.h>
Wraps a single tensor
inputinto an optional-of-tensor value. The output’s element type, shape and bytes are an exact copy ofinput.Public Functions
-
inline explicit KernelBase(const KernelContext &ctx)#
Public Static Functions
-
static inline constexpr bool CanRunInPlace() noexcept#
Output is a byte-for-byte copy of
input, so storage may safely be shared with the input buffer.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
class OptionalGetElement : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_optional_kernels.h>
Reference implementation of the ONNX
OptionalGetElementoperator (since opset 15 in the ai.onnx domain). It extracts the element from an optional-type input and returns it. Because the project’s runtime :ref:Tensortype does not model optional values, the kernel treats the input as the “present” element and behaves as a passthrough:the tensor overload returns a byte-for-byte copy of the input tensor (same
data_typeandshape);the sequence overload returns a copy of the input sequence.
Since opset 18,
OptionalGetElementalso accepts non-optional tensor or sequence inputs as a no-op; the same passthrough behavior is correct in both cases. The kernel does not consume attributes.Public Functions
-
inline explicit KernelBase(const KernelContext &ctx)#
Public Static Functions
-
static inline constexpr bool CanRunInPlace() noexcept#
Output is a byte-for-byte copy of
input, so storage may safely be shared with the input buffer when both are tensors.
-
class OptionalHasElement : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_optional_kernels.h>
Reference implementation of the ONNX
OptionalHasElementoperator (since opset 15 in the ai.onnx domain). Returns a scalar boolean tensor:truewhen the input contains an element,falsewhen the input is an empty optional or (since opset 18) when no input is provided.Because the project’s runtime :ref:
Tensorand :ref:Sequencetypes do not model “empty optional” values, this kernel treats any concrete tensor or sequence input as containing an element (returnstrue). The zero-input overload returnsfalseand mirrors the opset-18 behavior where the input is omitted.Public Functions
-
Tensor operator()(const Tensor &input) const#
Tensor input: always returns
Tensor<bool, {}>{true}(the input is assumed to be the present element).
-
inline explicit KernelBase(const KernelContext &ctx)#
Public Static Functions
-
static inline constexpr bool CanRunInPlace() noexcept#
Output is a fresh scalar bool tensor unrelated to any input storage; aliasing is not permitted.
-
Tensor operator()(const Tensor &input) const#
-
class Optional : public onnx_light::onnx_kernels::kernel::KernelBase#
-
namespace kernel
-
namespace onnx_kernels