.. _l-onnx-doc-ArgMin: ====== ArgMin ====== .. contents:: :local: .. _l-onnx-op-argmin-13: 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** .. raw:: html
00Computes the indices of the min elements of the input tensor's element along theComputes the indices of the min elements of the input tensor's element along the
11provided 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.
22If keepdims equal 0, then the resulting tensor has the reduced dimension pruned.If keepdims equals 0, then the resulting tensor has the reduced dimension pruned.
33If select_last_index is True (default False), the index of the last occurrence of the minIf select_last_index is True (default False), the index of the last occurrence of the min
44is selected if the min appears more than once in the input. Otherwise the index of theis selected if the min appears more than once in the input. Otherwise the index of the
55first occurrence is selected.first occurrence is selected.
66The type of the output tensor is integer.The type of the output tensor is integer.
77
88**Attributes****Attributes**
99
1010* **axis**:* **axis**:
1111 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,
1212 r-1] where r = rank(data). Default value is 0. r-1] where r = rank(data). Default value is 0.
1313* **keepdims**:* **keepdims**:
1414 Keep the reduced dimension or not, default 1 means keep reduced Keep the reduced dimension or not, default 1 means keep reduced
1515 dimension. Default value is 1. dimension. Default value is 1.
1616* **select_last_index**:* **select_last_index**:
1717 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}
1818 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.
1919
2020**Inputs****Inputs**
2121
2222* **data** (heterogeneous) - **T**:* **data** (heterogeneous) - **T**:
2323 An input tensor. An input tensor.
2424
2525**Outputs****Outputs**
2626
2727* **reduced** (heterogeneous) - **tensor(int64)**:* **reduced** (heterogeneous) - **tensor(int64)**:
2828 Reduced output tensor with integer data type. Reduced output tensor with integer data type.
2929
3030**Type Constraints****Type Constraints**
3131
3232* **T** in (* **T** in (
33 tensor(bfloat16),
3334 tensor(double), tensor(double),
3435 tensor(float), tensor(float),
3536 tensor(float16), tensor(float16),
3637 tensor(int16), tensor(int16),
3738 tensor(int32), tensor(int32),
3839 tensor(int64), tensor(int64),
3940 tensor(int8), tensor(int8),
4041 tensor(uint16), tensor(uint16),
4142 tensor(uint32), tensor(uint32),
4243 tensor(uint64), tensor(uint64),
4344 tensor(uint8) tensor(uint8)
4445 ): ):
4546 Constrain input and output types to all numeric tensors. Constrain input and output types to all numeric tensors.
.. _l-onnx-op-argmin-12: 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** .. raw:: html
00Computes the indices of the min elements of the input tensor's element along theComputes the indices of the min elements of the input tensor's element along the
11provided 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.
22If 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.
3If select_last_index is True (default False), the index of the last occurrence of the min
4is selected if the min appears more than once in the input. Otherwise the index of the
5first occurrence is selected.
36The type of the output tensor is integer.The type of the output tensor is integer.
47
58**Attributes****Attributes**
69
710* **axis**:* **axis**:
811 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,
912 r-1] where r = rank(data). Default value is 0. r-1] where r = rank(data). Default value is 0.
1013* **keepdims**:* **keepdims**:
1114 Keep the reduced dimension or not, default 1 means keep reduced Keep the reduced dimension or not, default 1 means keep reduced
1215 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.
1319
1420**Inputs****Inputs**
1521
1622* **data** (heterogeneous) - **T**:* **data** (heterogeneous) - **T**:
1723 An input tensor. An input tensor.
1824
1925**Outputs****Outputs**
2026
2127* **reduced** (heterogeneous) - **tensor(int64)**:* **reduced** (heterogeneous) - **tensor(int64)**:
2228 Reduced output tensor with integer data type. Reduced output tensor with integer data type.
2329
2430**Type Constraints****Type Constraints**
2531
2632* **T** in (* **T** in (
2733 tensor(double), tensor(double),
2834 tensor(float), tensor(float),
2935 tensor(float16), tensor(float16),
3036 tensor(int16), tensor(int16),
3137 tensor(int32), tensor(int32),
3238 tensor(int64), tensor(int64),
3339 tensor(int8), tensor(int8),
3440 tensor(uint16), tensor(uint16),
3541 tensor(uint32), tensor(uint32),
3642 tensor(uint64), tensor(uint64),
3743 tensor(uint8) tensor(uint8)
3844 ): ):
3945 Constrain input and output types to all numeric tensors. Constrain input and output types to all numeric tensors.
.. _l-onnx-op-argmin-11: 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** .. raw:: html
00Computes the indices of the min elements of the input tensor's element along theComputes the indices of the min elements of the input tensor's element along the
11provided 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.
22If keepdims equal 0, then the resulted tensor have the reduced dimension pruned.If keepdims equal 0, then the resulting tensor has the reduced dimension pruned.
33The type of the output tensor is integer.The type of the output tensor is integer.
44
55**Attributes****Attributes**
66
77* **axis**:* **axis**:
88 The axis in which to compute the arg indices. Default value is 0. The axis in which to compute the arg indices. Accepted range is [-r,
9 r-1] where r = rank(data). Default value is 0.
910* **keepdims**:* **keepdims**:
1011 Keep the reduced dimension or not, default 1 means keep reduced Keep the reduced dimension or not, default 1 means keep reduced
1112 dimension. Default value is 1. dimension. Default value is 1.
1213
1314**Inputs****Inputs**
1415
1516* **data** (heterogeneous) - **T**:* **data** (heterogeneous) - **T**:
1617 An input tensor. An input tensor.
1718
1819**Outputs****Outputs**
1920
2021* **reduced** (heterogeneous) - **tensor(int64)**:* **reduced** (heterogeneous) - **tensor(int64)**:
2122 Reduced output tensor with integer data type. Reduced output tensor with integer data type.
2223
2324**Type Constraints****Type Constraints**
2425
2526* **T** in (* **T** in (
2627 tensor(double), tensor(double),
2728 tensor(float), tensor(float),
2829 tensor(float16), tensor(float16),
2930 tensor(int16), tensor(int16),
3031 tensor(int32), tensor(int32),
3132 tensor(int64), tensor(int64),
3233 tensor(int8), tensor(int8),
3334 tensor(uint16), tensor(uint16),
3435 tensor(uint32), tensor(uint32),
3536 tensor(uint64), tensor(uint64),
3637 tensor(uint8) tensor(uint8)
3738 ): ):
3839 Constrain input and output types to all numeric tensors. Constrain input and output types to all numeric tensors.
.. _l-onnx-op-argmin-1: 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.