Clip - version 12#
This page documents version 12 of operator Clip. See Clip for the latest version (since version 13).
Domain:
ai.onnxSince version: 12
Clip operator limits the given input within an interval. The interval is specified by the inputs ‘min’ and ‘max’. They default to numeric_limits::lowest() and numeric_limits::max(), respectively.
Inputs
input (T): Input tensor whose elements to be clipped
min (T): Minimum value, under which element is replaced by min. It must be a scalar(tensor of empty shape).
max (T): Maximum value, above which element is replaced by max. It must be a scalar(tensor of empty shape).
Outputs
output (T): Output tensor with clipped input elements
Type Constraints
T: Constrain input and output types to all numeric tensors. Allowed types: tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8).
Examples#
test_clip_default_int8_inbounds
Node:
Clip(x) -> (y)
Inputs:
x: shape=(3,), dtype=int8
[-1, 0, 1]
Outputs:
y: shape=(3,), dtype=int8
[-1, 0, 1]
test_clip_default_int8_max
Node:
Clip(x, "", max) -> (y)
Inputs:
x: shape=(3, 4, 5), dtype=int8
[[[ 0, 1, 0, 0, 0],
[ 0, -2, 1, 0, 0],
[ 0, 0, -1, 0, 1],
[ 1, 0, 0, 1, 0]],
[[ 1, -1, 0, 0, 0],
[-1, 0, -1, 0, -1],
[ 0, 0, -1, -2, 0],
[ 1, 0, -1, 0, -1]],
[[-2, -1, 0, 0, 1],
[ 0, 1, 0, 1, 0],
[ 0, 1, -1, 0, -1],
[ 0, 1, -1, -1, 0]]]
max: shape=(), dtype=int8
0
Outputs:
y: shape=(3, 4, 5), dtype=int8
[[[ 0, 0, 0, 0, 0],
[ 0, -2, 0, 0, 0],
[ 0, 0, -1, 0, 0],
[ 0, 0, 0, 0, 0]],
[[ 0, -1, 0, 0, 0],
[-1, 0, -1, 0, -1],
[ 0, 0, -1, -2, 0],
[ 0, 0, -1, 0, -1]],
[[-2, -1, 0, 0, 0],
[ 0, 0, 0, 0, 0],
[ 0, 0, -1, 0, -1],
[ 0, 0, -1, -1, 0]]]
test_clip_default_int8_min
Node:
Clip(x, min) -> (y)
Inputs:
x: shape=(3, 4, 5), dtype=int8
[[[ 1, 0, 1, 0, 0],
[-1, 0, 0, 0, 0],
[-1, 0, 0, 0, 1],
[ 0, -2, 0, 0, 0]],
[[ 0, 1, 1, 0, 0],
[ 0, 0, 1, 0, 0],
[ 0, 0, -1, 0, 1],
[ 0, 1, -1, 0, 1]],
[[ 1, 0, 0, 1, 0],
[ 0, 0, -1, 1, 1],
[ 0, -2, 0, 0, 0],
[ 0, 0, 1, 1, 0]]]
min: shape=(), dtype=int8
0
Outputs:
y: shape=(3, 4, 5), dtype=int8
[[[1, 0, 1, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 1],
[0, 0, 0, 0, 0]],
[[0, 1, 1, 0, 0],
[0, 0, 1, 0, 0],
[0, 0, 0, 0, 1],
[0, 1, 0, 0, 1]],
[[1, 0, 0, 1, 0],
[0, 0, 0, 1, 1],
[0, 0, 0, 0, 0],
[0, 0, 1, 1, 0]]]
Differences with previous version (11)#
SchemaDiff: Clip (domain 'ai.onnx')
old version: 11
new version: 12
breaking: no
Type constraints:
changed ‘T’: added types: [‘tensor(int16)’, ‘tensor(int32)’, ‘tensor(int64)’, ‘tensor(int8)’, ‘tensor(uint16)’, ‘tensor(uint32)’, ‘tensor(uint64)’, ‘tensor(uint8)’]