NonzeroOperation

Description

Outputs a non-zero index.

Definition

struct NonzeroParam {
    uint8_t rsv[8] = {0};
};

Parameters

Member

Type

Default Value

Description

rsv[8]

uint8_t

{0}

Reserved

Input

Parameter

Dimension

Data Type

Format

Description

x

[-1,...,-1]

The value -1 indicates that the size of the current dimension is not restricted.

int64

ND

Input tensor.

Output

Parameter

Dimension

Data Type

Format

Description

output1

[inputDimNum, inputNumel]

int64

ND

Index of a non-zero element.

output2

[1]

int64

ND

Number of non-zero elements.

Restrictions

Supported only on the Atlas A2 inference products.

API Calling Example

  • One-dimensional scenario

    Input

    intensor = {[0, 1, 1, 0, 1]}

    Output

    outtensor1 = {0, 1, 2, 0, 4}outtensor2 = [3]
  • Two-dimensional scenario

    Input

    intensor = {[0, 1, 1, 0, 1]}

    Output

    outtensor1 = {0, 1, 2, 0, 4}outtensor2 = [3]