fix some issues

This commit is contained in:
lilinjie 2023-01-06 11:25:57 +08:00
parent 7b1d48bded
commit 05b1899052
9 changed files with 47 additions and 88 deletions

View File

@ -570,6 +570,7 @@ Array操作
mindspore.ops.Sort
mindspore.ops.SpaceToBatchND
mindspore.ops.SpaceToDepth
mindspore.ops.SparseSlice
mindspore.ops.SparseGatherV2
mindspore.ops.Split
mindspore.ops.SplitV

View File

@ -38,7 +38,7 @@
- **data_format** (str可选) - 数据格式的值。目前只支持 `NCHW` ,默认值: `NCHW`
输入:
- **x** (Tensor) - 输入数据。一个四维Tensor数据类型为float16、float32shape必须为
- **x** (Tensor) - 输入数据。一个四维Tensorshape必须为
:math:`(N, C_{in}, H_{in}, W_{in})`
- **filter** (Tensor) - 一个三维Tensor数据类型和输入 `x` 相同shape必须为
:math:`(C_{in}, H_{filter}, W_{filter})`

View File

@ -3,32 +3,4 @@ mindspore.ops.ResizeBilinear
.. py:class:: mindspore.ops.ResizeBilinear(size, align_corners=False, half_pixel_centers=False)
使用双线性插值调整图像大小到指定的大小。
调整输入图像的高和宽。且可以输入不同数据类型的图像但输出的数据类型只能是float32。
使用通用resize功能请参考 :func:`mindspore.ops.interpolate`
.. warning::
这个接口不支持动态shape而且将来可能面临更改或删除:func:`mindspore.ops.interpolate` 可替代该接口。
参数:
- **size** (Union[tuple[int], list[int]]) - 指定图像的新尺寸输入格式为2个int元素 :math:`(new\_height, new\_width)` 的tuple或者list。
- **align_corners** (bool) - 如果为True则通过 :math:`(new\_height - 1) / (height - 1)` 调整输入这将精确对齐图像的4个角和调整图像大小。如果为False则按 :math:`new\_height / height` 调整输入。默认值False。
- **half_pixel_centers** (bool) - 是否几何中心对齐。如果设置为True, 那么 `scale_factor` 应该设置为False。默认值False。
输入:
- **x** (Tensor) - ResizeBilinear的输入四维的Tensor其shape为 :math:`(batch, channels, height, width)` 数据类型为float32或float16。
输出:
Tensor调整大小后的图像。shape为 :math:`(batch, channels, new\_height, new\_width)` 的四维Tensor数据类型与输入 `x` 相同。
异常:
- **TypeError** - `size` 既不是tuple也不是list。
- **TypeError** - `align_corners` 不是bool。
- **TypeError** - `half_pixel_centers` 不是bool。
- **TypeError** - `align_corners``half_pixel_centers` 都为True。
- **TypeError** - `half_pixel_centers` 为True且device_target不为Ascend。
- **TypeError** - `x` 的数据类型既不是float16也不是float32。
- **TypeError** - `x` 不是Tensor。
- **ValueError** - `x` 的shape长度不等于4。
此接口已弃用,请使用 :class:`mindspore.ops.ResizeBilinearV2` 。如果要使用其他插值方法进行尺寸调整,请参考 :func:`mindspore.ops.interpolate`

View File

