Relu#

  • Domain: ai.onnx

  • Since version: 14

Relu takes one input data (Tensor ) and produces one output data (Tensor ) where the rectified linear function, y = max(0, x), is applied to the tensor elementwise.

Inputs

  • X (T): Input tensor

Outputs

  • Y (T): Output tensor

Type Constraints

  • T: Constrain input and output types to signed numeric tensors. Allowed types: tensor(bfloat16), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8).

Examples#

test_cc_relu

Node:
  Relu(X) -> (Y)
Inputs:
  X: shape=(2, 3), dtype=float32
    [[-3., -1.,  0.],
     [ 1.,  2.,  3.]]

Outputs:
  Y: shape=(2, 3), dtype=float32
    [[0., 0., 0.],
     [1., 2., 3.]]

test_cc_relu_bfloat16

Node:
  Relu(X) -> (Y)
Inputs:
  X: shape=(2, 3), dtype=bfloat16
    [[-2, -0.5, 0],
     [0.5, 1.5, 3]]

Outputs:
  Y: shape=(2, 3), dtype=bfloat16
    [[0, 0, 0],
     [0.5, 1.5, 3]]

test_cc_relu_double

Node:
  Relu(x) -> (y)
Inputs:
  x: shape=(2, 3), dtype=float64
    [[-2. , -0.5,  0. ],
     [ 0.5,  1.5,  3. ]]

Outputs:
  y: shape=(2, 3), dtype=float64
    [[0. , 0. , 0. ],
     [0.5, 1.5, 3. ]]

test_cc_relu_example

Node:
  Relu(X) -> (Y)
Inputs:
  X: shape=(3, 4, 5), dtype=float32
    [[[-1., -1., -1., -1., -1.],
      [-1., -1., -1., -1., -1.],
      [-1., -1., -1., -1., -1.],
      [-1., -1., -1., -1., -1.]],

     [[-1., -1., -1., -1., -1.],
      [-1., -1., -1., -1., -1.],
      [-1., -1., -1., -1., -1.],
      [-1., -1., -1., -1., -1.]],

     [[-1., -1., -1., -1., -1.],
      [-1., -1., -1., -1., -1.],
      [-1., -1., -1., -1., -1.],
      [-1., -1., -1., -1., -1.]]]

Outputs:
  Y: shape=(3, 4, 5), dtype=float32
    [[[0., 0., 0., 0., 0.],
      [0., 0., 0., 0., 0.],
      [0., 0., 0., 0., 0.],
      [0., 0., 0., 0., 0.]],

     [[0., 0., 0., 0., 0.],
      [0., 0., 0., 0., 0.],
      [0., 0., 0., 0., 0.],
      [0., 0., 0., 0., 0.]],

     [[0., 0., 0., 0., 0.],
      [0., 0., 0., 0., 0.],
      [0., 0., 0., 0., 0.],
      [0., 0., 0., 0., 0.]]]

test_cc_relu_float16

Node:
  Relu(X) -> (Y)
Inputs:
  X: shape=(2, 3), dtype=float16
    [[-3., -1.,  0.],
     [ 1.,  2.,  3.]]

Outputs:
  Y: shape=(2, 3), dtype=float16
    [[0., 0., 0.],
     [1., 2., 3.]]

test_cc_relu_int16

Node:
  Relu(x) -> (y)
Inputs:
  x: shape=(2, 3), dtype=int16
    [[-500,   -1,    0],
     [   1,  300, 1000]]

Outputs:
  y: shape=(2, 3), dtype=int16
    [[   0,    0,    0],
     [   1,  300, 1000]]

test_cc_relu_int32

Node:
  Relu(x) -> (y)
Inputs:
  x: shape=(2, 3), dtype=int32
    [[-100000,      -1,       0],
     [      1,      42,  100000]]

Outputs:
  y: shape=(2, 3), dtype=int32
    [[     0,      0,      0],
     [     1,     42, 100000]]

test_cc_relu_int64

Node:
  Relu(x) -> (y)
Inputs:
  x: shape=(2, 3), dtype=int64
    [[-1000000000000,             -1,              0],
     [             1,             42,  1000000000000]]

Outputs:
  y: shape=(2, 3), dtype=int64
    [[            0,             0,             0],
     [            1,            42, 1000000000000]]

test_cc_relu_int8

Node:
  Relu(x) -> (y)
Inputs:
  x: shape=(2, 3), dtype=int8
    [[ -5,  -1,   0],
     [  1,   3, 127]]

Outputs:
  y: shape=(2, 3), dtype=int8
    [[  0,   0,   0],
     [  1,   3, 127]]

Differences with previous version (13)#

SchemaDiff: Relu (domain 'ai.onnx')

  • old version: 13

  • new version: 14

  • breaking: no

Type constraints:

  • changed ‘T’: added types: [‘tensor(int16)’, ‘tensor(int32)’, ‘tensor(int64)’, ‘tensor(int8)’]

Version History#