Compress#
Domain:
ai.onnxSince version: 28
Selects slices from an input tensor along a given axis where condition evaluates to True for each axis index. In case axis is not provided, input is flattened before elements are selected. Compress behaves like numpy.compress: https://docs.scipy.org/doc/numpy/reference/generated/numpy.compress.html
Inputs
input (T): Tensor of rank r >= 1.
condition (T1): Rank 1 tensor of booleans to indicate which slices or data elements to be selected. Its length can be less than the input length along the axis or the flattened input size if axis is not specified. In such cases data slices or elements exceeding the condition length are discarded.
Outputs
output (T): Tensor of rank r if axis is specified. Otherwise output is a Tensor of rank 1.
Attributes
axis (int): (Optional) Axis along which to take slices. If not specified, input is flattened before elements being selected. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(input).
Type Constraints
T: Constrain input and output types to all tensor types. Allowed types: tensor(bfloat16), tensor(bool), tensor(complex128), tensor(complex64), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8).
T1: Constrain to boolean tensors. Allowed types: tensor(bool).
Examples#
test_compress_bfloat16
Node:
Compress(input, condition) -> (output)
Attributes:
axis = 0
Inputs:
input: shape=(3, 2), dtype=bfloat16
[[1, 2],
[3, 4],
[5, 6]]
condition: shape=(3,), dtype=bool
[False, True, True]
Outputs:
output: shape=(2, 2), dtype=bfloat16
[[3, 4],
[5, 6]]
Differences with previous version (11)#
SchemaDiff: Compress (domain 'ai.onnx')
old version: 11
new version: 28
breaking: no
Type constraints:
changed ‘T’: added types: [‘tensor(bfloat16)’]
Documentation:
line similarity: 0.17 (+4/-6 lines)
--- Compress v11
+++ Compress v28
@@ -1,7 +1,5 @@
-Selects slices from an input tensor along a given axis value passed.
-
-In case axis is not provided, input is flattened before elements being selected.
-Positive value means counting dimensions from the front.
-Negative value means counting dimensions from the back.
-Compress behaves like numpy.compress: https://docs.scipy.org/doc/numpy/reference/generated/numpy.compress.html
+ Selects slices from an input tensor along a given axis where condition evaluates to True for each axis index.
+ In case axis is not provided, input is flattened before elements are selected.
+ Compress behaves like numpy.compress: https://docs.scipy.org/doc/numpy/reference/generated/numpy.compress.html
+