Sign#

Sign - 13#

Version

  • name: Sign (GitHub)

  • domain: main

  • since_version: 13

  • function: False

  • support_level: SupportType.COMMON

  • shape inference: True

This version of the operator has been available since version 13.

Summary

Calculate the sign of the given input tensor element-wise. If input > 0, output 1. if input < 0, output -1. if input == 0, output 0.

Inputs

  • input (heterogeneous) - T: Input tensor

Outputs

  • output (heterogeneous) - T: The sign of the input tensor computed element-wise. It has the same shape and type of the input.

Type Constraints

  • T in ( tensor(bfloat16), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8) ): Constrain input and output types to all numeric tensors.

Examples

default

node = onnx.helper.make_node(
    'Sign',
    inputs=['x'],
    outputs=['y'],
)

x = np.array(range(-5, 6)).astype(np.float32)
y = np.sign(x)
expect(node, inputs=[x], outputs=[y],
       name='test_sign')

Differences

00Calculate the sign of the given input tensor element-wise.Calculate the sign of the given input tensor element-wise.
11If input > 0, output 1. if input < 0, output -1. if input == 0, output 0.If input > 0, output 1. if input < 0, output -1. if input == 0, output 0.
22
33**Inputs****Inputs**
44
55* **input** (heterogeneous) - **T**:* **input** (heterogeneous) - **T**:
66 Input tensor Input tensor
77
88**Outputs****Outputs**
99
1010* **output** (heterogeneous) - **T**:* **output** (heterogeneous) - **T**:
1111 The sign of the input tensor computed element-wise. It has the same The sign of the input tensor computed element-wise. It has the same
1212 shape and type of the input. shape and type of the input.
1313
1414**Type Constraints****Type Constraints**
1515
1616* **T** in (* **T** in (
17 tensor(bfloat16),
1718 tensor(double), tensor(double),
1819 tensor(float), tensor(float),
1920 tensor(float16), tensor(float16),
2021 tensor(int16), tensor(int16),
2122 tensor(int32), tensor(int32),
2223 tensor(int64), tensor(int64),
2324 tensor(int8), tensor(int8),
2425 tensor(uint16), tensor(uint16),
2526 tensor(uint32), tensor(uint32),
2627 tensor(uint64), tensor(uint64),
2728 tensor(uint8) tensor(uint8)
2829 ): ):
2930 Constrain input and output types to all numeric tensors. Constrain input and output types to all numeric tensors.

Sign - 9#

Version

  • name: Sign (GitHub)

  • domain: main

  • since_version: 9

  • function: False

  • support_level: SupportType.COMMON

  • shape inference: True

This version of the operator has been available since version 9.

Summary

Calculate the sign of the given input tensor element-wise. If input > 0, output 1. if input < 0, output -1. if input == 0, output 0.

Inputs

  • input (heterogeneous) - T: Input tensor

Outputs

  • output (heterogeneous) - T: The sign of the input tensor computed element-wise. It has the same shape and type of the input.

Type Constraints

  • T in ( tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8) ): Constrain input and output types to all numeric tensors.