add pad null padding

This commit is contained in:
fengyihang 2022-11-30 09:30:43 +08:00
parent 0863ef09bf
commit 92b0e2d468
2 changed files with 4 additions and 2 deletions

View File

@ -3,7 +3,7 @@ mindspore.ops.pad
.. py:function:: mindspore.ops.pad(input_x, padding, mode='constant', value=None)
根据参数 `paddings` 对输入进行填充。
根据参数 `padding` 对输入进行填充。
参数:
- **input_x** (Tensor) - 输入Tensorshape为 :math:`(N, *)` :math:`*` 代表任意附加维度。

View File

@ -2396,7 +2396,7 @@ def _check_pad_inputs(padding):
def pad(input_x, padding, mode='constant', value=None):
r"""
Pads the input tensor according to the paddings.
Pads the input tensor according to the padding.
Args:
input_x (Tensor): Tensor of shape :math:`(N, *)`, where :math:`*` means, any number of additional dimensions.
@ -2478,6 +2478,8 @@ def pad(input_x, padding, mode='constant', value=None):
"""
if not isinstance(input_x, Tensor):
raise TypeError(f"For 'pad', the type of 'input_x' must be Tensor, but got {type(input_x)}.")
if (isinstance(padding, (tuple, list)) and not padding) or (isinstance(padding, Tensor) and padding.shape == (0,)):
return input_x
if not isinstance(padding, Tensor):
_check_pad_inputs(padding)
padding = Tensor(padding)