Sign#
Domain:
ai.onnxSince version: 13
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 (T): Input tensor
Outputs
output (T): The sign of the input tensor computed element-wise. It has the same shape and type of the input.
Type Constraints
T: Constrain input and output types to all numeric tensors. Allowed types: tensor(bfloat16), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8).
Examples#
test_cc_sign
Node:
Sign(x) -> (y)
Inputs:
x: shape=(2, 3), dtype=float32
[[-2.5 , -1. , 0. ],
[ 0.5 , 1. , 3.25]]
Outputs:
y: shape=(2, 3), dtype=float32
[[-1., -1., 0.],
[ 1., 1., 1.]]
test_cc_sign_bfloat16
Node:
Sign(x) -> (y)
Inputs:
x: shape=(2, 3), dtype=bfloat16
[[-3, -0.5, 0],
[0.5, 2, -1]]
Outputs:
y: shape=(2, 3), dtype=bfloat16
[[-1, -1, 0],
[1, 1, -1]]
test_cc_sign_float16
Node:
Sign(x) -> (y)
Inputs:
x: shape=(2, 3), dtype=float16
[[-3. , -0.5, 0. ],
[ 0.5, 2. , -1. ]]
Outputs:
y: shape=(2, 3), dtype=float16
[[-1., -1., 0.],
[ 1., 1., -1.]]
test_cc_sign_int16
Node:
Sign(x) -> (y)
Inputs:
x: shape=(2, 3), dtype=int16
[[ -1, 0, 2],
[-1000, 3, -5]]
Outputs:
y: shape=(2, 3), dtype=int16
[[-1, 0, 1],
[-1, 1, -1]]
test_cc_sign_int32
Node:
Sign(x) -> (y)
Inputs:
x: shape=(2, 3), dtype=int32
[[ -1, 0, 2],
[-100000, 3, -5]]
Outputs:
y: shape=(2, 3), dtype=int32
[[-1, 0, 1],
[-1, 1, -1]]
test_cc_sign_int64
Node:
Sign(x) -> (y)
Inputs:
x: shape=(2, 3), dtype=int64
[[ -1, 0, 2],
[-1000000000000, 3, -5]]
Outputs:
y: shape=(2, 3), dtype=int64
[[-1, 0, 1],
[-1, 1, -1]]
test_cc_sign_int8
Node:
Sign(x) -> (y)
Inputs:
x: shape=(2, 3), dtype=int8
[[ -1, 0, 2],
[-127, 3, -5]]
Outputs:
y: shape=(2, 3), dtype=int8
[[-1, 0, 1],
[-1, 1, -1]]
test_cc_sign_uint16
Node:
Sign(x) -> (y)
Inputs:
x: shape=(2, 3), dtype=uint16
[[ 0, 1, 1000],
[ 0, 5, 65535]]
Outputs:
y: shape=(2, 3), dtype=uint16
[[0, 1, 1],
[0, 1, 1]]
test_cc_sign_uint32
Node:
Sign(x) -> (y)
Inputs:
x: shape=(2, 3), dtype=uint32
[[ 0, 1, 1000000],
[ 0, 5, 4294967295]]
Outputs:
y: shape=(2, 3), dtype=uint32
[[0, 1, 1],
[0, 1, 1]]
test_cc_sign_uint64
Node:
Sign(x) -> (y)
Inputs:
x: shape=(2, 3), dtype=uint64
[[ 0, 1, 1000000000000],
[ 0, 5, 18446744073709551615]]
Outputs:
y: shape=(2, 3), dtype=uint64
[[0, 1, 1],
[0, 1, 1]]
test_cc_sign_uint8
Node:
Sign(x) -> (y)
Inputs:
x: shape=(2, 3), dtype=uint8
[[ 0, 1, 2],
[ 0, 5, 255]]
Outputs:
y: shape=(2, 3), dtype=uint8
[[0, 1, 1],
[0, 1, 1]]
test_sign
Node:
Sign(x) -> (y)
Inputs:
x: shape=(11,), dtype=float32
[-5., -4., -3., -2., -1., 0., 1., 2., 3., 4., 5.]
Outputs:
y: shape=(11,), dtype=float32
[-1., -1., -1., -1., -1., 0., 1., 1., 1., 1., 1.]
Differences with previous version (9)#
SchemaDiff: Sign (domain 'ai.onnx')
old version: 9
new version: 13
breaking: no
Type constraints:
changed ‘T’: added types: [‘tensor(bfloat16)’]