Abs#
Domain:
ai.onnxSince version: 13
Absolute takes one input data (Tensor ) and produces one output data (Tensor ) where absolute value, y = abs(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 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_abs
Node:
Abs(x) -> (y)
Inputs:
x: shape=(3, 4, 5), dtype=float32
[[[-0.846573 , 1.2833743 , 0.7443729 , -0.53892165, -0.18734488],
[ 0.12178429, -2.0982637 , 1.5225194 , 0.8434675 , 0.33549327],
[ 0.09154005, 0.84206796, -1.6517702 , -0.6042637 , 1.0845611 ],
[ 1.5201056 , 0.99814653, -0.17626205, 1.6406455 , 0.7513234 ]],
[[ 1.7203773 , -1.0786597 , 0.17007604, 0.51496613, 0.2197246 ],
[-1.1963571 , 0.40040365, -1.2112149 , -0.33787218, -1.3460412 ],
[ 0.7294753 , 0.6825587 , -1.2590255 , -2.3378267 , -0.7833349 ],
[ 1.8637013 , -0.9699887 , -1.1392695 , -0.08200161, -1.0864431 ]],
[[-2.0017872 , -1.6769867 , 0.01457232, 0.58369064, 1.4740808 ],
[ 0.33742025, 1.0194283 , -0.9550304 , 1.0498446 , -0.16838181],
[ 0.04257414, 1.3051497 , -1.2076538 , -0.4271947 , -1.4134941 ],
[ 0.7686854 , 1.2206558 , -1.1196595 , -1.1292622 , -0.41522065]]]
Outputs:
y: shape=(3, 4, 5), dtype=float32
[[[0.846573 , 1.2833743 , 0.7443729 , 0.53892165, 0.18734488],
[0.12178429, 2.0982637 , 1.5225194 , 0.8434675 , 0.33549327],
[0.09154005, 0.84206796, 1.6517702 , 0.6042637 , 1.0845611 ],
[1.5201056 , 0.99814653, 0.17626205, 1.6406455 , 0.7513234 ]],
[[1.7203773 , 1.0786597 , 0.17007604, 0.51496613, 0.2197246 ],
[1.1963571 , 0.40040365, 1.2112149 , 0.33787218, 1.3460412 ],
[0.7294753 , 0.6825587 , 1.2590255 , 2.3378267 , 0.7833349 ],
[1.8637013 , 0.9699887 , 1.1392695 , 0.08200161, 1.0864431 ]],
[[2.0017872 , 1.6769867 , 0.01457232, 0.58369064, 1.4740808 ],
[0.33742025, 1.0194283 , 0.9550304 , 1.0498446 , 0.16838181],
[0.04257414, 1.3051497 , 1.2076538 , 0.4271947 , 1.4134941 ],
[0.7686854 , 1.2206558 , 1.1196595 , 1.1292622 , 0.41522065]]]
test_cc_abs
Node:
Abs(x) -> (y)
Inputs:
x: shape=(2, 3), dtype=float32
[[-1. , 0. , 1.5 ],
[-2.25, 3.5 , -4.75]]
Outputs:
y: shape=(2, 3), dtype=float32
[[1. , 0. , 1.5 ],
[2.25, 3.5 , 4.75]]
test_cc_abs_bfloat16
Node:
Abs(x) -> (y)
Inputs:
x: shape=(2, 3), dtype=bfloat16
[[-1, 0, 1.5],
[-2.25, 3.5, -4.75]]
Outputs:
y: shape=(2, 3), dtype=bfloat16
[[1, 0, 1.5],
[2.25, 3.5, 4.75]]
test_cc_abs_double
Node:
Abs(x) -> (y)
Inputs:
x: shape=(2, 3), dtype=float64
[[-1. , 0. , 1.5 ],
[-2.25, 3.5 , -4.75]]
Outputs:
y: shape=(2, 3), dtype=float64
[[1. , 0. , 1.5 ],
[2.25, 3.5 , 4.75]]
test_cc_abs_float16
Node:
Abs(x) -> (y)
Inputs:
x: shape=(2, 3), dtype=float16
[[-1. , 0. , 1.5 ],
[-2.25, 3.5 , -4.75]]
Outputs:
y: shape=(2, 3), dtype=float16
[[1. , 0. , 1.5 ],
[2.25, 3.5 , 4.75]]
test_cc_abs_int16
Node:
Abs(x) -> (y)
Inputs:
x: shape=(2, 3), dtype=int16
[[ -1, 0, 2],
[-1000, 3, -5]]
Outputs:
y: shape=(2, 3), dtype=int16
[[ 1, 0, 2],
[1000, 3, 5]]
test_cc_abs_int32
Node:
Abs(x) -> (y)
Inputs:
x: shape=(2, 3), dtype=int32
[[ -1, 0, 2],
[-100000, 3, -5]]
Outputs:
y: shape=(2, 3), dtype=int32
[[ 1, 0, 2],
[100000, 3, 5]]
test_cc_abs_int64
Node:
Abs(x) -> (y)
Inputs:
x: shape=(2, 3), dtype=int64
[[ -1, 0, 2],
[-1000000000000, 3, -5]]
Outputs:
y: shape=(2, 3), dtype=int64
[[ 1, 0, 2],
[1000000000000, 3, 5]]
test_cc_abs_int8
Node:
Abs(x) -> (y)
Inputs:
x: shape=(2, 3), dtype=int8
[[ -1, 0, 2],
[-127, 3, -5]]
Outputs:
y: shape=(2, 3), dtype=int8
[[ 1, 0, 2],
[127, 3, 5]]
test_cc_shape_inference_if_symbolic_shapes
Node:
Abs(I1) -> (Y1)
Inputs:
I1: shape=(), dtype=bool
True
input_1: shape=(3, 4), dtype=float32
[[1. , 1.1 , 1.2 , 1.3 ],
[1.4 , 1.5 , 1.6 , 1.7 ],
[1.8 , 1.9000001, 2. , 2.1 ]]
input_2: shape=(5, 4), dtype=float32
[[-1. , -0.9 , -0.8 , -0.7 ],
[-0.6 , -0.5 , -0.39999998, -0.3 ],
[-0.19999999, -0.09999996, 0. , 0.10000002],
[ 0.20000005, 0.30000007, 0.39999998, 0.5 ],
[ 0.6 , 0.70000005, 0.8000001 , 0.9 ]]
input_3: shape=(5,), dtype=bool
[ True, False, True, False, True]
input_4: shape=(3,), dtype=int64
[1, 2, 3]
input_5: shape=(5,), dtype=int64
[-1, -2, -3, -4, -5]
Outputs:
Y1: shape=(3, 4), dtype=float32
[[1. , 1.1 , 1.2 , 1.3 ],
[1.4 , 1.5 , 1.6 , 1.7 ],
[1.8 , 1.9000001, 2. , 2.1 ]]
output_1: shape=(3,), dtype=int64
[-1, -2, -3]
test_cc_shape_inference_slice_symbolic_end
Node:
Abs(sliced) -> (Y)
Inputs:
sliced: shape=(2, 3, 4), dtype=float32
[[[ 1., 2., 3., 4.],
[ 5., 6., 7., 8.],
[ 9., 10., 11., 12.]],
[[13., 14., 15., 16.],
[17., 18., 19., 20.],
[21., 22., 23., 24.]]]
Outputs:
Y: shape=(2, 3, 3), dtype=float32
[[[ 1., 2., 3.],
[ 5., 6., 7.],
[ 9., 10., 11.]],
[[13., 14., 15.],
[17., 18., 19.],
[21., 22., 23.]]]
Differences with previous version (6)#
SchemaDiff: Abs (domain 'ai.onnx')
old version: 6
new version: 13
breaking: no
Type constraints:
changed ‘T’: added types: [‘tensor(bfloat16)’]