@ -0,0 +1,29 @@
mindspore.ops.SparseSlice
==========================
.. py:class:: mindspore.ops.SparseSlice
基于 `start``size` 对稀疏Tensor进行切片。
输入:
- **indices** (Tensor) - 稀疏Tensor的索引是一个二维Tensor(N乘R的矩阵)shape为 :math:`(N, R)` 。支持的数据类型为int64其每一个值都必须是非负整数。
- **values** (Tensor)- 稀疏Tensor `indices` 对应位置的值是一个一维Tensorshape为 :math:`(N,)`
- **shape** (Tensor) - 稀疏Tensor的shape是一个一维Tensorshape为 :math:`(R,)` 数据类型为int64。
- **start** (Tensor) - 切片操作起始位置是一个一维Tensorshape为 :math:`(R,)` 数据类型为int64。
- **size** (Tensor) - 切片的尺寸是一个一维Tensorshape为 :math:`(R,)` 数据类型为int64。
输出:
切片操作生成一个 `SparseTensor` 对象。
- y_indices: int64类型的Tensor。
- y_values: 数据类型与 `values` 相同的Tensor.
- y_shape: int64类型的Tensor其大小与 `size` 相同。
异常:
- **TypeError** - `indices``shape``start``size` 不是int64数据类型。
- **ValueError** - `indices` 不是2维Tensor。
- **ValueError** - `values``start``shape``size` 不是一维Tensor。
- **ValueError** - `indices``values` 对应元素数量不一致。
- **ValueError** - `indices[1]``shape` 的shape不一致。
- **ValueError** - `shape``start` 的shape不一致。
- **ValueError** - `shape``size` git的shape不一致。

View File

@ -569,6 +569,7 @@ Array Operation
mindspore.ops.Sort
mindspore.ops.SpaceToBatchND
mindspore.ops.SpaceToDepth
mindspore.ops.SparseSlice
mindspore.ops.SparseGatherV2
mindspore.ops.Split
mindspore.ops.SplitV

View File

@ -9854,6 +9854,7 @@ __all__ = [
'imag',
'roll',
'sum',
'matrix_exp'
'matrix_exp',
'orgqr'
]
__all__.sort()

View File

