pub struct INonZeroLayer { /* private fields */ }Expand description
INonZero
A NonZero layer in a network.
This layer gets the positions of elements that are non-zero in the input. For boolean input, “non-zero” means “true”. Semantics are similar to ONNX NonZero.
The input may have type kFLOAT, kHALF, kINT32, or kBOOL.
The output is a matrix of type kINT32 or kINT64. For an input with dimensions [L1, L2, …, Lm], the output has dimensions [m,n], where n is the number of non-zero elements. I.e., each column denotes a m-D position.
The columns are lexically ordered. E.g., a column with [3,2,4,7] precedes a column with [3,2,5,6].
Tip: “compress” can be implemented with INonZero+IShuffle+Gather. For example, to compress a tensor x over axis k using mask vector v, use nonzero(v) to compute the subscripts, shuffle with reshape dimensions = [-1] to make the subscripts 1D, and then gather with the subscripts.
Implementations§
Source§impl INonZeroLayer
impl INonZeroLayer
Sourcepub fn setIndicesType(self: Pin<&mut INonZeroLayer>, type_: DataType) -> bool
pub fn setIndicesType(self: Pin<&mut INonZeroLayer>, type_: DataType) -> bool
Set the indices type for the layer.
typeThe DataType of the indices tensor.
true if set successfully, false otherwise.
Set the indices (the first output) type of the NonZero layer. Valid values are DataType::kINT32 and DataType::kINT64, otherwise an error occurs and the type is not updated.
Sourcepub fn getIndicesType(self: &INonZeroLayer) -> DataType
pub fn getIndicesType(self: &INonZeroLayer) -> DataType
Return the NonZero layer indices type.
indices type set during layer creation or by setIndicesType(). The return value is the indices type of the NonZero layer. The default value is DataType::kINT32.