include_traditionalml_kernels.h#

namespace ONNX_LIGHT_NAMESPACE
namespace onnx_backend_test
namespace kernel
class Binarizer#
#include <include_traditionalml_kernels.h>

Reference implementation of the ai.onnx.ml Binarizer operator (since opset 1 in the ai.onnx.ml domain).

For every input element x[i], the output element y[i] is 1 if x[i] > threshold and 0 otherwise. The output tensor has the same shape and element type as the input.

The kernel supports the four numeric element types listed in the ONNX schema via explicit template instantiations:

  • float

  • double

  • int64_t

  • int32_t

The in-place overload throws std::invalid_argument if the preallocated output’s dtype/shape/byte size do not match the input’s.

Public Functions

inline explicit Binarizer(const KernelContext &ctx)#
template<typename T>
Tensor operator()(const Tensor &x, T threshold) const#
template<typename T>
void operator()(const Tensor &x, T threshold, Tensor &output) const#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Private Members

KernelContext ctx_#
class LabelEncoder#
#include <include_traditionalml_kernels.h>

Maps each element of the input tensor through a pair of parallel keys/values arrays — the reference behaviour of the ai.onnx.ml LabelEncoder operator (since opset 4 in the ai.onnx.ml domain).

For every input element x[i], the output element y[i] is values[k] where k is the index of the first keys[k] that matches x[i]; if no key matches, y[i] is default_value.

The output tensor has the same shape as the input tensor. The kernel supports the following (KeyT, ValueT) element-type combinations via explicit template instantiations:

  • (int64_t, int64_t)

  • (int64_t, float)

  • (float, int64_t)

  • (float, float)

keys.size() must match values.size(). The kernel throws std::invalid_argument if the input element type does not match KeyT or, for the in-place overload, if the preallocated output’s type/shape do not match the resolved value type and the input shape.

Public Functions

inline explicit LabelEncoder(const KernelContext &ctx)#
template<typename KeyT, typename ValueT>
Tensor operator()(const Tensor &x, const std::vector<KeyT> &keys, const std::vector<ValueT> &values, ValueT default_value) const#
template<typename KeyT, typename ValueT>
void operator()(const Tensor &x, const std::vector<KeyT> &keys, const std::vector<ValueT> &values, ValueT default_value, Tensor &output) const#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Private Members

KernelContext ctx_#