@ -123,7 +123,7 @@ from .random_ops import (RandomChoiceWithMask, StandardNormal, Gamma, RandomGamm
LogUniformCandidateSampler, TruncatedNormal, LogNormalReverse, NonDeterministicInts,
ParameterizedTruncatedNormal, RandomPoisson)
from .rl_ops import (BufferAppend, BufferGetItem, BufferSample)
from .sparse_ops import (SparseToDense, SparseTensorDenseMatmul, SparseTensorDenseAdd)
from .sparse_ops import (SparseToDense, SparseTensorDenseMatmul, SparseTensorDenseAdd, SparseSlice)
from .spectral_ops import (BartlettWindow, BlackmanWindow)
__all__ = [
@ -643,7 +643,8 @@ __all__ = [
"Zeta",
"PadV3",
"Roll",
"Lgamma"
"Lgamma",
"SparseSlice"
]
__custom__ = [

View File

@ -3623,57 +3623,11 @@ class DropoutDoMask(Primitive):
class ResizeBilinear(PrimitiveWithInfer):
r"""
Resizes an image to a certain size using the bilinear interpolation.
The resizing only affects the lower two dimensions which represent the height and width. The input images
can be represented by different data types, but the data types of output images are always float32.
For general resize, refer to :func:`mindspore.ops.interpolate` for more details.
.. warning::
This interface does not support dynamic shape and is subject to change or deletion,
use :func:`mindspore.ops.interpolate` instead.
Args:
size (Union[tuple[int], list[int]]): A tuple or list of 2 int elements :math:`(new\_height, new\_width)`,
the new size of the images.
align_corners (bool): If true, rescale input by :math:`(new\_height - 1) / (height - 1)`,
which exactly aligns the 4 corners of images and resized images. If false,
rescale by :math:`new\_height / height`. Default: False.
half_pixel_centers (bool): Whether half pixel center. If set to True, `align_corners` should be False.
Default: False.
Inputs:
- **x** (Tensor) - Image to be resized. Input images must be a 4-D tensor with shape
:math:`(batch, channels, height, width)`, with data type of float32 or float16.
Outputs:
Tensor, resized image. 4-D with shape :math:`(batch, channels, new\_height, new\_width)`,
with the same data type as input `x`.
Raises:
TypeError: If `size` is neither a tuple nor list.
TypeError: If `align_corners` is not a bool.
TypeError: If `half_pixel_centers` is not a bool.
TypeError: If `align_corners` and `half_pixel_centers` are all True.
TypeError: If `half_pixel_centers` is True and device_target not Ascend.
TypeError: If dtype of `x` is neither float16 nor float32.
TypeError: If `x` is not a Tensor.
ValueError: If length of shape of `x` is not equal to 4.
This API is deprecated, please use the :class:`mindspore.ops.ResizeBilinearV2` instead.
For general resizing with other interpolation methods, refer to :func:`mindspore.ops.interpolate` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> x = Tensor([[[[1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]]], mindspore.float32)
>>> resize_bilinear = ops.ResizeBilinear((5, 5))
>>> output = resize_bilinear(x)
>>> print(output)
[[[[1. 2. 3. 4. 5.]
[1. 2. 3. 4. 5.]
[1. 2. 3. 4. 5.]
[1. 2. 3. 4. 5.]
[1. 2. 3. 4. 5.]]]]
Deprecated
"""
@prim_attr_register
@ -7096,7 +7050,7 @@ class CTCGreedyDecoder(Primitive):
Examples:
>>> inputs = Tensor(np.array([[[0.6, 0.4, 0.2], [0.8, 0.6, 0.3]],
>>> [[0.0, 0.6, 0.0], [0.5, 0.4, 0.5]]]), mindspore.float32)
... [[0.0, 0.6, 0.0], [0.5, 0.4, 0.5]]]), mindspore.float32)
>>> sequence_length = Tensor(np.array([2, 2]), mindspore.int32)
>>> decoded_indices, decoded_values, decoded_shape, log_probability = ops.CTCGreedyDecoder()(inputs,
... sequence_length)
@ -7972,7 +7926,7 @@ class CTCLossV2(Primitive):
Examples:
>>> log_probs = Tensor(np.array([[[0.3, 0.6, 0.6]],
[[0.9, 0.4, 0.2]]]).astype(np.float32))
... [[0.9, 0.4, 0.2]]]).astype(np.float32))
>>> targets = Tensor(np.array([[0, 1]]), mstype.int32)
>>> input_lengths = Tensor(np.array([2]), mstype.int32)
>>> target_lengths = Tensor(np.array([1]), mstype.int32)
@ -8271,7 +8225,7 @@ class Dilation2D(Primitive):
data_format (str, optional): The value for data format, only 'NCHW' is supported at present. Default: "NCHW".
Inputs:
- **x** (Tensor) - Input data. A four dimension tensor with float16 or float32 data type. The shape must be
- **x** (Tensor) - Input data. A 4-D Tensor, its shape must be
:math:`(N, C_{in}, H_{in}, W_{in})`.
- **filter** (Tensor) - A three dimension tensor with the same type as input. The shape must be
:math:`(C_{in}, H_{filter}, W_{filter})`.

View File

@ -192,10 +192,10 @@ class SparseDenseCwiseDiv(Primitive):
class SparseSlice(Primitive):
r"""
Slices a SparseTensor based on the "start" and "size".
Slices a SparseTensor based on the `start` and `size`.
Inputs:
- **indices** (Tensor) - A 2D Tensor (N x R matrix) of type int64. The indices of the SparseTensor.
- **indices** (Tensor) - A 2D Tensor (N x R matrix), the indices of the SparseTensor.
Support int64, each element value should be a non-negative int number.
The shape is :math:`(N, R)`.
- **values** (Tensor) - A 1D Tensor, represents the value corresponding to the position in the `indices`.
@ -210,7 +210,7 @@ class SparseSlice(Primitive):
Outputs:
A `SparseTensor` objects resulting from splicing.
- *y_indices: A Tensor of type int64.
- *y_values: A Tensor. Has the same type as "values".
- *y_values: A Tensor. Has the same type as `values`.
- *y_shape: A Tensor of type int64. Has the same size as `size`.
Raises: