!34560 Update space_to_batch_nd tensor api doc

Merge pull request !34560 from zichun_ye/code_docs_space_to_batch_nd
This commit is contained in:
i-robot 2022-05-18 07:08:10 +00:00 committed by Gitee
commit b92c70bcd7
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 14 additions and 32 deletions

View File

@ -2724,41 +2724,23 @@ class Tensor(Tensor_):
r"""
Divides spatial dimensions into blocks and combines the block size with the original batch.
Args:
block_shape (Union[list(int), tuple(int), int]): The block shape of dividing block with all value greater
than 1.
paddings (Union[tuple, list]): The padding values for spatial dimensions, containing 2 subtraction list.
Inputs:
- **input_x** (Tensor) - The input tensor. It must be a 4-D tensor on Ascend.
Outputs:
Tensor, the output tensor with the same data type as input.
Raises:
TypeError: If `block_shape` is not one of list, tuple, int.
TypeError: If `paddings` is neither list nor tuple.
ValueError: If `block_shape` is not one dimensional when `block_shape` is a list or tuple.
ValueError: If the length of `block_shape` is not 2 on Ascend.
ValueError: If shape of `paddings` is not (2, M), where M is the length of `block_shape`.
ValueError: If the element of `block_shape` is not an integer larger than 1.
ValueError: If the element of `paddings` is not an integer larger than 0.
Refer to :func:`mindspore.ops.space_to_batch_nd` for more detail.
Supported Platforms:
``Ascend`` ``GPU``
``Ascend`` ``CPU``
Examples:
>>> import numpy as np
>>> from mindspore import Tensor
>>> block_shape = [2, 2]
>>> paddings = [[0, 0], [0, 0]]
>>> input_x = Tensor(np.array([[[[1, 2], [3, 4]]]]), mindspore.float32)
>>> output = input_x.space_to_batch_nd(block_shape, paddings)
>>> print(output)
[[[[1.]]]
[[[2.]]]
[[[3.]]]
[[[4.]]]]
Examples:
>>> import numpy as np
>>> from mindspore import Tensor
>>> block_shape = [2, 2]
>>> paddings = [[0, 0], [0, 0]]
>>> input_x = Tensor(np.array([[[[1, 2], [3, 4]]]]), mindspore.float32)
>>> output = input_x.space_to_batch_nd(block_shape, paddings)
>>> print(output)
[[[[1.]]]
[[[2.]]]
[[[3.]]]
[[[4.]]]]
"""
return tensor_operator_registry.get('space_to_batch_nd')(block_shape, paddings)(self)