ArgMin#
ArgMin - 13#
Version
name: ArgMin (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
Computes the indices of the min elements of the input tensor’s element along the provided axis. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. If select_last_index is True (default False), the index of the last occurrence of the min is selected if the min appears more than once in the input. Otherwise the index of the first occurrence is selected. The type of the output tensor is integer.
Attributes
axis: The axis in which to compute the arg indices. Accepted range is [-r, r-1] where r = rank(data). Default value is
0
.keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is
1
.select_last_index: Whether to select the last index or the first index if the {name} appears in multiple indices, default is False (first index). Default value is
0
.
Inputs
data (heterogeneous) - T: An input tensor.
Outputs
reduced (heterogeneous) - tensor(int64): Reduced output tensor with integer data type.
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
_no_keepdims
data = np.array([[2, 1], [3, 10]], dtype=np.float32)
axis = 1
keepdims = 0
node = onnx.helper.make_node(
"ArgMin", inputs=["data"], outputs=["result"], axis=axis, keepdims=keepdims
)
# The content of result is : [[1, 0]]
result = argmin_use_numpy(data, axis=axis, keepdims=keepdims)
expect(
node,
inputs=[data],
outputs=[result],
name="test_argmin_no_keepdims_example",
)
data = np.random.uniform(-10, 10, [2, 3, 4]).astype(np.float32)
# result's shape: [2, 4]
result = argmin_use_numpy(data, axis=axis, keepdims=keepdims)
expect(
node, inputs=[data], outputs=[result], name="test_argmin_no_keepdims_random"
)
_keepdims
data = np.array([[2, 1], [3, 10]], dtype=np.float32)
axis = 1
keepdims = 1
node = onnx.helper.make_node(
"ArgMin", inputs=["data"], outputs=["result"], axis=axis, keepdims=keepdims
)
# The content of result is : [[1], [0]]
result = argmin_use_numpy(data, axis=axis, keepdims=keepdims)
expect(
node, inputs=[data], outputs=[result], name="test_argmin_keepdims_example"
)
data = np.random.uniform(-10, 10, [2, 3, 4]).astype(np.float32)
# result's shape: [2, 1, 4]
result = argmin_use_numpy(data, axis=axis, keepdims=keepdims)
expect(
node, inputs=[data], outputs=[result], name="test_argmin_keepdims_random"
)
_default_axes_keepdims
data = np.array([[2, 1], [3, 10]], dtype=np.float32)
keepdims = 1
node = onnx.helper.make_node(
"ArgMin", inputs=["data"], outputs=["result"], keepdims=keepdims
)
# The content of result is : [[0], [0]]
result = argmin_use_numpy(data, keepdims=keepdims)
expect(
node,
inputs=[data],
outputs=[result],
name="test_argmin_default_axis_example",
)
data = np.random.uniform(-10, 10, [2, 3, 4]).astype(np.float32)
# result's shape: [1, 3, 4]
result = argmin_use_numpy(data, keepdims=keepdims)
expect(
node,
inputs=[data],
outputs=[result],
name="test_argmin_default_axis_random",
)
_negative_axis_keepdims
data = np.array([[2, 1], [3, 10]], dtype=np.float32)
axis = -1
keepdims = 1
node = onnx.helper.make_node(
"ArgMin", inputs=["data"], outputs=["result"], axis=axis, keepdims=keepdims
)
# The content of result is : [[1], [0]]
result = argmin_use_numpy(data, axis=axis, keepdims=keepdims)
expect(
node,
inputs=[data],
outputs=[result],
name="test_argmin_negative_axis_keepdims_example",
)
data = np.random.uniform(-10, 10, [2, 3, 4]).astype(np.float32)
# result's shape: [2, 3, 1]
result = argmin_use_numpy(data, axis=axis, keepdims=keepdims)
expect(
node,
inputs=[data],
outputs=[result],
name="test_argmin_negative_axis_keepdims_random",
)
_no_keepdims_select_last_index
data = np.array([[2, 2], [3, 10]], dtype=np.float32)
axis = 1
keepdims = 0
node = onnx.helper.make_node(
"ArgMin",
inputs=["data"],
outputs=["result"],
axis=axis,
keepdims=keepdims,
select_last_index=True,
)
# result: [[1, 0]]
result = argmin_use_numpy_select_last_index(data, axis=axis, keepdims=keepdims)
expect(
node,
inputs=[data],
outputs=[result],
name="test_argmin_no_keepdims_example_select_last_index",
)
data = np.random.uniform(-10, 10, [2, 3, 4]).astype(np.float32)
# result's shape: [2, 4]
result = argmin_use_numpy_select_last_index(data, axis=axis, keepdims=keepdims)
expect(
node,
inputs=[data],
outputs=[result],
name="test_argmin_no_keepdims_random_select_last_index",
)
_keepdims_select_last_index
data = np.array([[2, 2], [3, 10]], dtype=np.float32)
axis = 1
keepdims = 1
node = onnx.helper.make_node(
"ArgMin",
inputs=["data"],
outputs=["result"],
axis=axis,
keepdims=keepdims,
select_last_index=True,
)
# result: [[1], [0]]
result = argmin_use_numpy_select_last_index(data, axis=axis, keepdims=keepdims)
expect(
node,
inputs=[data],
outputs=[result],
name="test_argmin_keepdims_example_select_last_index",
)
data = np.random.uniform(-10, 10, [2, 3, 4]).astype(np.float32)
# result's shape: [2, 1, 4]
result = argmin_use_numpy_select_last_index(data, axis=axis, keepdims=keepdims)
expect(
node,
inputs=[data],
outputs=[result],
name="test_argmin_keepdims_random_select_last_index",
)
_default_axes_keepdims_select_last_index
data = np.array([[2, 2], [3, 10]], dtype=np.float32)
keepdims = 1
node = onnx.helper.make_node(
"ArgMin",
inputs=["data"],
outputs=["result"],
keepdims=keepdims,
select_last_index=True,
)
# result: [[0, 0]]
result = argmin_use_numpy_select_last_index(data, keepdims=keepdims)
expect(
node,
inputs=[data],
outputs=[result],
name="test_argmin_default_axis_example_select_last_index",
)
data = np.random.uniform(-10, 10, [2, 3, 4]).astype(np.float32)
# result's shape: [1, 3, 4]
result = argmin_use_numpy_select_last_index(data, keepdims=keepdims)
expect(
node,
inputs=[data],
outputs=[result],
name="test_argmin_default_axis_random_select_last_index",
)
_negative_axis_keepdims_select_last_index
data = np.array([[2, 2], [3, 10]], dtype=np.float32)
axis = -1
keepdims = 1
node = onnx.helper.make_node(
"ArgMin",
inputs=["data"],
outputs=["result"],
axis=axis,
keepdims=keepdims,
select_last_index=True,
)
# result: [[1], [0]]
result = argmin_use_numpy_select_last_index(data, axis=axis, keepdims=keepdims)
expect(
node,
inputs=[data],
outputs=[result],
name="test_argmin_negative_axis_keepdims_example_select_last_index",
)
data = np.random.uniform(-10, 10, [2, 3, 4]).astype(np.float32)
# result's shape: [2, 3, 1]
result = argmin_use_numpy_select_last_index(data, axis=axis, keepdims=keepdims)
expect(
node,
inputs=[data],
outputs=[result],
name="test_argmin_negative_axis_keepdims_random_select_last_index",
)
Differences
0 | 0 | Computes the indices of the min elements of the input tensor's element along the | Computes the indices of the min elements of the input tensor's element along the |
1 | 1 | provided axis. The resulting tensor has the same rank as the input if keepdims equals 1. | provided axis. The resulting tensor has the same rank as the input if keepdims equals 1. |
2 | 2 | If keepdims equal 0, then the resulting tensor has the reduced dimension pruned. |
|
3 | 3 | If select_last_index is True (default False), the index of the last occurrence of the min | If select_last_index is True (default False), the index of the last occurrence of the min |
4 | 4 | is selected if the min appears more than once in the input. Otherwise the index of the | is selected if the min appears more than once in the input. Otherwise the index of the |
5 | 5 | first occurrence is selected. | first occurrence is selected. |
6 | 6 | The type of the output tensor is integer. | The type of the output tensor is integer. |
7 | 7 |
|
|
8 | 8 | **Attributes** | **Attributes** |
9 | 9 |
|
|
10 | 10 | * **axis**: | * **axis**: |
11 | 11 | The axis in which to compute the arg indices. Accepted range is [-r, | The axis in which to compute the arg indices. Accepted range is [-r, |
12 | 12 | r-1] where r = rank(data). Default value is 0. | r-1] where r = rank(data). Default value is 0. |
13 | 13 | * **keepdims**: | * **keepdims**: |
14 | 14 | Keep the reduced dimension or not, default 1 means keep reduced | Keep the reduced dimension or not, default 1 means keep reduced |
15 | 15 | dimension. Default value is 1. | dimension. Default value is 1. |
16 | 16 | * **select_last_index**: | * **select_last_index**: |
17 | 17 | Whether to select the last index or the first index if the {name} | Whether to select the last index or the first index if the {name} |
18 | 18 | appears in multiple indices, default is False (first index). Default value is 0. | appears in multiple indices, default is False (first index). Default value is 0. |
19 | 19 |
|
|
20 | 20 | **Inputs** | **Inputs** |
21 | 21 |
|
|
22 | 22 | * **data** (heterogeneous) - **T**: | * **data** (heterogeneous) - **T**: |
23 | 23 | An input tensor. | An input tensor. |
24 | 24 |
|
|
25 | 25 | **Outputs** | **Outputs** |
26 | 26 |
|
|
27 | 27 | * **reduced** (heterogeneous) - **tensor(int64)**: | * **reduced** (heterogeneous) - **tensor(int64)**: |
28 | 28 | Reduced output tensor with integer data type. | Reduced output tensor with integer data type. |
29 | 29 |
|
|
30 | 30 | **Type Constraints** | **Type Constraints** |
31 | 31 |
|
|
32 | 32 | * **T** in ( | * **T** in ( |
33 | tensor(bfloat16), | ||
33 | 34 | tensor(double), | tensor(double), |
34 | 35 | tensor(float), | tensor(float), |
35 | 36 | tensor(float16), | tensor(float16), |
36 | 37 | tensor(int16), | tensor(int16), |
37 | 38 | tensor(int32), | tensor(int32), |
38 | 39 | tensor(int64), | tensor(int64), |
39 | 40 | tensor(int8), | tensor(int8), |
40 | 41 | tensor(uint16), | tensor(uint16), |
41 | 42 | tensor(uint32), | tensor(uint32), |
42 | 43 | tensor(uint64), | tensor(uint64), |
43 | 44 | tensor(uint8) | tensor(uint8) |
44 | 45 | ): | ): |
45 | 46 | Constrain input and output types to all numeric tensors. | Constrain input and output types to all numeric tensors. |
ArgMin - 12#
Version
name: ArgMin (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
Computes the indices of the min elements of the input tensor’s element along the provided axis. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulting tensor has the reduced dimension pruned. If select_last_index is True (default False), the index of the last occurrence of the min is selected if the min appears more than once in the input. Otherwise the index of the first occurrence is selected. The type of the output tensor is integer.
Attributes
axis: The axis in which to compute the arg indices. Accepted range is [-r, r-1] where r = rank(data). Default value is
0
.keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is
1
.select_last_index: Whether to select the last index or the first index if the {name} appears in multiple indices, default is False (first index). Default value is
0
.
Inputs
data (heterogeneous) - T: An input tensor.
Outputs
reduced (heterogeneous) - tensor(int64): Reduced output tensor with integer data type.
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 | Computes the indices of the min elements of the input tensor's element along the | Computes the indices of the min elements of the input tensor's element along the |
1 | 1 | provided axis. The resulting tensor has the same rank as the input if keepdims equals 1. | provided axis. The resulting tensor has the same rank as the input if keepdims equals 1. |
2 | 2 | If keepdims equal 0, then the resulting tensor has the reduced dimension pruned. | If keepdims equal 0, then the resulting tensor has the reduced dimension pruned. |
3 | If select_last_index is True (default False), the index of the last occurrence of the min | ||
4 | is selected if the min appears more than once in the input. Otherwise the index of the | ||
5 | first occurrence is selected. | ||
3 | 6 | The type of the output tensor is integer. | The type of the output tensor is integer. |
4 | 7 |
|
|
5 | 8 | **Attributes** | **Attributes** |
6 | 9 |
|
|
7 | 10 | * **axis**: | * **axis**: |
8 | 11 | The axis in which to compute the arg indices. Accepted range is [-r, | The axis in which to compute the arg indices. Accepted range is [-r, |
9 | 12 | r-1] where r = rank(data). Default value is 0. | r-1] where r = rank(data). Default value is 0. |
10 | 13 | * **keepdims**: | * **keepdims**: |
11 | 14 | Keep the reduced dimension or not, default 1 means keep reduced | Keep the reduced dimension or not, default 1 means keep reduced |
12 | 15 | dimension. Default value is 1. | dimension. Default value is 1. |
16 | * **select_last_index**: | ||
17 | Whether to select the last index or the first index if the {name} | ||
18 | appears in multiple indices, default is False (first index). Default value is 0. | ||
13 | 19 |
|
|
14 | 20 | **Inputs** | **Inputs** |
15 | 21 |
|
|
16 | 22 | * **data** (heterogeneous) - **T**: | * **data** (heterogeneous) - **T**: |
17 | 23 | An input tensor. | An input tensor. |
18 | 24 |
|
|
19 | 25 | **Outputs** | **Outputs** |
20 | 26 |
|
|
21 | 27 | * **reduced** (heterogeneous) - **tensor(int64)**: | * **reduced** (heterogeneous) - **tensor(int64)**: |
22 | 28 | Reduced output tensor with integer data type. | Reduced output tensor with integer data type. |
23 | 29 |
|
|
24 | 30 | **Type Constraints** | **Type Constraints** |
25 | 31 |
|
|
26 | 32 | * **T** in ( | * **T** in ( |
27 | 33 | tensor(double), | tensor(double), |
28 | 34 | tensor(float), | tensor(float), |
29 | 35 | tensor(float16), | tensor(float16), |
30 | 36 | tensor(int16), | tensor(int16), |
31 | 37 | tensor(int32), | tensor(int32), |
32 | 38 | tensor(int64), | tensor(int64), |
33 | 39 | tensor(int8), | tensor(int8), |
34 | 40 | tensor(uint16), | tensor(uint16), |
35 | 41 | tensor(uint32), | tensor(uint32), |
36 | 42 | tensor(uint64), | tensor(uint64), |
37 | 43 | tensor(uint8) | tensor(uint8) |
38 | 44 | ): | ): |
39 | 45 | Constrain input and output types to all numeric tensors. | Constrain input and output types to all numeric tensors. |
ArgMin - 11#
Version
name: ArgMin (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
Computes the indices of the min elements of the input tensor’s element along the provided axis. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulting tensor has the reduced dimension pruned. The type of the output tensor is integer.
Attributes
axis: The axis in which to compute the arg indices. Accepted range is [-r, r-1] where r = rank(data). Default value is
0
.keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is
1
.
Inputs
data (heterogeneous) - T: An input tensor.
Outputs
reduced (heterogeneous) - tensor(int64): Reduced output tensor with integer data type.
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 | Computes the indices of the min elements of the input tensor's element along the | Computes the indices of the min elements of the input tensor's element along the |
1 | 1 | provided axis. The resulting tensor has the same rank as the input if keepdims equals 1. | provided axis. The resulting tensor has the same rank as the input if keepdims equals 1. |
2 | 2 | If keepdims equal 0, then the resulted tensor have the reduced dimension pruned. |
|
3 | 3 | The type of the output tensor is integer. | The type of the output tensor is integer. |
4 | 4 |
|
|
5 | 5 | **Attributes** | **Attributes** |
6 | 6 |
|
|
7 | 7 | * **axis**: | * **axis**: |
8 | 8 | The axis in which to compute the arg indices. Default value is 0. |
|
9 | r-1] where r = rank(data). Default value is 0. | ||
9 | 10 | * **keepdims**: | * **keepdims**: |
10 | 11 | Keep the reduced dimension or not, default 1 means keep reduced | Keep the reduced dimension or not, default 1 means keep reduced |
11 | 12 | dimension. Default value is 1. | dimension. Default value is 1. |
12 | 13 |
|
|
13 | 14 | **Inputs** | **Inputs** |
14 | 15 |
|
|
15 | 16 | * **data** (heterogeneous) - **T**: | * **data** (heterogeneous) - **T**: |
16 | 17 | An input tensor. | An input tensor. |
17 | 18 |
|
|
18 | 19 | **Outputs** | **Outputs** |
19 | 20 |
|
|
20 | 21 | * **reduced** (heterogeneous) - **tensor(int64)**: | * **reduced** (heterogeneous) - **tensor(int64)**: |
21 | 22 | Reduced output tensor with integer data type. | Reduced output tensor with integer data type. |
22 | 23 |
|
|
23 | 24 | **Type Constraints** | **Type Constraints** |
24 | 25 |
|
|
25 | 26 | * **T** in ( | * **T** in ( |
26 | 27 | tensor(double), | tensor(double), |
27 | 28 | tensor(float), | tensor(float), |
28 | 29 | tensor(float16), | tensor(float16), |
29 | 30 | tensor(int16), | tensor(int16), |
30 | 31 | tensor(int32), | tensor(int32), |
31 | 32 | tensor(int64), | tensor(int64), |
32 | 33 | tensor(int8), | tensor(int8), |
33 | 34 | tensor(uint16), | tensor(uint16), |
34 | 35 | tensor(uint32), | tensor(uint32), |
35 | 36 | tensor(uint64), | tensor(uint64), |
36 | 37 | tensor(uint8) | tensor(uint8) |
37 | 38 | ): | ): |
38 | 39 | Constrain input and output types to all numeric tensors. | Constrain input and output types to all numeric tensors. |
ArgMin - 1#
Version
name: ArgMin (GitHub)
domain: main
since_version: 1
function: False
support_level: SupportType.COMMON
shape inference: True
This version of the operator has been available since version 1.
Summary
Computes the indices of the min elements of the input tensor’s element along the provided axis. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned. The type of the output tensor is integer.
Attributes
axis: The axis in which to compute the arg indices. Default value is
0
.keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is
1
.
Inputs
data (heterogeneous) - T: An input tensor.
Outputs
reduced (heterogeneous) - tensor(int64): Reduced output tensor with integer data type.
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.