From 6c7957f0dd2ae8abb366e56001d426c6e75d4cca Mon Sep 17 00:00:00 2001 From: lianliguang Date: Mon, 21 Feb 2022 18:06:28 +0800 Subject: [PATCH] change api of DynamicShape ops --- .../ops/mindspore.ops.DynamicShape.rst | 6 ++++ .../ops/mindspore.ops.TensorShape.rst | 18 ++++++++++ .../mindspore/ops/operations/array_ops.py | 36 ++----------------- 3 files changed, 27 insertions(+), 33 deletions(-) create mode 100644 docs/api/api_python/ops/mindspore.ops.DynamicShape.rst create mode 100644 docs/api/api_python/ops/mindspore.ops.TensorShape.rst diff --git a/docs/api/api_python/ops/mindspore.ops.DynamicShape.rst b/docs/api/api_python/ops/mindspore.ops.DynamicShape.rst new file mode 100644 index 00000000000..841c303bb92 --- /dev/null +++ b/docs/api/api_python/ops/mindspore.ops.DynamicShape.rst @@ -0,0 +1,6 @@ +mindspore.ops.DynamicShape +================= + +.. py:class:: mindspore.ops.DynamicShape() + +与`TensorShape`相同,`DynamicShape`将会被`TensorShape`替换,请使用`TensorShape`。 diff --git a/docs/api/api_python/ops/mindspore.ops.TensorShape.rst b/docs/api/api_python/ops/mindspore.ops.TensorShape.rst new file mode 100644 index 00000000000..1095335935f --- /dev/null +++ b/docs/api/api_python/ops/mindspore.ops.TensorShape.rst @@ -0,0 +1,18 @@ +mindspore.ops.TensorShape +================= + +.. py:class:: mindspore.ops.TensorShape() + + 返回输入Tensor的Shape。 + + **输入:** + + - **input_x** (Tensor) - 第一个输入,是一个Tensor类型数据 + + **输出:** + + Tensor,输入`input_x`的shape + + **异常:** + + - **TypeError** - `input_x` 都不是Tensor。 diff --git a/mindspore/python/mindspore/ops/operations/array_ops.py b/mindspore/python/mindspore/ops/operations/array_ops.py index 2b5c139af06..4f018db05e0 100755 --- a/mindspore/python/mindspore/ops/operations/array_ops.py +++ b/mindspore/python/mindspore/ops/operations/array_ops.py @@ -637,13 +637,7 @@ class Shape(Primitive): class TensorShape(Primitive): """ - Returns the shape of the input tensor. And it used to be dynamic shape. - - Note: - Dynamic shape: After the graph is running, as the tensor flows in the graph, the specific shape of the tensor - on each node on the graph can be inferred according to the structure of the graph. - This shape is called a dynamic shape. As the input shape of the graph is different, - the dynamic shape of the tensor in the graph will change. + Returns the shape of the input tensor. Inputs: - **input_x** (Tensor) - The shape of tensor is :math:`(x_1, x_2, ..., x_R)`. @@ -671,32 +665,8 @@ class TensorShape(Primitive): class DynamicShape(Primitive): """ - Returns the shape of the input tensor. And it used to be dynamic shape. - - Note: - Dynamic shape: After the graph is running, as the tensor flows in the graph, the specific shape of the tensor - on each node on the graph can be inferred according to the structure of the graph. - This shape is called a dynamic shape. As the input shape of the graph is different, - the dynamic shape of the tensor in the graph will change. - - Inputs: - - **input_x** (Tensor) - The shape of tensor is :math:`(x_1, x_2, ..., x_R)`. - - Outputs: - Tensor[int], 1-dim Tensor of type int32 - - Raises: - TypeError: If `input_x` is not a Tensor. - - Supported Platforms: - ``Ascend`` ``GPU`` ``CPU`` - - Examples: - >>> input_x = Tensor(np.ones(shape=[3, 2, 1]), mindspore.float32) - >>> shape = ops.DynamicShape() - >>> output = shape(input_x) - >>> print(output) - [3 2 1] + Same as operator TensorShape. DynamicShape will be deprecated in the future. + Please use TensorShape instead. """ @deprecated("1.7", "TensorShape", True)