include_generator_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 Bernoulli : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_generator_kernels.h>
Reference implementation of the ONNX
Bernoullioperator (since opset 15 in theai.onnxdomain). Draws binary samplesy[i]from a Bernoulli distribution with probabilityinput[i](a value in[0, 1]); returns1with probabilityinput[i]and0otherwise.Bernoulliis non-deterministic; this reference implementation uses astd::mt19937engine seeded either with the value of the optionalseedattribute (interpreted by truncating touint32_t) or, when the attribute is absent, with a fixed default seed so the kernel is reproducible for testing. Output dtype is controlled by the optionaldtypeattribute: when absent the output element type matches the input; when present it overrides the output element type.Supported input dtypes are
FLOAT,DOUBLEandFLOAT16; supported output dtypes areFLOAT,DOUBLE,FLOAT16,INT8,INT16,INT32,INT64,UINT8,UINT16,UINT32,UINT64andBOOL(every type for which the produced 0/1 value has a natural representation).Public Functions
-
Tensor operator()(const Tensor &input, int64_t seed = kNoSeed, int32_t dtype = 0) const#
Draws Bernoulli samples for every element of
input.seedis the value of theseedattribute when present (truncated touint32_t); passkNoSeedto use the kernel’s default seed.dtypeis the value of thedtypeattribute when present (a :cpp:class:DataTypevalue); pass0to keep the output dtype identical toinput.data_type.
-
inline explicit KernelBase(const KernelContext &ctx)#
Public Static Functions
-
static inline constexpr bool CanRunInPlace() noexcept#
The output buffer has the same byte size as the input only when
dtypeis identical to the input dtype, which we do not require; disable in-place support to keep the contract simple.
Public Static Attributes
-
static constexpr int64_t kNoSeed = -1#
Sentinel value indicating the
seedattribute is absent. Picked outside theuint32_trange so any 32-bit seed (including 0) is representable as a regular value.
-
Tensor operator()(const Tensor &input, int64_t seed = kNoSeed, int32_t dtype = 0) const#
-
class Constant : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_generator_kernels.h>
Returns a copy of the
valueattribute of theConstantop.Public Functions
-
inline explicit KernelBase(const KernelContext &ctx)#
Public Static Functions
-
static inline constexpr bool CanRunInPlace() noexcept#
-
inline explicit KernelBase(const KernelContext &ctx)#
-
class ConstantOfShape : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_generator_kernels.h>
Reference implementation of the ONNX
ConstantOfShapeoperator (since opset 9 in theai.onnxdomain). Produces an output tensor of the shape given by the 1-Dint64shapeinput, filled with the (single) scalar value of thevaluetensor.When
valueis empty (data_type == 0anddata.empty()), the output defaults to aFLOATtensor filled with zeros, per the schema.Supported numeric
valuedtypes match the upstreamtest_constantofshape_int_zeros/test_constantofshape_float_onesnode tests: every fixed-width whole-byte numeric type as well asBOOL. Other dtypes throwstd::invalid_argument.Public Functions
-
Tensor operator()(const Tensor &shape, const Tensor &value) const#
shapemust be a 1-D INT64 tensor whose entries describe the shape of the output.valueis the (single-element) fill value taken from the operator’svalueattribute; pass a default-constructedTensorto use the schema default (FLOAT 0.0).
-
inline explicit KernelBase(const KernelContext &ctx)#
Public Static Functions
-
static inline constexpr bool CanRunInPlace() noexcept#
The output buffer has a different size than the inputs, so storage can not generally be shared.
-
Tensor operator()(const Tensor &shape, const Tensor &value) const#
-
class EyeLike : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_generator_kernels.h>
Reference implementation of ONNX
EyeLike(since opset 9): returns a matrix with ones on diagonalkand zeros elsewhere, with output shape copied from the 2-Dinputtensor.Public Functions
-
inline explicit KernelBase(const KernelContext &ctx)#
Public Static Functions
-
static inline constexpr bool CanRunInPlace() noexcept#
-
inline explicit KernelBase(const KernelContext &ctx)#
-
class Multinomial : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_generator_kernels.h>
Reference implementation of the ONNX
Multinomialoperator (since opset 7 in theai.onnxdomain). Drawssample_sizesamples from a multinomial distribution per batch row, where the per-row unnormalized log-probabilities are given by the 2-D input tensor of shape[batch_size, class_size]. The output is a 2-D tensor of shape[batch_size, sample_size]of integer class indices.Multinomialis non-deterministic; this reference implementation uses astd::mt19937engine seeded either with the value of the optionalseedattribute (interpreted by truncating touint32_t) or, when the attribute is absent, with a fixed default seed so the kernel is reproducible for testing.Supported input dtypes are
FLOAT,DOUBLEandFLOAT16. Supported output dtypes areINT32(default) andINT64.Public Functions
-
Tensor operator()(const Tensor &input, int64_t sample_size = 1, int64_t seed = kNoSeed, int32_t dtype = 0) const#
Draws
sample_sizesamples per batch row ofinput.seedis the value of theseedattribute when present (truncated touint32_t); passkNoSeedto use the kernel’s default seed.dtypeis the value of thedtypeattribute; pass0(or :cpp:enumerator:DataType::INT32) to produceINT32output, or :cpp:enumerator:DataType::INT64forINT64output.
-
void operator()(const Tensor &input, int64_t sample_size, int64_t seed, int32_t dtype, Tensor &output) const#
-
inline explicit KernelBase(const KernelContext &ctx)#
Public Static Functions
-
static inline constexpr bool CanRunInPlace() noexcept#
The output buffer has a different shape than the input, so storage cannot generally be shared.
Public Static Attributes
-
static constexpr int64_t kNoSeed = -1#
Sentinel meaning
seedattribute is absent.
-
Tensor operator()(const Tensor &input, int64_t sample_size = 1, int64_t seed = kNoSeed, int32_t dtype = 0) const#
-
class RandomNormal : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_generator_kernels.h>
Reference implementation of the ONNX
RandomNormaloperator (since opset 1 in theai.onnxdomain). Produces an output tensor of the givenshapefilled with samples drawn from a normal distribution with meanmeanand standard deviationscale.RandomNormalis non-deterministic; this reference kernel uses the deterministic :cpp:func:Randnhelper (SplitMix64 + Irwin-Hall) so expected outputs are bit-stable for testing. Whenseedis :cpp:var:kNoSeedthe kernel’s default seed is used; otherwise the optionalseedattribute (declared as FLOAT in the schema) is truncated touint64_tand forwarded to :cpp:func:Randn.Supported output dtypes are
FLOAT(default) andDOUBLE; any other value ofdtypetriggersstd::invalid_argument.Public Functions
-
Tensor operator()(const std::vector<int64_t> &shape, double mean = 0.0, double scale = 1.0, int64_t seed = kNoSeed, int32_t dtype = 0) const#
Produces a
shape-shaped tensor of normal samples.meanandscalecome from the operator attributes (defaults0.0/1.0).dtypedefaults toDataType::FLOATto mirror the schema default.seedselects the RNG seed; passkNoSeedto use the kernel’s default.
-
void operator()(const std::vector<int64_t> &shape, double mean, double scale, int64_t seed, int32_t dtype, Tensor &output) const#
-
inline explicit KernelBase(const KernelContext &ctx)#
Public Static Functions
-
static inline constexpr bool CanRunInPlace() noexcept#
No input tensor to alias with: in-place semantics are not relevant.
Public Static Attributes
-
static constexpr int64_t kNoSeed = -1#
Sentinel meaning
seedattribute is absent.
-
Tensor operator()(const std::vector<int64_t> &shape, double mean = 0.0, double scale = 1.0, int64_t seed = kNoSeed, int32_t dtype = 0) const#
-
class RandomNormalLike : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_generator_kernels.h>
Reference implementation of the ONNX
RandomNormalLikeoperator (since opset 1 in theai.onnxdomain). Produces an output tensor whose shape matchesinputfilled with samples drawn from a normal distribution. Whendtypeis0the output dtype equals the input dtype (which must be one of the supported output dtypes); otherwise the value overrides the output dtype.Public Functions
-
Tensor operator()(const Tensor &input, double mean = 0.0, double scale = 1.0, int64_t seed = kNoSeed, int32_t dtype = 0) const#
-
void operator()(const Tensor &input, double mean, double scale, int64_t seed, int32_t dtype, Tensor &output) const#
-
inline explicit KernelBase(const KernelContext &ctx)#
Public Static Functions
-
static inline constexpr bool CanRunInPlace() noexcept#
Public Static Attributes
-
static constexpr int64_t kNoSeed = -1#
-
Tensor operator()(const Tensor &input, double mean = 0.0, double scale = 1.0, int64_t seed = kNoSeed, int32_t dtype = 0) const#
-
class RandomUniform : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_generator_kernels.h>
Reference implementation of the ONNX
RandomUniformoperator (since opset 1 in theai.onnxdomain). Produces an output tensor of the givenshapefilled with samples drawn uniformly from the half-open interval[low, high).Uses the deterministic :cpp:func:
Randhelper (SplitMix64). Supported output dtypes areFLOAT(default) andDOUBLE; any other value ofdtypetriggersstd::invalid_argument.Public Functions
-
Tensor operator()(const std::vector<int64_t> &shape, double low = 0.0, double high = 1.0, int64_t seed = kNoSeed, int32_t dtype = 0) const#
Produces a
shape-shaped tensor of uniform samples in[low, high).lowdefaults to0.0andhighto1.0to mirror the schema.dtypedefaults toDataType::FLOAT.seedselects the RNG seed; passkNoSeedto use the kernel’s default.
-
void operator()(const std::vector<int64_t> &shape, double low, double high, int64_t seed, int32_t dtype, Tensor &output) const#
-
inline explicit KernelBase(const KernelContext &ctx)#
Public Static Functions
-
static inline constexpr bool CanRunInPlace() noexcept#
Public Static Attributes
-
static constexpr int64_t kNoSeed = -1#
Sentinel meaning
seedattribute is absent.
-
Tensor operator()(const std::vector<int64_t> &shape, double low = 0.0, double high = 1.0, int64_t seed = kNoSeed, int32_t dtype = 0) const#
-
class RandomUniformLike : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_generator_kernels.h>
Reference implementation of the ONNX
RandomUniformLikeoperator (since opset 1 in theai.onnxdomain). Same semantics as :cpp:class:RandomUniformbut the output shape is copied frominput.Public Functions
-
Tensor operator()(const Tensor &input, double low = 0.0, double high = 1.0, int64_t seed = kNoSeed, int32_t dtype = 0) const#
-
void operator()(const Tensor &input, double low, double high, int64_t seed, int32_t dtype, Tensor &output) const#
-
inline explicit KernelBase(const KernelContext &ctx)#
Public Static Functions
-
static inline constexpr bool CanRunInPlace() noexcept#
Public Static Attributes
-
static constexpr int64_t kNoSeed = -1#
-
Tensor operator()(const Tensor &input, double low = 0.0, double high = 1.0, int64_t seed = kNoSeed, int32_t dtype = 0) const#
-
class Range : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_generator_kernels.h>
Reference implementation of the ONNX
Rangeoperator (since opset 11 in theai.onnxdomain, with opset 27 widening the supported types to includeFLOAT16/BFLOAT16). Generates a 1-D tensor with values[start, start + delta, start + 2*delta, ...]up to (but excluding)limit.The three inputs
start,limitanddeltamust all be scalar tensors of the same element type. Supported element types areFLOAT,DOUBLE,INT16,INT32,INT64,FLOAT16andBFLOAT16(matching the upstreamRangeschema’sTtype-constraint at opset 27). ForFLOAT16andBFLOAT16the loop accumulator runs infloat(thestash_type = 1default introduced at opset 27).The number of output elements is
max(ceil((limit - start) / delta), 0). When the result would be empty (e.g.start >= limitwith a positivedelta), the kernel returns an empty 1-D tensor of length 0.Public Functions
-
void operator()(const Tensor &start, const Tensor &limit, const Tensor &delta, Tensor &output) const#
-
inline explicit KernelBase(const KernelContext &ctx)#
Public Static Functions
-
static inline constexpr bool CanRunInPlace() noexcept#
The output buffer has a different size than the inputs, so storage cannot be shared.
-
void operator()(const Tensor &start, const Tensor &limit, const Tensor &delta, Tensor &output) const#
-
class Bernoulli : public onnx_light::onnx_kernels::kernel::KernelBase#
-
namespace kernel
-
namespace onnx_kernels