!46163 sync fixes from master after Nov. 23
Merge pull request !46163 from 李林杰/1129_sync_master_and_r20_alpha
This commit is contained in:
commit
d5c872b116
|
@ -396,7 +396,6 @@ Array操作
|
|||
mindspore.ops.normal
|
||||
mindspore.ops.nonzero
|
||||
mindspore.ops.numel
|
||||
mindspore.ops.orgqr
|
||||
mindspore.ops.permute
|
||||
mindspore.ops.population_count
|
||||
mindspore.ops.range
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
mindspore.ops.NonDeterministicInts
|
||||
===================================
|
||||
|
||||
.. py:class:: mindspore.ops.NonDeterministicInts(dtype=mindspore.int64)
|
||||
.. py:class:: mindspore.ops.NonDeterministicInts(dtype=mstype.int64)
|
||||
|
||||
生成指定数据类型范围内的随机整数。
|
||||
|
||||
|
@ -11,7 +11,7 @@ mindspore.ops.NonDeterministicInts
|
|||
`shape` 中的值必须大于零,输出元素总数不可超过1000000。
|
||||
|
||||
参数:
|
||||
- **dtype** (mindspore.dtype,可选) - 输出数据类型。支持的数据类型为:mindspore.int32和mindspore.int64。默认值:mindspore.int64。
|
||||
- **dtype** (mindspore.dtype,可选) - 输出数据类型。支持的数据类型为:mstype.int32和mstype.int64。默认值:mstype.int64。
|
||||
|
||||
输入:
|
||||
- **shape** (Tensor) - 输出Tensor的shape。支持的数据类型为:int32和int64。
|
||||
|
@ -21,7 +21,7 @@ mindspore.ops.NonDeterministicInts
|
|||
|
||||
异常:
|
||||
- **TypeError** - `shape` 不是Tensor。
|
||||
- **TypeError** - `dtype` 不是mindspore.int32或mindspore.int64。
|
||||
- **TypeError** - `dtype` 不是mstype.int32或mstype.int64。
|
||||
- **ValueError** - `shape` 中含有负数。
|
||||
- **ValueError** - `shape` 元素个数少于2。
|
||||
- **ValueError** - `shape` 不是一维Tensor。
|
||||
|
|
|
@ -6,7 +6,7 @@ mindspore.ops.RGBToHSV
|
|||
将一张或多张图片由RGB格式转换为HSV格式。
|
||||
输出与输入有相同shape的Tensor,含有每个像素的HSV值。输出值仅在[0,1]范围内才是被有效定义的。
|
||||
|
||||
.. warning::
|
||||
.. note::
|
||||
输入图片的最后一维长度必须为3。
|
||||
|
||||
输入:
|
||||
|
|
|
@ -3,11 +3,7 @@ mindspore.ops.RandomGamma
|
|||
|
||||
.. py:class:: mindspore.ops.RandomGamma(seed=0, seed2=0)
|
||||
|
||||
根据概率密度函数分布生成随机正值浮点数x。函数定义如下:
|
||||
|
||||
.. math::
|
||||
|
||||
\text{P}(x|α,β) = \frac{\exp(-x/β)}{{β^α}\cdot{\Gamma(α)}}\cdot{x^{α-1}}
|
||||
根据概率密度函数分布生成随机正值浮点数x。
|
||||
|
||||
.. note::
|
||||
- 随机种子:通过一些复杂的数学算法,可以得到一组有规律的随机数,而随机种子就是这个随机数的初始值。随机种子相同,得到的随机数就不会改变。
|
||||
|
@ -22,14 +18,13 @@ mindspore.ops.RandomGamma
|
|||
|
||||
输入:
|
||||
- **shape** (tuple) - 待生成的随机Tensor的shape。只支持常量值。
|
||||
- **alpha** (Tensor) - α为Gamma分布的shape parameter,主要决定了曲线的形状。其值必须大于0。数据类型为float32。
|
||||
- **beta** (Tensor) - β为Gamma分布的inverse scale parameter,主要决定了曲线有多陡。其值必须大于0。数据类型为float32。
|
||||
- **alpha** (Tensor) - α为RandomGamma分布的shape parameter,主要决定了曲线的形状。其值必须大于0。数据类型为float32。
|
||||
|
||||
输出:
|
||||
Tensor。shape是输入 `shape`, `alpha`, `beta` 广播后的shape。数据类型为float32。
|
||||
Tensor。shape是输入 `shape`, `alpha` 相连后的shape。数据类型与 `alpha` 一致。
|
||||
|
||||
异常:
|
||||
- **TypeError** - `seed` 或 `seed2` 的数据类型不是int。
|
||||
- **TypeError** - `alpha` 或 `beta` 不是Tensor。
|
||||
- **TypeError** - `alpha` 或 `beta` 的数据类型不是float32。
|
||||
- **TypeError** - `shape` 或 `alpha` 不是Tensor。
|
||||
- **TypeError** - `shape` 或 `alpha` 的数据类型不是float32。
|
||||
- **ValueError** - `shape` 不是常量值。
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
mindspore.ops.RandomPoisson
|
||||
============================
|
||||
|
||||
.. py:class:: mindspore.ops.RandomPoisson(seed=0, seed2=0, dtype=mindspore.int64)
|
||||
.. py:class:: mindspore.ops.RandomPoisson(seed=0, seed2=0, dtype=mstype.int64)
|
||||
|
||||
根据离散概率密度函数分布生成随机非负数浮点数i。函数定义如下:
|
||||
|
||||
|
@ -11,10 +11,10 @@ mindspore.ops.RandomPoisson
|
|||
参数:
|
||||
- **seed** (int,可选) - 随机数种子。如果 `seed` 或者 `seed2` 被设置为非零,则使用这个非零值。否则使用一个随机生成的种子。默认值:0。
|
||||
- **seed2** (int,可选) - 另一个随机种子,避免发生冲突。默认值:0。
|
||||
- **dtype** (mindspore.dtype,可选) - 输出数据类型, 默人值:mindspore.int64。
|
||||
- **dtype** (mindspore.dtype,可选) - 输出数据类型, 默人值:mstype.int64。
|
||||
|
||||
输入:
|
||||
- **shape** (tuple) - 待生成的随机Tensor的shape,是一个一维Tensor。数据类型为nt32或int64。
|
||||
- **shape** (tuple) - 待生成的随机Tensor的shape,是一个一维Tensor。数据类型为int32或int64。
|
||||
- **rate** (Tensor) - `rate` 为Poisson分布的μ参数,决定数字的平均出现次数。数据类型是其中之一:[float16, float32, float64, int32, int64]。
|
||||
|
||||
输出:
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
mindspore.ops.SearchSorted
|
||||
===========================
|
||||
|
||||
.. py:class:: mindspore.ops.SearchSorted(out_int32=False, right=False)
|
||||
.. py:class:: mindspore.ops.SearchSorted(dtype=mstype.int64, right=False)
|
||||
|
||||
从 `sequence` 的最内维度查找索引,以便最内维度元素的的顺序在插入 `values` 的值之后维持不变。
|
||||
|
||||
更多参考详见 :func:`mindspore.ops.search_sorted` 。
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@ mindspore.ops.SegmentSum
|
|||
|
||||
计算Tensor的片段和。
|
||||
|
||||
.. warning::
|
||||
如果 `input_x` 的数据类型是复数,则不能进行反向求导。
|
||||
|
||||
计算一个Tensor,使得 :math:`output_i = \sum_j input\_x_j` ,其中求和是在j上,满足::math:`segment\_ids[j] == i` 。如果给定 ID :math:`i` 的分段的和为空,则有 :math:`output[i] = 0` 。
|
||||
|
||||
输入:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
mindspore.ops.TrilIndices
|
||||
==========================
|
||||
|
||||
.. py:class:: mindspore.ops.TrilIndices(row, col, offset=0, dtype=mindspore.int32)
|
||||
.. py:class:: mindspore.ops.TrilIndices(row, col, offset=0, dtype=mstype.int32)
|
||||
|
||||
返回一个包含 `row` * `col` 的矩阵的下三角形部分的索引的Tensor。Tensor的shape为 :math:`(2, tril_size)` ,其中, `tril_size` 为下三角矩阵的元素总数。第一行包含所有索引的行坐标,第二行包含列坐标。索引按行排序,然后按列排序。
|
||||
|
||||
|
@ -13,8 +13,8 @@ mindspore.ops.TrilIndices
|
|||
参数:
|
||||
- **row** (int) - 2-D 矩阵的行数。
|
||||
- **col** (int) - 2-D 矩阵的列数。
|
||||
- **offset** (int, 可选) - 对角线偏移量。默认值:0。
|
||||
- **dtype** (:class:`mindspore.dtype`, 可选) - 指定输出Tensor数据类型,支持的数据类型为 `mindspore.int32` 和 `mindspore.int64` ,默认值: `mindspore.int32` 。
|
||||
- **offset** (int,可选) - 对角线偏移量。默认值:0。
|
||||
- **dtype** (:class:`mindspore.dtype` ,可选) - 指定输出Tensor数据类型,支持的数据类型为 `mstype.int32` 和 `mstype.int64` ,默认值: `mstype.int32` 。
|
||||
|
||||
输出:
|
||||
- **y** (Tensor) - 矩阵的下三角形部分的索引。数据类型由 `dtype` 指定,shape为 :math:`(2, tril_size)` ,其中, `tril_size` 为下三角矩阵的元素总数。
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
mindspore.ops.TriuIndices
|
||||
==========================
|
||||
|
||||
.. py:class:: mindspore.ops.TriuIndices(row, col, offset=0, dtype=mindspore.int32)
|
||||
.. py:class:: mindspore.ops.TriuIndices(row, col, offset=0, dtype=mstype.int32)
|
||||
|
||||
返回一个包含 `row` * `col` 的矩阵的上三角形部分的索引的Tensor。Tensor的shape为 :math:`(2, tril_size)` ,其中, `tril_size` 为上三角矩阵的元素总数。第一行包含所有索引的行坐标,第二行包含列坐标。索引按行排序,然后按列排序。
|
||||
|
||||
|
@ -14,7 +14,7 @@ mindspore.ops.TriuIndices
|
|||
- **row** (int) - 2-D 矩阵的行数。
|
||||
- **col** (int) - 2-D 矩阵的列数。
|
||||
- **offset** (int,可选) - 对角线偏移量。默认值:0。
|
||||
- **dtype** (:class:`mindspore.dtype`,可选) - 指定输出Tensor数据类型,支持的数据类型为 `mindspore.int32` 和 `mindspore.int64` ,默认值: `mindspore.int32` 。
|
||||
- **dtype** (:class:`mindspore.dtype`,可选) - 指定输出Tensor数据类型,支持的数据类型为 `mstype.int32` 和 `mstype.int64` ,默认值: `mstype.int32` 。
|
||||
|
||||
输出:
|
||||
- **y** (Tensor) - 矩阵的下三角形部分的索引。数据类型由 `dtype` 指定,shape为 :math:`(2, tril_size)` ,其中, `tril_size` 为上三角矩阵的元素总数。
|
||||
|
|
|
@ -28,3 +28,4 @@ mindspore.ops.TruncatedNormal
|
|||
- **ValueError** - `shape` 的元素不全大于零。
|
||||
- **ValueError** - `shape` 不是一维Tensor。
|
||||
- **ValueError** - 输出Tensor的元素个数大于1000000。
|
||||
|
||||
|
|
|
@ -396,7 +396,6 @@ Array Operation
|
|||
mindspore.ops.normal
|
||||
mindspore.ops.nonzero
|
||||
mindspore.ops.numel
|
||||
mindspore.ops.orgqr
|
||||
mindspore.ops.permute
|
||||
mindspore.ops.population_count
|
||||
mindspore.ops.range
|
||||
|
|
|
@ -65,7 +65,7 @@ abstract::ShapePtr BiasAddInferShape(const PrimitivePtr &primitive, const std::v
|
|||
if ((data_format == static_cast<int64_t>(Format::NCDHW)) && input_shape.size() != x_max_rank &&
|
||||
(is_ascend || is_cpu)) {
|
||||
MS_EXCEPTION(ValueError) << "For '" << prim_name
|
||||
<< "', NCDHW format only supports 5-D input on Ascend or CPU, but got a"
|
||||
<< "', NCDHW format only supports 5-D input on Ascend or CPU, but got a "
|
||||
<< input_shape.size() << "-D input.";
|
||||
}
|
||||
if ((data_format == static_cast<int64_t>(Format::NHWC) || data_format == static_cast<int64_t>(Format::NCHW)) &&
|
||||
|
|
|
@ -5397,6 +5397,21 @@ class BroadcastTo(Primitive):
|
|||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
||||
Examples:
|
||||
>>> shape = (2, 3)
|
||||
>>> x = Tensor(np.array([1, 2, 3]).astype(np.float32))
|
||||
>>> output = ops.BroadcastTo(shape=shape)(x)
|
||||
>>> print(output)
|
||||
[[1. 2. 3.]
|
||||
[1. 2. 3.]]
|
||||
|
||||
>>> shape = (-1, 2)
|
||||
>>> x = Tensor(np.array([[1], [2]]).astype(np.float32))
|
||||
>>> output = ops.BroadcastTo(shape=shape)(x)
|
||||
>>> print(output)
|
||||
[[1. 1.]
|
||||
[2. 2.]]
|
||||
"""
|
||||
|
||||
@prim_attr_register
|
||||
|
@ -7752,6 +7767,12 @@ class PopulationCount(Primitive):
|
|||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
||||
Examples:
|
||||
>>> input_x = Tensor([0, 1, 3], mindspore.int16)
|
||||
>>> output = ops.PopulationCount()(input_x)
|
||||
>>> print(output)
|
||||
[0 1 2]
|
||||
"""
|
||||
|
||||
@prim_attr_register
|
||||
|
|
|
@ -5957,6 +5957,12 @@ class Trunc(Primitive):
|
|||
|
||||
Supported Platforms:
|
||||
``GPU`` ``CPU``
|
||||
|
||||
Examples:
|
||||
>>> x = Tensor(np.array([3.4742, 0.5466, -0.8008, -3.9079]), mindspore.float32)
|
||||
>>> output = ops.Trunc()(x)
|
||||
>>> print(output)
|
||||
[ 3. 0. -0. -3.]
|
||||
"""
|
||||
|
||||
@prim_attr_register
|
||||
|
@ -7295,7 +7301,7 @@ class TrilIndices(Primitive):
|
|||
col (int): number of columns in the 2-D matrix.
|
||||
offset (int, optional): diagonal offset from the main diagonal. Default: 0.
|
||||
dtype (:class:`mindspore.dtype`, optional): The specified type of output tensor.
|
||||
An optional data type of `mindspore.int32` and `mindspore.int64`. Default: `mindspore.int32`.
|
||||
An optional data type of `mstype.int32` and `mstype.int64`. Default: `mstype.int32`.
|
||||
|
||||
Outputs:
|
||||
- **y** (Tensor) - indices of the elements in lower triangular part of matrix. The type specified by `dtype`.
|
||||
|
@ -7311,7 +7317,7 @@ class TrilIndices(Primitive):
|
|||
``GPU`` ``CPU``
|
||||
|
||||
Examples:
|
||||
>>> net = ops.TrilIndices(4, 3, -1, mindspore.int64)
|
||||
>>> net = ops.TrilIndices(4, 3, -1, mstype.int64)
|
||||
>>> output = net()
|
||||
>>> print(output)
|
||||
[[1 2 2 3 3 3]
|
||||
|
@ -7518,8 +7524,8 @@ class TriuIndices(Primitive):
|
|||
row (int): number of rows in the 2-D matrix.
|
||||
col (int): number of columns in the 2-D matrix.
|
||||
offset (int, optional): diagonal offset from the main diagonal. Default: 0.
|
||||
dtype (:class:`mindspore.dtype`): The specified type of output tensor.
|
||||
An optional data type of `mindspore.int32` and `mindspore.int64`. Default: `mindspore.int32`.
|
||||
dtype (:class:`mindspore.dtype`, optional): The specified type of output tensor.
|
||||
An optional data type of `mstype.int32` and `mstype.int64`. Default: `mstype.int32`.
|
||||
|
||||
Outputs:
|
||||
- **y** (Tensor) - indices of the elements in lower triangular part of matrix. The type specified by `dtype`.
|
||||
|
@ -7535,7 +7541,7 @@ class TriuIndices(Primitive):
|
|||
``GPU`` ``CPU``
|
||||
|
||||
Examples:
|
||||
>>> net = ops.TriuIndices(5, 4, 2, mindspore.int64)
|
||||
>>> net = ops.TriuIndices(5, 4, 2, mstype.int64)
|
||||
>>> output = net()
|
||||
>>> print(output)
|
||||
[[0 0 1]
|
||||
|
@ -7795,3 +7801,40 @@ class Ormqr(Primitive):
|
|||
self.transpose = validator.check_value_type('transpose', transpose, [bool], self.name)
|
||||
self.add_prim_attr('left', self.left)
|
||||
self.add_prim_attr('transpose', self.transpose)
|
||||
|
||||
|
||||
class Roll(Primitive):
|
||||
"""
|
||||
Rolls the elements of a tensor along an axis.
|
||||
|
||||
Refer to :func:`mindspore.ops.roll` for more details.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU``
|
||||
|
||||
Examples:
|
||||
>>> input_x = Tensor(np.array([0, 1, 2, 3, 4]).astype(np.float32))
|
||||
>>> op = ops.Roll(shift=2, axis=0)
|
||||
>>> output = op(input_x)
|
||||
>>> print(output)
|
||||
[3. 4. 0. 1. 2.]
|
||||
>>> input_x = Tensor(np.array([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]).astype(np.float32))
|
||||
>>> op = ops.Roll(shift=-1, axis=0)
|
||||
>>> output = op(input_x)
|
||||
>>> print(output)
|
||||
"""
|
||||
|
||||
@prim_attr_register
|
||||
def __init__(self, shift, axis):
|
||||
"""Initialize Roll"""
|
||||
if context.get_context("device_target") == "GPU":
|
||||
validator.check_value_type("shift", shift, [int, tuple, list], self.name)
|
||||
validator.check_value_type("axis", axis, [int, tuple, list], self.name)
|
||||
else:
|
||||
if isinstance(shift, (tuple, list)) and isinstance(axis, (tuple, list)):
|
||||
validator.check_equal_int(len(shift), 1, "shift size", self.name)
|
||||
validator.check_equal_int(len(axis), 1, "shift size", self.name)
|
||||
validator.check_equal_int(axis[0], 0, "axis", self.name)
|
||||
elif isinstance(shift, int) and isinstance(axis, int):
|
||||
validator.check_equal_int(axis, 0, "axis", self.name)
|
||||
self.init_prim_io_names(inputs=['input_x'], outputs=['output'])
|
||||
|
|
|
@ -7116,6 +7116,24 @@ class CTCGreedyDecoder(Primitive):
|
|||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``CPU``
|
||||
|
||||
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)
|
||||
>>> sequence_length = Tensor(np.array([2, 2]), mindspore.int32)
|
||||
>>> decoded_indices, decoded_values, decoded_shape, log_probability = ops.CTCGreedyDecoder()(inputs,
|
||||
>>> sequence_length)
|
||||
>>> print(decoded_indices)
|
||||
[[0 0]
|
||||
[0 1]
|
||||
[1 0]]
|
||||
>>> print(decoded_values)
|
||||
[0 1 0]
|
||||
>>> print(decoded_shape)
|
||||
[2 2]
|
||||
>>> print(log_probability)
|
||||
[[-1.2]
|
||||
[-1.3]]
|
||||
"""
|
||||
|
||||
@prim_attr_register
|
||||
|
|
|
@ -34,8 +34,8 @@ class NonDeterministicInts(Primitive):
|
|||
The number of elements of output can not exceed 1000000.
|
||||
|
||||
Args:
|
||||
dtype (mindspore.dtype, optional): The date type of output. The supported values are: mindspore.int32
|
||||
and mindspore.int64. Default: mindspore.int64.
|
||||
dtype (mindspore.dtype, optional): The date type of output. The supported values are: mstype.int32
|
||||
and mstype.int64. Default: mstype.int64.
|
||||
|
||||
Inputs:
|
||||
- **shape** (Tensor) - The shape of random tensor to be generated. The supported values are:
|
||||
|
@ -46,7 +46,7 @@ class NonDeterministicInts(Primitive):
|
|||
|
||||
Raises:
|
||||
TypeError: If `shape` is not a Tensor.
|
||||
TypeError: If `dtype` is not mindspore.int32 or mindspore.int64.
|
||||
TypeError: If `dtype` is not mstype.int32 or mstype.int64.
|
||||
ValueError: If `shape` has negative elements.
|
||||
ValueError: If `shape` has less than 2 elements.
|
||||
ValueError: If `shape` is not a 1-D tensor.
|
||||
|
@ -227,14 +227,13 @@ class RandomGamma(Primitive):
|
|||
Args:
|
||||
seed (int, optional): The operator-level random seed, used to generate random numbers,
|
||||
must be non-negative. Default: 0.
|
||||
seed2 (int, optional): The global random seed and it will combile with the operator-level
|
||||
seed2 (int, optional): The global random seed, which combines with the operator-level
|
||||
random seed to determine the final generated random number, must be non-negative. Default: 0.
|
||||
|
||||
Inputs:
|
||||
- **shape** (Tensor) - The shape of random tensor to be generated.
|
||||
Must be one of the following types: int32, int64. 1-D integer tensor.
|
||||
- **alpha** (Tensor) - α is the shape parameter of RandomGamma distribution.
|
||||
It must be greater than 0. Must be one of the following types: half, float32, float64.
|
||||
- **shape** (Tensor) - The shape of random tensor to be generated. It must be constant value.
|
||||
- **alpha** (Tensor) - α is the shape parameter of RandomGamma distribution, it mainly determines the
|
||||
shape of the graph curve. It must be greater than 0 and have date type float32.
|
||||
|
||||
Outputs:
|
||||
Tensor. The shape should be equal to the concat shape between the input `shape` and `alpha`.
|
||||
|
@ -580,7 +579,7 @@ class RandomPoisson(Primitive):
|
|||
the seed is set by the given seed. Otherwise, it is seeded by a random seed. Default: 0.
|
||||
seed2 (int, optional): A second seed to avoid seed collision. Default: 0.
|
||||
|
||||
dtype (mindspore.dtype, optional): The type of output. Default: mindspore.int64.
|
||||
dtype (mindspore.dtype, optional): The type of output. Default: mstype.int64.
|
||||
|
||||
Inputs:
|
||||
- **shape** (Tensor) - The shape of random tensor to be generated, 1-D Tensor, whose dtype must be in
|
||||
|
|
Loading…
Reference in New Issue