From 0360bd60cf2d916816141c5b95126a3f9ccdebbe Mon Sep 17 00:00:00 2001 From: ZPaC Date: Fri, 22 Jul 2022 16:03:56 +0800 Subject: [PATCH] Add functional doc --- .../api_python/mindspore.ops.functional.rst | 1 + .../api_python/ops/mindspore.ops.func_min.rst | 34 +++++++++++++++++++ .../mindspore.ops.functional.rst | 1 + .../mindspore/ops/function/array_func.py | 5 +-- 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 docs/api/api_python/ops/mindspore.ops.func_min.rst diff --git a/docs/api/api_python/mindspore.ops.functional.rst b/docs/api/api_python/mindspore.ops.functional.rst index fd2c46aef93..b9ae7cd829d 100644 --- a/docs/api/api_python/mindspore.ops.functional.rst +++ b/docs/api/api_python/mindspore.ops.functional.rst @@ -209,6 +209,7 @@ Reduction算子 mindspore.ops.logsumexp mindspore.ops.norm + mindspore.ops.min .. list-table:: :widths: 50 50 diff --git a/docs/api/api_python/ops/mindspore.ops.func_min.rst b/docs/api/api_python/ops/mindspore.ops.func_min.rst new file mode 100644 index 00000000000..b4137c6da6f --- /dev/null +++ b/docs/api/api_python/ops/mindspore.ops.func_min.rst @@ -0,0 +1,34 @@ +mindspore.ops.min +============================== + +.. py:function:: mindspore.ops.min(x, axis=0, keep_dims=False) + + 根据指定的索引计算最小值,并返回索引和值。 + + 在给定轴上计算输入Tensor的最小值,并且返回最小值和索引。 + + .. note:: + 在auto_parallel和semi_auto_parallel模式下,不能使用第一个输出索引。 + + .. warning:: + - 如果有多个最小值,则取第一个最小值的索引。 + - "axis"的取值范围为[-dims, dims - 1]。"dims"为"x"的维度长度。 + + **参数:** + + - **x** (Tensor) - 输入任意维度的Tensor。将输入Tensor的shape设为 :math:`(x_1, x_2, ..., x_N)` 。数据类型为mindspore.uint16,mindspore.uint32,mindspore.int16,mindspore.int32,mindspore.float16或者mindspore.float32。 + - **axis** (int) - 指定计算维度。默认值:0。 + - **keep_dims** (bool) - 表示是否减少维度,如果为True,输出将与输入保持相同的维度;如果为False,输出将减少维度。默认值:False。 + + **返回:** + + tuple (Tensor),表示2个Tensor组成的tuple,包含对应的索引和输入Tensor的最小值。 + + - **index** (Tensor) - 输入Tensor最小值的索引。如果 `keep_dims` 为True,则输出Tensor的shape为 :math:`(x_1, x_2, ..., x_{axis-1}, 1, x_{axis+1}, ..., x_N)` 。否则,shape为 :math:`(x_1, x_2, ..., x_{axis-1}, x_{axis+1}, ..., x_N)` 。 + - **output_x** (Tensor) - 输入Tensor的最小值,其shape与索引相同。 + + **异常:** + + - **TypeError** - `input_x` 的数据类型非uint16,uint32,int16,int32,float16,float32。 + - **TypeError** - `keep_dims` 不是bool。 + - **TypeError** - `axis` 不是int。 \ No newline at end of file diff --git a/docs/api/api_python_en/mindspore.ops.functional.rst b/docs/api/api_python_en/mindspore.ops.functional.rst index f8c4b5d8d69..6394003be9e 100644 --- a/docs/api/api_python_en/mindspore.ops.functional.rst +++ b/docs/api/api_python_en/mindspore.ops.functional.rst @@ -208,6 +208,7 @@ Reduction Operators mindspore.ops.logsumexp mindspore.ops.norm + mindspore.ops.min .. list-table:: :widths: 50 50 diff --git a/mindspore/python/mindspore/ops/function/array_func.py b/mindspore/python/mindspore/ops/function/array_func.py index 85c7b4f9117..f3123c06daf 100644 --- a/mindspore/python/mindspore/ops/function/array_func.py +++ b/mindspore/python/mindspore/ops/function/array_func.py @@ -3856,7 +3856,7 @@ def max(x, axis=0, keep_dims=False): Also see: class: `mindspore.ops.ArgMaxWithValue`. Args: - x (Tensor) - The input tensor, can be any dimension. Set the shape of input tensor as + x (Tensor): The input tensor, can be any dimension. Set the shape of input tensor as :math:`(x_1, x_2, ..., x_N)`. And the data type only support mindspore.float16 or float32. axis (int): The dimension to reduce. Default: 0. keep_dims (bool): Whether to reduce dimension, if true, the output will keep same dimension with the input, @@ -3909,7 +3909,7 @@ def min(x, axis=0, keep_dims=False): Also see: class: `mindspore.ops.ArgMinWithValue`. Args: - x (Tensor) - The input tensor, can be any dimension. Set the shape of input tensor as + x (Tensor): The input tensor, can be any dimension. Set the shape of input tensor as :math:`(x_1, x_2, ..., x_N)` . And the data type only support mindspore.uint16, mindspore.uint32, mindspore.int16, mindspore.int32, mindspore.float16, mindspore.float32. axis (int): The dimension to reduce. Default: 0. @@ -3926,6 +3926,7 @@ def min(x, axis=0, keep_dims=False): - **values** (Tensor) - The minimum value of input tensor, with the same shape as index. Raises: + TypeError: If data type `x` is not uint16, uint32, int16, int32, float16, float32. TypeError: If `keep_dims` is not a bool. TypeError: If `axis` is not an int.