ClikaRT::ops::sum
function
sum()
Tensor sum(
Tensor x,
ClikaRT::Span<const std::int64_t> dims = {},
bool keepdim = false,
DataType dtype = DataType::Undefined
)
Sums x over dims.
Empty dims reduces EVERY dimension (a 0-D result unless keepdim). Integer inputs accumulate and return at their own dtype unless dtype widens them explicitly.
Parameters
x: the input tensor; any arithmetic dtype.dims: axes to reduce; empty = all axes.keepdim: keep reduced axes as size-1 dims; default false.dtype: output/accumulator dtype;DataType::Undefined(the default) keepsx's dtype.
Returns: the reduced tensor; shape = x minus dims (or size-1 there under keepdim).
Throws
ClikaRT::Error: (INVALID_ARGUMENT) when adimsentry is out of range forx's rank, ordtypecannot represent the sum.
auto row_totals = ClikaRT::ops::sum(x, {-1}); // [.., N] -> [..]
auto grand = ClikaRT::ops::sum(x); // 0-D total
Declared in ClikaRT/compute/ops.h, line 4446