Clip#
Clip - 13#
Version
name: Clip (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
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
Between 1 and 3 inputs.
input (heterogeneous) - T: Input tensor whose elements to be clipped
min (optional, heterogeneous) - T: Minimum value, under which element is replaced by min. It must be a scalar(tensor of empty shape).
max (optional, heterogeneous) - T: Maximum value, above which element is replaced by max. It must be a scalar(tensor of empty shape).
Outputs
output (heterogeneous) - T: Output tensor with clipped input elements
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
clip_default
node = onnx.helper.make_node(
'Clip',
inputs=['x', 'min'],
outputs=['y'],
)
min_val = np.float32(0)
x = np.random.randn(3, 4, 5).astype(np.float32)
y = np.clip(x, min_val, np.inf)
expect(node, inputs=[x, min_val], outputs=[y],
name='test_clip_default_min')
no_min = "" # optional input, not supplied
node = onnx.helper.make_node(
'Clip',
inputs=['x', no_min, 'max'],
outputs=['y'],
)
max_val = np.float32(0)
x = np.random.randn(3, 4, 5).astype(np.float32)
y = np.clip(x, -np.inf, max_val)
expect(node, inputs=[x, max_val], outputs=[y],
name='test_clip_default_max')
no_max = "" # optional input, not supplied
node = onnx.helper.make_node(
'Clip',
inputs=['x', no_min, no_max],
outputs=['y'],
)
x = np.array([-1, 0, 1]).astype(np.float32)
y = np.array([-1, 0, 1]).astype(np.float32)
expect(node, inputs=[x], outputs=[y],
name='test_clip_default_inbounds')
clip_default_int8
node = onnx.helper.make_node(
'Clip',
inputs=['x', 'min'],
outputs=['y'],
)
min_val = np.int8(0)
x = np.random.randn(3, 4, 5).astype(np.int8)
y = np.clip(x, min_val, np.iinfo(np.int8).max)
expect(node, inputs=[x, min_val], outputs=[y],
name='test_clip_default_int8_min')
no_min = "" # optional input, not supplied
node = onnx.helper.make_node(
'Clip',
inputs=['x', no_min, 'max'],
outputs=['y'],
)
max_val = np.int8(0)
x = np.random.randn(3, 4, 5).astype(np.int8)
y = np.clip(x, np.iinfo(np.int8).min, max_val)
expect(node, inputs=[x, max_val], outputs=[y],
name='test_clip_default_int8_max')
no_max = "" # optional input, not supplied
node = onnx.helper.make_node(
'Clip',
inputs=['x', no_min, no_max],
outputs=['y'],
)
x = np.array([-1, 0, 1]).astype(np.int8)
y = np.array([-1, 0, 1]).astype(np.int8)
expect(node, inputs=[x], outputs=[y],
name='test_clip_default_int8_inbounds')
Differences
0 | 0 | Clip operator limits the given input within an interval. The interval is | Clip operator limits the given input within an interval. The interval is |
1 | 1 | specified by the inputs 'min' and 'max'. They default to | specified by the inputs 'min' and 'max'. They default to |
2 | 2 | numeric_limits::lowest() and numeric_limits::max(), respectively. | numeric_limits::lowest() and numeric_limits::max(), respectively. |
3 | 3 |
|
|
4 | 4 | **Inputs** | **Inputs** |
5 | 5 |
|
|
6 | 6 | Between 1 and 3 inputs. | Between 1 and 3 inputs. |
7 | 7 |
|
|
8 | 8 | * **input** (heterogeneous) - **T**: | * **input** (heterogeneous) - **T**: |
9 | 9 | Input tensor whose elements to be clipped | Input tensor whose elements to be clipped |
10 | 10 | * **min** (optional, heterogeneous) - **T**: | * **min** (optional, heterogeneous) - **T**: |
11 | 11 | Minimum value, under which element is replaced by min. It must be a | Minimum value, under which element is replaced by min. It must be a |
12 | 12 | scalar(tensor of empty shape). | scalar(tensor of empty shape). |
13 | 13 | * **max** (optional, heterogeneous) - **T**: | * **max** (optional, heterogeneous) - **T**: |
14 | 14 | Maximum value, above which element is replaced by max. It must be a | Maximum value, above which element is replaced by max. It must be a |
15 | 15 | scalar(tensor of empty shape). | scalar(tensor of empty shape). |
16 | 16 |
|
|
17 | 17 | **Outputs** | **Outputs** |
18 | 18 |
|
|
19 | 19 | * **output** (heterogeneous) - **T**: | * **output** (heterogeneous) - **T**: |
20 | 20 | Output tensor with clipped input elements | Output tensor with clipped input elements |
21 | 21 |
|
|
22 | 22 | **Type Constraints** | **Type Constraints** |
23 | 23 |
|
|
24 | 24 | * **T** in ( | * **T** in ( |
25 | tensor(bfloat16), | ||
25 | 26 | tensor(double), | tensor(double), |
26 | 27 | tensor(float), | tensor(float), |
27 | 28 | tensor(float16), | tensor(float16), |
28 | 29 | tensor(int16), | tensor(int16), |
29 | 30 | tensor(int32), | tensor(int32), |
30 | 31 | tensor(int64), | tensor(int64), |
31 | 32 | tensor(int8), | tensor(int8), |
32 | 33 | tensor(uint16), | tensor(uint16), |
33 | 34 | tensor(uint32), | tensor(uint32), |
34 | 35 | tensor(uint64), | tensor(uint64), |
35 | 36 | tensor(uint8) | tensor(uint8) |
36 | 37 | ): | ): |
37 | 38 | Constrain input and output types to all numeric tensors. | Constrain input and output types to all numeric tensors. |
Clip - 12#
Version
name: Clip (GitHub)
domain: main
since_version: 12
function: False
support_level: SupportType.COMMON
shape inference: True
This version of the operator has been available since version 12.
Summary
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
Between 1 and 3 inputs.
input (heterogeneous) - T: Input tensor whose elements to be clipped
min (optional, heterogeneous) - T: Minimum value, under which element is replaced by min. It must be a scalar(tensor of empty shape).
max (optional, heterogeneous) - T: Maximum value, above which element is replaced by max. It must be a scalar(tensor of empty shape).
Outputs
output (heterogeneous) - T: Output tensor with clipped input elements
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.
Differences
0 | 0 | Clip operator limits the given input within an interval. The interval is | Clip operator limits the given input within an interval. The interval is |
1 | 1 | specified by the inputs 'min' and 'max'. They default to | specified by the inputs 'min' and 'max'. They default to |
2 | 2 | numeric_limits::lowest() and numeric_limits::max(), respectively. | numeric_limits::lowest() and numeric_limits::max(), respectively. |
3 | 3 |
|
|
4 | 4 | **Inputs** | **Inputs** |
5 | 5 |
|
|
6 | 6 | Between 1 and 3 inputs. | Between 1 and 3 inputs. |
7 | 7 |
|
|
8 | 8 | * **input** (heterogeneous) - **T**: | * **input** (heterogeneous) - **T**: |
9 | 9 | Input tensor whose elements to be clipped | Input tensor whose elements to be clipped |
10 | 10 | * **min** (optional, heterogeneous) - **T**: | * **min** (optional, heterogeneous) - **T**: |
11 | 11 | Minimum value, under which element is replaced by min. It must be a | Minimum value, under which element is replaced by min. It must be a |
12 | 12 | scalar(tensor of empty shape). | scalar(tensor of empty shape). |
13 | 13 | * **max** (optional, heterogeneous) - **T**: | * **max** (optional, heterogeneous) - **T**: |
14 | 14 | Maximum value, above which element is replaced by max. It must be a | Maximum value, above which element is replaced by max. It must be a |
15 | 15 | scalar(tensor of empty shape). | scalar(tensor of empty shape). |
16 | 16 |
|
|
17 | 17 | **Outputs** | **Outputs** |
18 | 18 |
|
|
19 | 19 | * **output** (heterogeneous) - **T**: | * **output** (heterogeneous) - **T**: |
20 | 20 | Output tensor with clipped input elements | Output tensor with clipped input elements |
21 | 21 |
|
|
22 | 22 | **Type Constraints** | **Type Constraints** |
23 | 23 |
|
|
24 | 24 | * **T** in ( | * **T** in ( |
25 | 25 | tensor(double), | tensor(double), |
26 | 26 | tensor(float), | tensor(float), |
27 | 27 | tensor(float16) |
|
28 | tensor(int16), | ||
29 | tensor(int32), | ||
30 | tensor(int64), | ||
31 | tensor(int8), | ||
32 | tensor(uint16), | ||
33 | tensor(uint32), | ||
34 | tensor(uint64), | ||
35 | tensor(uint8) | ||
28 | 36 | ): | ): |
29 | 37 | Constrain input and output types to float tensors. |
|
Clip - 11#
Version
name: Clip (GitHub)
domain: main
since_version: 11
function: False
support_level: SupportType.COMMON
shape inference: True
This version of the operator has been available since version 11.
Summary
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
Between 1 and 3 inputs.
input (heterogeneous) - T: Input tensor whose elements to be clipped
min (optional, heterogeneous) - T: Minimum value, under which element is replaced by min. It must be a scalar(tensor of empty shape).
max (optional, heterogeneous) - T: Maximum value, above which element is replaced by max. It must be a scalar(tensor of empty shape).
Outputs
output (heterogeneous) - T: Output tensor with clipped input elements
Type Constraints
T in ( tensor(double), tensor(float), tensor(float16) ): Constrain input and output types to float tensors.
Differences
0 | 0 | Clip operator limits the given input within an interval. The interval is | Clip operator limits the given input within an interval. The interval is |
1 | 1 | specified with arguments 'min' and 'max'. They default to |
|
2 | 2 | numeric_limits::lowest() and numeric_limits::max() respectively. |
|
3 | 3 |
|
|
4 | **Inputs** | ||
5 |
| ||
6 | Between 1 and 3 inputs. | ||
7 |
| ||
4 | 8 | **Attributes** |
|
5 |
| ||
6 | 9 | * **max**: |
|
7 | 10 | Maximum value, above which element is replaced by max Default value is 3.4028234663852886e+38. |
|
8 | * **min**: | ||
9 | 11 | Minimum value, under which element is replaced by min Default value is -3.4028234663852886e+38. |
|
10 |
| ||
11 | 12 | **Inputs** |
|
12 |
| ||
13 | 13 | * **input** (heterogeneous) - **T**: |
|
14 | Input tensor whose elements to be clipped | ||
14 | Maximum value, above which element is replaced by max. It must be a | ||
15 | scalar(tensor of empty shape). | ||
15 | 16 |
|
|
16 | 17 | **Outputs** | **Outputs** |
17 | 18 |
|
|
18 | 19 | * **output** (heterogeneous) - **T**: | * **output** (heterogeneous) - **T**: |
19 | 20 | Output tensor with clipped input elements | Output tensor with clipped input elements |
20 | 21 |
|
|
21 | 22 | **Type Constraints** | **Type Constraints** |
22 | 23 |
|
|
23 | 24 | * **T** in ( | * **T** in ( |
24 | 25 | tensor(double), | tensor(double), |
25 | 26 | tensor(float), | tensor(float), |
26 | 27 | tensor(float16) | tensor(float16) |
27 | 28 | ): | ): |
28 | 29 | Constrain input and output types to float tensors. | Constrain input and output types to float tensors. |
Clip - 6#
Version
name: Clip (GitHub)
domain: main
since_version: 6
function: False
support_level: SupportType.COMMON
shape inference: True
This version of the operator has been available since version 6.
Summary
Clip operator limits the given input within an interval. The interval is specified with arguments ‘min’ and ‘max’. They default to numeric_limits::lowest() and numeric_limits::max() respectively.
Attributes
max: Maximum value, above which element is replaced by max Default value is
3.4028234663852886e+38
.min: Minimum value, under which element is replaced by min Default value is
-3.4028234663852886e+38
.
Inputs
input (heterogeneous) - T: Input tensor whose elements to be clipped
Outputs
output (heterogeneous) - T: Output tensor with clipped input elements
Type Constraints
T in ( tensor(double), tensor(float), tensor(float16) ): Constrain input and output types to float tensors.
Differences
0 | 0 | Clip operator limits the given input within an interval. The interval is | Clip operator limits the given input within an interval. The interval is |
1 | 1 | specified with arguments 'min' and 'max'. They default to | specified with arguments 'min' and 'max'. They default to |
2 | 2 | numeric_limits::lowest() and numeric_limits::max() respectively. | numeric_limits::lowest() and numeric_limits::max() respectively. |
3 | 3 |
|
|
4 | 4 | **Attributes** | **Attributes** |
5 | 5 |
|
|
6 | * **consumed_inputs**: | ||
7 | legacy optimization attribute. | ||
8 | 6 | * **max**: | * **max**: |
9 | 7 | Maximum value, above which element is replaced by max |
|
10 | 8 | * **min**: | * **min**: |
11 | 9 | Minimum value, under which element is replaced by min |
|
12 | 10 |
|
|
13 | 11 | **Inputs** | **Inputs** |
14 | 12 |
|
|
15 | 13 | * **input** (heterogeneous) - **T**: | * **input** (heterogeneous) - **T**: |
16 | 14 | Input tensor whose elements to be clipped | Input tensor whose elements to be clipped |
17 | 15 |
|
|
18 | 16 | **Outputs** | **Outputs** |
19 | 17 |
|
|
20 | 18 | * **output** (heterogeneous) - **T**: | * **output** (heterogeneous) - **T**: |
21 | 19 | Output tensor with clipped input elements | Output tensor with clipped input elements |
22 | 20 |
|
|
23 | 21 | **Type Constraints** | **Type Constraints** |
24 | 22 |
|
|
25 | 23 | * **T** in ( | * **T** in ( |
26 | 24 | tensor(double), | tensor(double), |
27 | 25 | tensor(float), | tensor(float), |
28 | 26 | tensor(float16) | tensor(float16) |
29 | 27 | ): | ): |
30 | 28 | Constrain input and output types to float tensors. | Constrain input and output types to float tensors. |
Clip - 1#
Version
name: Clip (GitHub)
domain: main
since_version: 1
function: False
support_level: SupportType.COMMON
shape inference: False
This version of the operator has been available since version 1.
Summary
Clip operator limits the given input within an interval. The interval is specified with arguments ‘min’ and ‘max’. They default to numeric_limits::lowest() and numeric_limits::max() respectively.
Attributes
consumed_inputs: legacy optimization attribute.
max: Maximum value, above which element is replaced by max
min: Minimum value, under which element is replaced by min
Inputs
input (heterogeneous) - T: Input tensor whose elements to be clipped
Outputs
output (heterogeneous) - T: Output tensor with clipped input elements
Type Constraints
T in ( tensor(double), tensor(float), tensor(float16) ): Constrain input and output types to float tensors.