Skip to main content

ClikaRT::ops::count_nonzero

function

count_nonzero()

Tensor count_nonzero(Tensor x, ClikaRT::Span<const std::int64_t> dims = {})

Number of nonzero elements over dims.

Empty dims counts across the whole tensor. Output dtype is always Int64.

Parameters

  • x: the input tensor; any dtype.
  • dims: axes to reduce; empty = all axes.

Returns: Int64 counts; shape = x minus dims.

Throws

  • ClikaRT::Error: (INVALID_ARGUMENT) on an out-of-range dims entry.

Declared in ClikaRT/compute/ops.h, line 4258