Skip to main content

INonZeroLayer

Struct INonZeroLayer 

Source
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

Source

pub fn setIndicesType(self: Pin<&mut INonZeroLayer>, type_: DataType) -> bool

Set the indices type for the layer.

  • type The 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.

Source

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.

Trait Implementations§

Source§

impl AsLayer for INonZeroLayer

Source§

fn as_layer(&self) -> &ILayer

Source§

fn as_layer_pin_mut(&mut self) -> Pin<&mut ILayer>

Source§

impl AsLayerTyped for INonZeroLayer

Source§

const TYPE: LayerType = LayerType::kNON_ZERO

Source§

impl AsRef<ILayer> for INonZeroLayer

Source§

fn as_ref(self: &INonZeroLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl ExternType for INonZeroLayer

Source§

type Id = (n, v, i, n, f, e, r, _1, (), I, N, o, n, Z, e, r, o, L, a, y, e, r)

A type-level representation of the type’s C++ namespace and type name. Read more
Source§

type Kind = Opaque

Source§

impl MakeCppStorage for INonZeroLayer

Source§

unsafe fn allocate_uninitialized_cpp_storage() -> *mut INonZeroLayer

Allocates heap space for this type in C++ and return a pointer to that space, but do not initialize that space (i.e. do not yet call a constructor). Read more
Source§

unsafe fn free_uninitialized_cpp_storage(arg0: *mut INonZeroLayer)

Frees a C++ allocation which has not yet had a constructor called. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.