elementwise_helpers.h#
-
namespace ONNX_LIGHT_NAMESPACE
-
namespace onnx_backend_test
-
namespace kernel#
-
namespace detail#
Functions
-
BroadcastInfo CheckBinaryBroadcast(const char *op_name, const char *dtype_name, int32_t expected_dtype, const Tensor &x, const Tensor &y)#
Verifies both inputs have
expected_dtypeand that their shapes are multidirectional-broadcastable per the standard NumPy/ONNX rules. Throwsstd::invalid_argumentotherwise.
-
BroadcastInfo CheckBinaryBroadcastInOut(const char *op_name, const char *in_dtype_name, int32_t expected_in_dtype, const Tensor &x, const Tensor &y)#
Variant of :cpp:func:
CheckBinaryBroadcastfor kernels whose input and output dtypes differ (e.g.Greater/Lesstake numeric inputs and returnBOOLoutputs). Validates that both inputs haveexpected_in_dtypeand computes the broadcast info; the caller is responsible for validating the output against its own dtype.
-
void CheckPreallocatedOutput(const char *op_name, const char *dtype_name, int32_t expected_dtype, const std::vector<int64_t> &expected_shape, size_t expected_bytes, const Tensor &output)#
Verifies the caller-supplied preallocated output tensor matches the expected dtype, shape and byte buffer size.
-
template<typename TIn, typename TOut, typename Op>
void BinaryElementwise(const char *op_name, const char *dtype_name, int32_t expected_dtype, const Tensor &x, const Tensor &y, Tensor &output, Op op)# In-place element-wise binary kernel driver. Validates inputs + output then invokes
op(a, b) -> TOutfor each element pair, with full multidirectional broadcasting.TInandTOutmust match the byte layout of theexpected_dtype.
-
template<typename TIn, typename TOut, typename Op>
Tensor BinaryElementwiseAlloc(const char *op_name, const char *dtype_name, int32_t expected_dtype, const Tensor &x, const Tensor &y, Op op)# Allocating element-wise binary kernel driver. Builds the output tensor with the broadcasted shape and
expected_dtype, then delegates to :cpp:func:BinaryElementwiseto fill it in.
-
template<typename TIn, typename TOut, typename Op>
void BinaryElementwiseInOut(const char *op_name, const char *in_dtype_name, int32_t in_dtype, const char *out_dtype_name, int32_t out_dtype, const Tensor &x, const Tensor &y, Tensor &output, Op op)# Variant of :cpp:func:
BinaryElementwisefor kernels whose input and output dtypes differ (e.g.Greater/Less). Validates that both inputs havein_dtypeand that the preallocated output hasout_dtypeand the broadcasted shape, then invokesop(a, b) -> TOutfor each element pair with full multidirectional broadcasting.
-
template<typename TIn, typename TOut, typename Op>
Tensor BinaryElementwiseAllocInOut(const char *op_name, const char *in_dtype_name, int32_t in_dtype, const char *out_dtype_name, int32_t out_dtype, const Tensor &x, const Tensor &y, Op op)# Allocating variant of :cpp:func:
BinaryElementwiseInOut. Builds the output tensor with the broadcasted shape andout_dtype, then delegates to :cpp:func:BinaryElementwiseInOutto fill it in.
-
struct BroadcastInfo#
- #include <elementwise_helpers.h>
Information about a validated binary broadcast: the output shape, total element count, the individual input element counts, and per-input element-strides aligned to the output rank (a stride of 0 marks a broadcast dimension). The rank-aligned
shape_x/shape_yare also reported for diagnostics.nx/nyare kept for fast-path detection (equal-shape or scalar broadcasting).
-
BroadcastInfo CheckBinaryBroadcast(const char *op_name, const char *dtype_name, int32_t expected_dtype, const Tensor &x, const Tensor &y)#
-
namespace detail#
-
namespace kernel#
-
namespace onnx_backend_test