expose Primitve APIs part4

This commit is contained in:
lilinjie 2022-11-15 16:28:15 +08:00
parent 01ef7c3d1e
commit 98c31d93dd
19 changed files with 512 additions and 130 deletions

View File

@ -1,7 +1,7 @@
mindspore.ops.Size
==================
.. py:class:: mindspore.ops.Size()
.. py:class:: mindspore.ops.Size
返回一个Scalar类型为整数表示输入Tensor的大小即Tensor中元素的总数。

View File

@ -0,0 +1,19 @@
mindspore.ops.Trace
====================
.. py:class:: mindspore.ops.Trace
返回在Tensor的对角线方向上的总和。
.. note::
输入必须是Tensor复数类型暂不支持。
输入:
- **x** (Tensor) - 二维Tensor。
输出:
Tensor其数据类型与 `x` 一致,含有一个元素。
异常:
- **TypeError** - 如果 `x` 不是Tensor。
- **ValueError** - 如果当 `x` 的维度不是2。

View File

@ -0,0 +1,33 @@
mindspore.ops.TridiagonalMatMul
================================
.. py:class:: mindspore.ops.TridiagonalMatMul
返回两个矩阵的乘积,其中左边的矩阵是三对角矩阵。
输入:
- **superdiag** (Tensor) - 矩阵乘法左边矩阵的高对角线。
数据类型为float16、float32、double、complex64和complex128。
shape为 :math:`(..., 1, M)`
最后一个元素被忽略。
- **maindiag** (Tensor) - 矩阵乘法左边矩阵的主对角线。
数据类型为float16、float32、double、complex64和complex128。
shape为 :math:`(..., 1, M)`
- **subdiag** (Tensor) - 矩阵乘法左边矩阵的低对角线。
数据类型为float16、float32、double、complex64和complex128。
shape为 :math:`(..., 1, M)`
第一个元素被忽略。
- **rhs** (Tensor) - 矩阵乘法右边的MxN矩阵。
数据类型为float16、float32、double、complex64和complex128。
shape为 :math:`(..., M, N)`
输出:
Tensor其数据类型和shape与 `rhs` 一致。
异常:
- **TypeError** - 如果 `superdiag``maindiag``subdiag``rhs` 的数据类型不是float16、float32、double、complex64或complex128。
- **ValueError** - 如果 `superdiag``maindiag``subdiag` 的列数不等于 `rhs` 的行数。
- **ValueError** - 如果 `superdiag``maindiag``subdiag` 的行数不等于1。
- **ValueError** - 如果 `superdiag``maindiag``subdiag` 的秩以及 `rhs` 行秩小于2。
- **ValueError** - 如果 `superdiag``maindiag``subdiag` 的shape不相同。
- **ValueError** - 如果 `superdiag``maindiag``subdiag``rhs` 各自忽略掉最后两个元素之后的shape不一致。

View File

@ -0,0 +1,22 @@
mindspore.ops.Tril
===================
.. py:class:: mindspore.ops.Tril(diagonal=0)
返回单个矩阵二维Tensor或批次输入矩阵的下三角形部分其他位置的元素将被置零。
矩阵的下三角形部分定义为对角线本身和对角线以下的元素。
参数:
- **diagonal** (int可选) - 指定对角线位置默认值0指定主对角线。
输入:
- **x** (Tensor) - 输入Tensor。shape为 :math:`(x_1, x_2, ..., x_R)` 其rank至少为2。
支持的数据类型有包括所有数值型和bool类型。
输出:
Tensor其数据类型和shape维度与 `input_x` 相同。shape的第一个维度等于 `segment_ids` 最后一个元素的值加1其他维度与 `input_x` 一致。
异常:
- **TypeError** - 如果 `x` 不是Tensor。
- **TypeError** - 如果 `diagonal` 不是int类型。
- **TypeError** - 如果 `x` 的数据类型既不是数值型也不是bool。
- **ValueError** - 如果 `x` 的秩小于2。

View File

@ -0,0 +1,25 @@
mindspore.ops.TrilIndices
==========================
.. py:class:: mindspore.ops.TrilIndices(row, col, offset=0, dtype=mindspore.int32)
返回一个包含 `row` * `col` 的矩阵的下三角形部分的索引的Tensor。Tensor的shape为 :math:`(2, tril_size)` ,其中, `tril_size` 为下三角矩阵的元素总数。第一行包含所有索引的行坐标,第二行包含列坐标。索引按行排序,然后按列排序。
矩阵的下三角形部分定义为对角线本身和对角线以下的元素。
.. note::
在CUDA上运行的时候 `row` * `col` 必须小于2^59以防止计算时溢出。
参数:
- **row** (int) - 2-D 矩阵的行数。
- **col** (int) - 2-D 矩阵的列数。
- **offset** (int可选) - 对角线偏移量。默认值0。
- **dtype** (:class:`mindspore.dtype` ,可选) - 指定输出Tensor数据类型支持的数据类型为 `mindspore.int32``mindspore.int64` ,默认值: `mindspore.int32`
输出:
- **y** (Tensor) - 矩阵的下三角形部分的索引。数据类型由 `dtype` 指定shape为 :math:`(2, tril_size)` ,其中, `tril_size` 为下三角矩阵的元素总数。
异常:
- **TypeError** - 如果 `row``col``offset` 不是int。
- **TypeError** - 如果 `dtype` 的类型不是int32或int64。
- **ValueError** - 如果 `row` 或者 `col` 小于零。

View File

@ -0,0 +1,51 @@
mindspore.ops.TripletMarginLoss
===============================
.. py:class:: mindspore.ops.TripletMarginLoss(p=2, eps=1e-06, swap=False, reduction='mean')
三元组损失函数。
创建一个标准用于计算输入Tensor :math:`x`:math:`x2`:math:`x3` 与大于:math:`0``margin` 之间的三元组损失值。
可以用来测量样本之间的相似度。一个三元组包含 `a``p``n` (即分别代表示 `anchor``positive examples``negative examples` )。
所有输入Tensor的shape都应该为 :math:`(N, D)`
距离交换在V. Balntas、E. Riba等人在论文 `Learning local feature descriptors with triplets and shallow convolutional neural networks <http://158.109.8.37/files/BRP2016.pdf>`_ 中有详细的阐述。
对于每个小批量样本,损失值为:
.. math::
L(a, p, n) = \max \{d(a_i, p_i) - d(a_i, n_i) + {\rm margin}, 0\}
其中
.. math::
d(x_i, y_i) = \left\lVert {\bf x}_i - {\bf y}_i \right\rVert_p
参数:
- **p** (int可选) - 成对距离的范数。默认值2。
- **eps** (float可选) - 默认值1e-06。
- **swap** (bool可选) - 距离交换在V. Balntas、E. Riba等人在论文 `Learning shallow convolutional feature descriptors with triplet losses` 默认值False。
- **reduction** (str可选) - 指定要应用于输出的缩减。取值为"mean"、"sum"或"none"。默认值:"mean"。
输入:
- **x** (Tensor) - 从训练集随机选取的样本。数据类型为BasicType。
- **positive** (Tensor) - 与 `x` 为同一类的样本数据类型与shape与 `x` 一致。
- **negative** (Tensor) - 与 `x` 为异类的样本数据类型与shape与 `x` 一致。
- **margin** (Tensor) - 拉进 `a``p` 之间的距离,拉远 `a``n` 之间的距离。
输出:
Tensor或Scalar如果 `reduction` 为"none"其shape为 :math:`(N)`。否则将返回Scalar。
异常:
- **TypeError** - `x``positive``negative` 或者 `margin` 不是Tensor。
- **TypeError** - `x``positive` 或者 `negative` 的数据类型不是BasicType。
- **TypeError** - `x``positive` 或者 `negative` 的数据类型不一致。
- **TypeError** - `margin` 的数据类型不是float32。
- **TypeError** - `p` 的数据类型不是int。
- **TypeError** - `eps` 的数据类型不是float。
- **TypeError** - `swap` 的数据类型不是bool。
- **ValueError** - `x``positive``negative` 的维度同时小于等于1。
- **ValueError** - `x``positive``negative` 的维度大于等于8。
- **ValueError** - `margin` 的shape长度不为0。
- **ValueError** - `x``positive``negative` 三者之间的shape无法广播。
- **ValueError** - `reduction` 不为"mean"、"sum"或"none"。

View File

@ -0,0 +1,21 @@
mindspore.ops.Triu
===================
.. py:class:: mindspore.ops.Triu(diagonal=0)
返回单个矩阵上三角形部分,其他位置的元素将被置零。
矩阵的上三角形部分定义为对角线和对角线上方的元素。
参数:
- **diagonal** (int可选) - 可选参数指定对角线位置默认值0指定主对角线。
输入:
- **x** (Tensor) - 输入Tensor。shape为 :math:`(N, *)` ,其中 * 为任意数量的额外维度。其数据类型为数值型。
输出:
Tensor其数据类型和shape维度与输入相同。
异常:
- **TypeError** - 如果 `x` 不是Tensor。
- **TypeError** - 如果 `diagonal` 不是int类型。
- **ValueError** - 如果 `x` 的shape长度小于1。

View File

@ -0,0 +1,25 @@
mindspore.ops.TriuIndices
==========================
.. py:class:: mindspore.ops.TriuIndices(row, col, offset=0, dtype=mindspore.int32)
返回一个包含 `row` * `col` 的矩阵的上三角形部分的索引的Tensor。Tensor的shape为 :math:`(2, tril_size)` ,其中, `tril_size` 为上三角矩阵的元素总数。第一行包含所有索引的行坐标,第二行包含列坐标。索引按行排序,然后按列排序。
矩阵的下三角形部分定义为对角线本身和对角线以上的元素。
.. note::
在CUDA上运行的时候 `row` * `col` 必须小于2^59以防止计算时溢出。
参数:
- **row** (int) - 2-D 矩阵的行数。
- **col** (int) - 2-D 矩阵的列数。
- **offset** (int可选) - 对角线偏移量。默认值0。
- **dtype** (:class:`mindspore.dtype`,可选) - 指定输出Tensor数据类型支持的数据类型为 `mindspore.int32``mindspore.int64` ,默认值: `mindspore.int32`
输出:
- **y** (Tensor) - 矩阵的下三角形部分的索引。数据类型由 `dtype` 指定shape为 :math:`(2, tril_size)` ,其中, `tril_size` 为上三角矩阵的元素总数。
异常:
- **TypeError** - 如果 `row``col``offset` 不是int。
- **TypeError** - 如果 `dtype` 的类型不是int32或int64。
- **ValueError** - 如果 `row` 或者 `col` 小于零。

View File

@ -0,0 +1,30 @@
mindspore.ops.TruncatedNormal
==============================
.. py:class:: mindspore.ops.TruncatedNormal(seed=0, seed2=0, dtype=mindspore.float32)
返回一个具有指定shape的Tensor其数值取自正态分布。
生成的值符合正态分布。
.. warning::
`shape` 所含元素的值必须大于零。输出长度必须不超过1000000。
参数:
- **seed** (int可选) - 随机数种子。如果 `seed` 或者 `seed2` 被设置为非零则使用这个非零值。否则使用一个随机生成的种子。默认值0。
- **seed2** (int可选) - 另一个随机种子避免发生冲突。默认值0。
- **dtype** (int可选) - 指定输出类型。可选值为mindspore.float16、mindspore.float32和mindspore.float64。默认值mindspore.float32。
输入:
- **shape** (Tensor) - 生成Tensor的shape。数据类型必须是mindspore.int32或者mindspore.int64。
输出:
Tensor其shape由 `shape` 决定,数据类型由 `dtype` 决定。其值在[-2,2]范围内。
异常:
- **TypeError** - `shape` 不是Tensor。
- **TypeError** - `dtype``shape` 的数据类型不支持。
- **ValueError** - `seed` 不是整数。
- **ValueError** - `shape` 的元素不全大于零。
- **ValueError** - `shape` 不是一维Tensor。
- **ValueError** - 输出Tensor的元素个数大于1000000。

View File

@ -0,0 +1,8 @@
mindspore.ops.UniqueConsecutive
================================
.. py:class:: mindspore.ops.UniqueConsecutive(return_idx=False, return_counts=False, axis=None)
对输入张量中连续且重复的元素去重。
更多参考详见 :func:`mindspore.ops.unique_consecutive`

View File

@ -0,0 +1,20 @@
mindspore.ops.UnravelIndex
===========================
.. py:class:: mindspore.ops.UnravelIndex
将索引数组转换为坐标数组的元组。
输入:
- **indices** (Tensor) - 其元素将换为shape为 `dims` 的坐标数组。维度为零维或者一维其数据类型为int32或int64。
- **dims** (Tensor) - `indices` 转换之后的shape输入Tensor。其维度必须为1数据类型与 `indices` 一致。
输出:
- **y** - 输出类型与 `indices` 一致。 `y` 的维度必须是二维或者1维如果 `indices` 是零维)。
异常:
- **TypeError** - 如果 `indices``dims` 的数据类型不一致。
- **TypeError** - 如果 `indices``dims` 的数据类型不是int32或int64。
- **ValueError** - 如果 `dims` 维度不等于1或者 `indices` 维度不是0或1。
- **ValueError** - 如果 `indices` 包含负数。

View File

@ -0,0 +1,24 @@
mindspore.ops.UpperBound
=========================
.. py:class:: mindspore.ops.UpperBound(out_type=mindspore.dtype.int32)
返回一个Tensor该Tensor包含用于查找 `values` 的值的在升序排列的 `sorted_x` 中上界的索引。
参数:
- **out_type** (:class:`mindspore.dtype` ,可选) - 指定输出数据类型,支持 `mindspore.dtype.int32``mindspore.dtype.int64` 。默认值: `mindspore.dtype.int32`
输入:
- **sorted_x** (Tensor) - 数据类型为实数的输入Tensor其秩必须为2 `sorted_x` 每一行都需要按升序排序。
- **values** (Tensor) - 数据类型与 `sorted_x` 相同的输入Tensor其秩必须为2两个输入的shape[0]必须一致。
输出:
Tensor数据列选由 `out_type` 决定shape与 `values` 一致。
异常:
- **TypeError** - `sorted_x` 不是Tensor。
- **TypeError** - `values` 不是Tensor。
- **TypeError** - `sorted_x``values` 数据类型不一致。
- **ValueError** - `sorted_x` 的秩不是2。
- **ValueError** - `values` 的秩不是2。
- **ValueError** - `sorted_x``values` 的行数不一致。

View File

@ -0,0 +1,31 @@
mindspore.ops.UpsampleNearest3D
================================
.. py:class:: mindspore.ops.UpsampleNearest3D(output_size=None, scales=None)
执行最近邻上采样操作。
此运算符使用指定的 `output_size``scales` 缩放因子放大输入体积,过程使用最近的邻算法。
必须指定 `output_size``scales` 中的一个值,并且不能同时指定两者。
参数:
- **output_size** (Union[tuple[int], list[int]],可选) - 指定输出体积大小的元组或int列表。默认值None。
- **scales** (Union[tuple[float], list[float]],可选) - 指定上采样因子的元组或float列表。默认值None。
输入:
- **x** (Tensor) - Shape为 :math:`(N, C, D_{in}, H_{in}, W_{in})` 的5维Tensor。支持的数据类型[float16, float32, float64]。
输出:
- **y** (Tensor) - 上采样输出。其shape :math:`(N, C, D_{out}, H_{out}, W_{out})` ,数据类型与 `x` 相同。
异常:
- **TypeError** - 当 `output_size` 不是None并且 `output_size` 不是list[int]或tuple[int]。
- **TypeError** - 当 `scales` 不是None并且 `scales` 不是list[float]或tuple[float]。
- **TypeError** - `x` 的数据类型不是float16也、float32或float64。
- **ValueError** - `output_size` 不为空时含有非正数值。
- **ValueError** - `scales` 不为空时含有非正数值。
- **ValueError** - `x` 维度不为5。
- **ValueError** - `scales``output_size` 同时被指定或都不被指定。
- **ValueError** - `scales` 被指定时其含有的元素个数不为3。
- **ValueError** - `output_size` 被指定时其含有的元素个数不为3。

View File

@ -0,0 +1,34 @@
mindspore.ops.UpsampleTrilinear3D
=================================
.. py:class:: mindspore.ops.UpsampleTrilinear3D(output_size=None, scales=None, align_corners=False)
输入为5维度Tensor跨其中3维执行三线性插值上调采样。
此运算符使用指定的 `output_size``scales` 缩放因子放大输入体积,过程使用三线性上调算法。
.. note::
必须指定 `output_size``scales` 中的一个值,并且不能同时指定两者。
参数:
- **output_size** (Union[tuple[int], list[int]],可选) - 包含3个int的元组或列表。元素分别为 :math:`(output\_depth, output\_height, output\_width)` 。只能指定 `output_size``scales` 中的一个值。默认值None。
- **scales** (Union[tuple[float], list[float]],可选) - 包含3个float的元组或列表。元素分别为 :math:`(scale\_depth, scale\_height, scale\_width)` 。 默认值None。
- **align_corners** (bool可选) - 如果为True则输入和输出Tensor由其角像素的中心点对齐保留角像素处的值。如果为False则输入和输出Tensor由其角像素的角点对齐插值对边界外值使用边值填充。默认值False。
输入:
- **x** (Tensor) - Shape为 :math:`(N, C, D_{in}, H_{in}, W_{in})` 的5维Tensor。支持的数据类型[float16, float32, float64]。
输出:
- **y** (Tensor) - 上采样输出。其shape :math:`(N, C, D_{out}, H_{out}, W_{out})` ,数据类型与 `x` 相同。
异常:
- **TypeError** - 当 `output_size` 不是None并且 `output_size` 不是list[int]或tuple[int]。
- **TypeError** - 当 `scales` 不是None并且 `scales` 不是list[float]或tuple[float]。
- **TypeError** - `x` 的数据类型不是float16也、float32或float64。
- **TypeError** - `align_corners` 的数据类型不是bool。
- **ValueError** - `output_size` 不为空时含有非正数值。
- **ValueError** - `scales` 不为空时含有非正数值。
- **ValueError** - `x` 维度不为5。
- **ValueError** - `scales``output_size` 同时被指定或都不被指定。
- **ValueError** - `scales` 被指定时其含有的元素个数不为3。
- **ValueError** - `output_size` 被指定时其含有的元素个数不为3。

View File

@ -0,0 +1,26 @@
mindspore.ops.Zeta
===================
.. py:class:: mindspore.ops.Zeta
计算输入Tensor的Hurwitz zeta函数ζ(x,q)值。
.. warning::
此接口是试验性的原型接口,可能会被删除/修改。
.. math::
\\zeta \\left ( x,q \\right )= \\textstyle \\sum_{n=0} ^ {\\infty} \\left ( q+n\\right )^{-x}
输入:
- **x** (Tensor) - Tensor数据类型为float32、float64。
- **q** (Tensor) - Tensor数据类型与 `x` 一致。
输出:
Tensor数据类型和shape与输入shape相同。
异常:
- **TypeError** - `x``q` 不是Tensor。
- **TypeError** - `x` 的数据类型既不是float32也不是float64。
- **TypeError** - `q` 的数据类型既不是float32也不是float64。
- **ValueError** - `x``q` 的shape不同。

View File

@ -79,23 +79,22 @@ class UnravelIndex(Primitive):
Converts an array of flat indices into a tuple of coordinate arrays.
Inputs:
- **indices** (Tensor) - Must be one of the following types: int32, int64.
whose elements are indices into the flattened version of an array of dimensions dims.
The dimension of 'indices' must be 0-D or 1-D.
- **dims** (Tensor) - Must have the same type as indices.
The shape of the array to use for unraveling indices.
The dimension of 'dims' must be 1-D.
- **indices** (Tensor) - Input Tensor whose elements are indices converting into
the flattened version of an array of dimensions dims.
The dimension of `indices` must be 0-D or 1-D.
Must be one of the following types: int32, int64.
- **dims** (Tensor) - The shape of the array to use for unraveling indices.
The dimension of `dims` must be 1-D. Must have the same type as `indices`.
Outputs:
- **y** (Tensor) - Has the same type as indices.
The dimension of 'y' can be 2-D or 1-D(if indices is 0D).
- **y** (Tensor) - Has the same type as `indices`.
The dimension of `y` can be 2-D or 1-D(if `indices` is 0D).
Raises:
TypeError: The data type of input0 need be same with input1.
TypeError: Both input data types are supported only support int32, int64.
ValueError: Dims shape must be equal to 1 or indices shape must be equal to 1 or 0.
ValueError: Index out of boundary or index must be greater than 0.
ValueError: All dimensions must be greater than 0.
TypeError: If the data type of `indices` and `dims` are different.
TypeError: If the data type of `indices` and `dims` is not int32 or int64.
ValueError: If the dimension of `dims` is not 1 or dimension of `indices` is not 1 or 0.
ValueError: If `indices` contains negative elements.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -225,7 +224,7 @@ class ExpandDims(PrimitiveWithCheck):
"""
Adds an additional dimension to `input_x` at the given axis.
Refer to :func:`mindspore.ops.expand_dims` for more detail.
Refer to :func:`mindspore.ops.expand_dims` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -636,7 +635,7 @@ class Reshape(PrimitiveWithCheck):
"""
Rearranges the input Tensor based on the given shape.
Refer to :func:`mindspore.ops.reshape` for more detail.
Refer to :func:`mindspore.ops.reshape` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -703,7 +702,7 @@ class Shape(Primitive):
"""
Returns the shape of the input tensor. And it used to be static shape.
Refer to :func:`mindspore.ops.shape` for more detail.
Refer to :func:`mindspore.ops.shape` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -777,7 +776,7 @@ class Squeeze(Primitive):
"""
Return the Tensor after deleting the dimension of size 1 in the specified `axis`.
Refer to :func:`mindspore.ops.squeeze` for more detail.
Refer to :func:`mindspore.ops.squeeze` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -809,7 +808,7 @@ class Transpose(Primitive):
"""
Permutes the dimensions of the input tensor according to input permutation.
Refer to :func:`mindspore.ops.transpose` for more detail.
Refer to :func:`mindspore.ops.transpose` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -943,7 +942,7 @@ class UniqueConsecutive(Primitive):
"""
Returns the elements that are unique in each consecutive group of equivalent elements in the input tensor.
Refer to :func:`mindspore.ops.unique_consecutive` for more detail.
Refer to :func:`mindspore.ops.unique_consecutive` for more details.
Supported Platforms:
``Ascend`` ``GPU``
@ -985,7 +984,7 @@ class Gather(Primitive):
where params represents the input `input_params`, and indices represents the index to be sliced `input_indices`.
Refer to :func:`mindspore.ops.gather` for more detail.
Refer to :func:`mindspore.ops.gather` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -1137,7 +1136,7 @@ class UniqueWithPad(Primitive):
the UniqueWithPad operator will fill the `y` Tensor with the `pad_num` specified by the user
to make it have the same shape as the Tensor `idx`.
Refer to :func:`mindspore.ops.unique_with_pad` for more detail.
Refer to :func:`mindspore.ops.unique_with_pad` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -1161,7 +1160,7 @@ class Split(Primitive):
"""
Splits the input tensor into output_num of tensors along the given axis and output numbers.
Refer to :func:`mindspore.ops.split` for more detail.
Refer to :func:`mindspore.ops.split` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -1208,7 +1207,7 @@ class Rank(PrimitiveWithInfer):
"""
Returns the rank of a tensor.
Refer to :func:`mindspore.ops.rank` for more detail.
Refer to :func:`mindspore.ops.rank` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -1245,7 +1244,7 @@ class Size(PrimitiveWithInfer):
Returns a Scalar of type int that represents the size of the input Tensor and the total number of elements in the
Tensor.
Refer to :func:`mindspore.ops.size` for more detail.
Refer to :func:`mindspore.ops.size` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -1280,7 +1279,7 @@ class MatrixDiagV3(Primitive):
"""
Returns a batched diagonal tensor with given batched diagonal values.
Refer to :func:`mindspore.ops.matrix_diag` for more detail.
Refer to :func:`mindspore.ops.matrix_diag` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -1316,7 +1315,7 @@ class MatrixDiagPartV3(Primitive):
r"""
Returns the diagonal part of a tensor.
Refer to :func:`mindspore.ops.matrix_diag_part` for more detail.
Refer to :func:`mindspore.ops.matrix_diag_part` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -1460,7 +1459,7 @@ class Fill(PrimitiveWithCheck):
"""
Create a Tensor of the specified shape and fill it with the specified value.
Refer to :func:`mindspore.ops.fill` for more detail.
Refer to :func:`mindspore.ops.fill` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -1499,7 +1498,7 @@ class Fills(Primitive):
"""
Create a tensor of the same shape and type as the input tensor and fill it with specified value.
Refer to :func:`mindspore.ops.fills` for more detail.
Refer to :func:`mindspore.ops.fills` for more details.
Supported Platforms:
``GPU``
@ -1528,7 +1527,7 @@ class Ones(Primitive):
Creates a tensor with shape described by the first argument and
fills it with value ones in type of the second argument.
Refer to :func:`mindspore.ops.ones` for more detail.
Refer to :func:`mindspore.ops.ones` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -1591,7 +1590,7 @@ class OnesLike(Primitive):
"""
Returns a Tensor with a value of 1 and its shape and data type is the same as the input.
Refer to :func:`mindspore.ops.ones_like` for more detail.
Refer to :func:`mindspore.ops.ones_like` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -1646,7 +1645,7 @@ class TupleToArray(PrimitiveWithInfer):
"""
Converts a tuple to a tensor.
Refer to :func:`mindspore.ops.tuple_to_array` for more detail.
Refer to :func:`mindspore.ops.tuple_to_array` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -1693,7 +1692,7 @@ class ScalarToTensor(PrimitiveWithInfer):
"""
Converts a scalar to a `Tensor`, and converts the data type to the specified type.
Refer to :func:`mindspore.ops.scalar_to_tensor` for more detail.
Refer to :func:`mindspore.ops.scalar_to_tensor` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -1800,7 +1799,7 @@ class Argmax(Primitive):
"""
Returns the indices of the maximum value of a tensor across the axis.
Refer to :func:`mindspore.ops.argmax` for more detail.
Refer to :func:`mindspore.ops.argmax` for more details.
If the shape of input tensor is :math:`(x_1, ..., x_N)`, the shape of the output tensor will be
:math:`(x_1, ..., x_{axis-1}, x_{axis+1}, ..., x_N)`.
@ -2074,7 +2073,7 @@ class Tile(PrimitiveWithInfer):
r"""
Replicates an input tensor with given multiples times.
Refer to :func:`mindspore.ops.tile` for more detail.
Refer to :func:`mindspore.ops.tile` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -2193,7 +2192,7 @@ class UnsortedSegmentSum(Primitive):
r"""
Computes the sum of a tensor along segments.
Refer to :func:`mindspore.ops.unsorted_segment_sum` for more detail.
Refer to :func:`mindspore.ops.unsorted_segment_sum` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -2226,7 +2225,7 @@ class UnsortedSegmentMin(PrimitiveWithCheck):
r"""
Computes the minimum of a tensor along segments.
Refer to :func:`mindspore.ops.unsorted_segment_min` for more detail.
Refer to :func:`mindspore.ops.unsorted_segment_min` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -2276,7 +2275,7 @@ class UnsortedSegmentMax(PrimitiveWithCheck):
r"""
Computes the maximum along segments of a tensor.
Refer to :func:`mindspore.ops.unsorted_segment_max` for more detail.
Refer to :func:`mindspore.ops.unsorted_segment_max` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -2384,7 +2383,7 @@ class UnsortedSegmentProd(Primitive):
"""
Computes the product of a tensor along segments.
Refer to :func:`mindspore.ops.unsorted_segment_prod` for more detail.
Refer to :func:`mindspore.ops.unsorted_segment_prod` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -2413,7 +2412,7 @@ class Concat(PrimitiveWithCheck):
r"""
Connect tensor in the specified axis.
Refer to :func:`mindspore.ops.concat` for more detail.
Refer to :func:`mindspore.ops.concat` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -2627,7 +2626,7 @@ class Stack(PrimitiveWithInfer):
r"""
Stacks a list of tensors in specified axis.
Refer to :func:`mindspore.ops.stack` for more detail.
Refer to :func:`mindspore.ops.stack` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -2779,7 +2778,7 @@ class Slice(Primitive):
"""
Slices a tensor in the specified shape.
Refer to :func:`mindspore.ops.slice` for more detail.
Refer to :func:`mindspore.ops.slice` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -3062,7 +3061,7 @@ class StridedSlice(PrimitiveWithInfer):
Extracts a strided slice of a tensor.
Refer to :func:`mindspore.ops.strided_slice` for more detail.
Refer to :func:`mindspore.ops.strided_slice` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -3500,7 +3499,7 @@ class Diag(PrimitiveWithCheck):
Constructs a diagonal tensor with a given diagonal values.
Refer to :func:`mindspore.ops.diag` for more detail.
Refer to :func:`mindspore.ops.diag` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -3633,7 +3632,7 @@ class Eye(Primitive):
"""
Creates a tensor with ones on the diagonal and zeros in the rest.
Refer to :func:`mindspore.ops.eye` for more detail.
Refer to :func:`mindspore.ops.eye` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -3668,7 +3667,7 @@ class ScatterNd(Primitive):
.. image:: ScatterNd.png
Refer to :func:`mindspore.ops.scatter_nd` for more detail.
Refer to :func:`mindspore.ops.scatter_nd` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -3855,7 +3854,7 @@ class GatherNd(Primitive):
r"""
Gathers slices from a tensor by indices.
Refer to :func:`mindspore.ops.gather_nd` for more detail.
Refer to :func:`mindspore.ops.gather_nd` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -4363,21 +4362,23 @@ class ScatterSub(Primitive):
class Triu(Primitive):
"""
Returns a tensor with elements below the kth diagonal zeroed.
Returns the higher triangular part of a single Tensor,
the other elements of the result tensor out are set to 0.
The higher triangular part of the matrix is defined as the elements on and above the diagonal.
Args:
diagonal (int): The index of diagonal. Default: 0
diagonal (int, optional): The index of diagonal. Default: 0, indicating the main diagonal.
Inputs:
- **x** (Tensor) - The input tensor. The data type is Number. (N,)
where means, any number of additional dimensions.
- **x** (Tensor) - The input tensor with shape :math:`(N,)`
where means any number of additional dimensions. The data type is Number.
Outputs:
- **y** (Tensor) - A tensor has the same shape and data type as input.
Raises:
TypeError: If `diagonal` is not an int.
TypeError: If `x` is not an Tensor.
TypeError: If `diagonal` is not an int.
ValueError: If length of shape of x is less than 1.
Supported Platforms:
@ -4650,7 +4651,7 @@ class ScatterNdAdd(Primitive):
Using given values to update tensor value through the add operation, along with the input indices.
This operation outputs the `input_x` after the update is done, which makes it convenient to use the updated value.
Refer to :func:`mindspore.ops.scatter_nd_add` for more detail.
Refer to :func:`mindspore.ops.scatter_nd_add` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -4711,7 +4712,7 @@ class ScatterNdSub(Primitive):
Using given values to update tensor value through the subtraction operation, along with the input indices.
This operation outputs the `input_x` after the update is done, which makes it convenient to use the updated value.
Refer to :func:`mindspore.ops.scatter_nd_sub` for more detail.
Refer to :func:`mindspore.ops.scatter_nd_sub` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -4773,7 +4774,7 @@ class ScatterNdMul(_ScatterNdOp):
Using given values to update parameter value through the multiplication operation, along with the input indices.
This operation outputs the `input_x` after the update is done, which makes it convenient to use the updated value.
Refer to :func:`mindspore.ops.scatter_nd_mul` for more detail.
Refer to :func:`mindspore.ops.scatter_nd_mul` for more details.
Supported Platforms:
``GPU`` ``CPU``
@ -5365,7 +5366,7 @@ class BatchToSpaceND(Primitive):
r"""
Divides batch dimension with blocks and interleaves these blocks back into spatial dimensions.
Refer to :func:`mindspore.ops.batch_to_space_nd` for more detail.
Refer to :func:`mindspore.ops.batch_to_space_nd` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -5410,7 +5411,7 @@ class BatchToSpaceNDV2(Primitive):
r"""
Divides batch dimension with blocks and interleaves these blocks back into spatial dimensions.
Refer to :func:`mindspore.ops.batch_to_space_nd` for more detail.
Refer to :func:`mindspore.ops.batch_to_space_nd` for more details.
"""
@prim_attr_register
@ -5424,7 +5425,7 @@ class BroadcastTo(Primitive):
"""
Broadcasts input tensor to a given shape.
Refer to :func:`mindspore.ops.broadcast_to` for more detail.
Refer to :func:`mindspore.ops.broadcast_to` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -5448,7 +5449,7 @@ class Meshgrid(PrimitiveWithInfer):
Given N one-dimensional coordinate tensors, returns a tuple outputs of N N-D
coordinate tensors for evaluating expressions on an N-D grid.
Refer to :func:`mindspore.ops.meshgrid` for more detail.
Refer to :func:`mindspore.ops.meshgrid` for more details.
Supported Platforms:
``Ascend`` ``CPU`` ``GPU``
@ -5814,7 +5815,7 @@ class GatherD(Primitive):
"""
Gathers elements along an axis specified by dim.
Refer to :func:`mindspore.ops.gather_elements` for more detail.
Refer to :func:`mindspore.ops.gather_elements` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -6007,7 +6008,7 @@ class MaskedFill(Primitive):
"""
Fills elements with value where mask is True.
Refer to :func:`mindspore.ops.masked_fill` for more detail.
Refer to :func:`mindspore.ops.masked_fill` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -6261,7 +6262,7 @@ class TensorScatterMax(Primitive):
By comparing the value at the position indicated by `indices` in `x` with the value in the `updates`,
the value at the index will eventually be equal to the largest one to create a new tensor.
Refer to :func:`mindspore.ops.tensor_scatter_max` for more detail.
Refer to :func:`mindspore.ops.tensor_scatter_max` for more details.
Supported Platforms:
``GPU`` ``CPU``
@ -6297,7 +6298,7 @@ class TensorScatterMin(Primitive):
By comparing the value at the position indicated by `indices` in `input_x` with the value in the `updates`,
the value at the index will eventually be equal to the smallest one to create a new tensor.
Refer to :func:`mindspore.ops.tensor_scatter_min` for more detail.
Refer to :func:`mindspore.ops.tensor_scatter_min` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -6335,7 +6336,7 @@ class TensorScatterSub(Primitive):
index, the result of the update will be to subtract these values respectively. This operation is almost
equivalent to using :class:`mindspore.ops.ScatterNdSub` , except that the updates are applied on output `Tensor`
instead of input `Parameter`.
Refer to :func:`mindspore.ops.tensor_scatter_sub` for more detail.
Refer to :func:`mindspore.ops.tensor_scatter_sub` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -6374,7 +6375,7 @@ class TensorScatterAdd(Primitive):
equivalent to using :class:`mindspore.ops.ScatterNdAdd`, except that the updates are applied on output `Tensor`
instead of input `Parameter`.
Refer to :func:`mindspore.ops.tensor_scatter_add` for more detail.
Refer to :func:`mindspore.ops.tensor_scatter_add` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -6412,7 +6413,7 @@ class TensorScatterMul(_TensorScatterOp):
index, the result of the update will be to multiply these values respectively.
The updates are applied on output `Tensor` instead of input `Parameter`.
Refer to :func:`mindspore.ops.tensor_scatter_mul` for more detail.
Refer to :func:`mindspore.ops.tensor_scatter_mul` for more details.
Supported Platforms:
``GPU`` ``CPU``
@ -6450,7 +6451,7 @@ class TensorScatterDiv(_TensorScatterOp):
index, the result of the update will be to divided these values respectively. Except that
the updates are applied on output `Tensor` instead of input `Parameter`.
Refer to :func:`mindspore.ops.tensor_scatter_div` for more detail.
Refer to :func:`mindspore.ops.tensor_scatter_div` for more details.
Supported Platforms:
``GPU`` ``CPU``
@ -6622,7 +6623,7 @@ class SplitV(Primitive):
class TensorScatterElements(Primitive):
"""
Updates the value of the output tensor through the reduction operation.
Refer to :func:`mindspore.ops.tensor_scatter_elements` for more detail.
Refer to :func:`mindspore.ops.tensor_scatter_elements` for more details.
.. warning::
The order in which updates are applied is nondeterministic, meaning that if there
@ -6920,12 +6921,13 @@ class UpperBound(Primitive):
the input values element in the input sorted_x.
Args:
out_type (:class:`mindspore.dtype`): An optional data type of `mindspore.dtype.int32`
and `mindspore.dtype.int64`. Default: `mindspore.dtype.int32`.
out_type (:class:`mindspore.dtype`, optional): Specified output type.
Supported types: `mindspore.dtype.int32` and `mindspore.dtype.int64`.
Default: `mindspore.dtype.int32`.
Inputs:
- **sorted_x** (Tensor) - The input tensor whose dtype is real number. The rank must be 2.
Each row of the sorted_x needs to be sorted in ascending order.
Each row of the `sorted_x` needs to be sorted in ascending order.
- **values** (Tensor) - The input tensor whose dtype is the same as `sorted_x`. The rank must be 2.
The shape[0] of the two inputs must be consistent.
@ -6970,7 +6972,7 @@ class Cummax(Primitive):
"""
Returns the cumulative maximum of elements and the index.
Refer to :func:`mindspore.ops.cummax` for more detail.
Refer to :func:`mindspore.ops.cummax` for more details.
Supported Platforms:
``GPU`` ``CPU``
@ -7109,7 +7111,7 @@ class NonZero(Primitive):
"""
Return a tensor of the positions of all non-zero values.
Refer to :func:`mindspore.ops.nonzero` for more detail.
Refer to :func:`mindspore.ops.nonzero` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -7139,14 +7141,15 @@ class Tril(Primitive):
The lower triangular part of the matrix is defined as the elements on and below the diagonal.
Args:
diagonal (int): An optional attribute indicates the diagonal to consider, default to 0.
diagonal (int, optional): An optional attribute indicates the diagonal to consider, default: 0,
indicating the main didiagonal.
Inputs:
- **x** (Tensor) - A Tensor with shape :math:`(x_1, x_2, ..., x_R)`. The rank must be at least 2.
Supporting all number types including bool.
Outputs:
Tensor, the same shape and data type as the input.
Tensor, the same shape and data type as the input `x`.
Raises:
TypeError: If `x` is not a Tensor.
@ -7205,7 +7208,7 @@ class IndexFill(Primitive):
Fills the elements under the dim dimension of the input Tensor with the input value
by selecting the indices in the order given in index.
Refer to :func:`mindspore.ops.index_fill` for more detail.
Refer to :func:`mindspore.ops.index_fill` for more details.
Inputs:
- **x** (Tensor) - Input tensor.
The shape is :math:`(N,*)` where :math:`*` means, any number of additional dimensions.
@ -7594,7 +7597,7 @@ class AffineGrid(Primitive):
r"""
Generates a 2D or 3D flow field (sampling grid), given a batch of affine matrices theta.
Refer to :func:`mindspore.ops.affine_grid` for more detail.
Refer to :func:`mindspore.ops.affine_grid` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -7732,7 +7735,7 @@ class PopulationCount(Primitive):
r"""
Computes element-wise population count(a.k.a bitsum, bitcount).
Refer to :func:`mindspore.ops.population_count` for more detail.
Refer to :func:`mindspore.ops.population_count` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
@ -7748,7 +7751,7 @@ class TopK(Primitive):
"""
Finds values and indices of the `k` largest entries along the last dimension.
Refer to :func:`mindspore.ops.top_k` for more detail.
Refer to :func:`mindspore.ops.top_k` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``

View File

@ -5976,24 +5976,20 @@ class TridiagonalMatMul(Primitive):
Return the result of a multiplication of two matrices, where the left one is a Tridiagonal Matrix.
Inputs:
- **superdiag** (Tensor) - The input tensor.
- **superdiag** (Tensor) - Superdiagonals of Tridiagonal Matrices to the left of multiplication.
Data types must be: float16, float32, double, complex64, complex128.
The shape is [..., 1, M].
Representing superdiagonals of Tridiagonal Matrices to the left of multiplication.
Last element is ignored.
- **maindiag** (Tensor) - The input tensor.
- **maindiag** (Tensor) - Maindiagonals of Tridiagonal Matrices to the left of multiplication.
Data types must be: float16, float32, double, complex64, complex128.
The shape is [..., 1, M].
Representing maindiagonals of Tridiagonal Matrices to the left of multiplication.
- **subdiag** (Tensor) - The input tensor.
- **subdiag** (Tensor) - Subdiagonals of Tridiagonal Matrices to the left of multiplication.
Data types must be: float16, float32, double, complex64, complex128.
The shape is [..., 1, M].
Representing subdiagonals of Tridiagonal Matrices to the left of multiplication.
First element is ignored.
- **rhs** (Tensor) - The input tensor.
- **rhs** (Tensor) - MxN Matrices to the right of multiplication.
Data types must be: float16, float32, double, complex64, complex128.
The shape is [..., M, N].
Representing MxN Matrices to the right of multiplication.
Outputs:
Tensor, with the same shape and data type as the `rhs`.
@ -6675,13 +6671,13 @@ class Trace(Primitive):
Returns a new tensor that is the sum of the input trace.
Note:
Input must be matrix, and complex number is nor supported at present.
Input must be matrix, and complex number is not supported at present.
Inputs:
- **x**(Tensor) - A matrix to be calculated. The matrix must be two dimensional.
Output:
Tensor, with the same data type as input 'x', and size equals to 1.
Tensor, with the same data type as input `x`, and size equals to 1.
Raises:
TypeError: If `x` is not a Tensor.
@ -6798,7 +6794,7 @@ class SparseSegmentMean(Primitive):
class Zeta(Primitive):
"""
Compute the Hurwitz zeta function ζ(x,q).
Compute the Hurwitz zeta function ζ(x,q) of input Tensor.
.. warning::
This is an experimental prototype that is subject to change and/or deletion.
@ -6809,7 +6805,7 @@ class Zeta(Primitive):
Inputs:
- **x** (Tensor) - A Tensor, types: float32, float64.
- **q** (Tensor) - A Tensor, must have the same shape and type as x.
- **q** (Tensor) - A Tensor, must have the same shape and type as `x`.
Outputs:
Tensor, has the same dtype and shape as the x.
@ -7278,8 +7274,10 @@ class NextAfter(Primitive):
class TrilIndices(Primitive):
r"""
Returns the indices of the lower triangular part of a row-by- col matrix in a 2-by-N Tensor,
where the first row contains row coordinates of all indices and the second row contains column coordinates.
Returns the indices of the lower triangular part of a `row` -by- `col` matrix in a Tensor.
The Tensor has a shape :math:`(2, tril_size)` where :math:`tril_size` is the number of
elements in the lower triangular matrix. The first row contains row coordinates of
all indices and the second row contains column coordinates.
Indices are ordered based on rows and then columns.
The lower triangular part of the matrix is defined as the elements on and below the diagonal.
@ -7290,8 +7288,8 @@ class TrilIndices(Primitive):
Args:
row (int): number of rows in the 2-D matrix.
col (int): number of columns in the 2-D matrix.
offset (int): diagonal offset from the main diagonal. Default: 0.
dtype (:class:`mindspore.dtype`): The specified type of output tensor.
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`.
Outputs:
@ -7526,8 +7524,10 @@ class Orgqr(Primitive):
class TriuIndices(Primitive):
r"""
Returns the indices of the upper triangular part of a row by col matrix in a 2-by-N Tensor,
where the first row contains row coordinates of all indices and the second row contains column coordinates.
Returns the indices of the upper triangular part of a `row` -by- `col` matrix in a Tensor.
The Tensor has a shape :math:`(2, tril_size)` where :math:`tril_size` is the number of
elements in the upper triangular matrix. The first row contains row coordinates of
all indices and the second row contains column coordinates.
Indices are ordered based on rows and then columns.
The upper triangular part of the matrix is defined as the elements on and above the diagonal.
@ -7538,12 +7538,14 @@ class TriuIndices(Primitive):
Args:
row (int): number of rows in the 2-D matrix.
col (int): number of columns in the 2-D matrix.
offset (int): diagonal offset from the main diagonal. Default: 0.
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`.
Outputs:
- **y** (Tensor) - indices of the elements in upper triangular part of matrix. The type specified by `dtype`.
- **y** (Tensor) - indices of the elements in lower triangular part of matrix. The type specified by `dtype`.
The shape of output is :math:`(2, tril_size)`, where :math:`tril_size` is the number of elements in the
lower triangular matrix.
Raises:
TypeError: If `row`, `col` or `offset` is not an int.

View File

@ -3730,7 +3730,7 @@ class ResizeBilinear(PrimitiveWithInfer):
class UpsampleTrilinear3D(Primitive):
r"""
Performs upsampling with trilinear interpolation across 3dims for 5dim inputs.
Performs upsampling with trilinear interpolation across 3dims for 5dim input Tensor.
This operator scale up the volumetric input with specified `output_size` or `scales` factors,
using trilinear upscaling algorithm.
@ -3739,15 +3739,15 @@ class UpsampleTrilinear3D(Primitive):
One of `scales` and `output_size` MUST be specified and it is an error if both are specified.
Args:
output_size (Union[tuple[int], list[int]]): A tuple or list of 3 int
output_size (Union[tuple[int], list[int]], optional): A tuple or list of 3 int
elements :math:`(output\_depth, output\_height, output\_width)`.
Defaults to None. Only one of `scales` and `output_size` can be specified.
scales (Union[tuple[float], list[float]]): A tuple or list of 3 float
scales (Union[tuple[float], list[float]], optional): A tuple or list of 3 float
elements :math:`(scale\_depth, scale\_height, scale\_width)`. Defaults to None.
align_corners (bool): An optional bool. Defaults to false.
If true, the input and output tensors are aligned by the center points of their corner pixels,
align_corners (bool, optional): An optional bool. Defaults to false.
If True, the input and output tensors are aligned by the center points of their corner pixels,
preserving the values at the corner pixels.
If false, the input and output tensors are aligned by the corner points of their corner pixels,
If False, the input and output tensors are aligned by the corner points of their corner pixels,
and the interpolation use edge value padding for out of boundary values.
Inputs:
@ -3759,8 +3759,8 @@ class UpsampleTrilinear3D(Primitive):
Tensor of shape :math:`(N, C, D_{out}, H_{out}, W_{out})`.
Raises:
TypeError: When `output_size` is not none and `output_size` is not list[int] or tuple[int].
TypeError: When `scales` is not none and `scales` is not list[float] or tuple[float].
TypeError: When `output_size` is not None and `output_size` is not list[int] or tuple[int].
TypeError: When `scales` is not None and `scales` is not list[float] or tuple[float].
TypeError: If dtype of `x` is not in [float16, float32, float64].
TypeError: If type of `align_corners` is not bool.
ValueError: If any value of `output_size` is negative or zero when `output_size` is not empty.
@ -9468,9 +9468,10 @@ class TripletMarginLoss(Primitive):
examples` respectively). The shapes of all input tensors should be
:math:`(N, D)`.
The distance swap is described in detail in the paper `Learning shallow
convolutional feature descriptors with triplet losses` by
V. Balntas, E. Riba et al.
The distance swap is described in detail in the paper
`Learning local feature descriptors with triplets and shallow convolutional neural
networks <http://158.109.8.37/files/BRP2016.pdf>`_
by V. Balntas, E. Riba et al.
The loss function for each sample in the mini-batch is:
@ -9483,17 +9484,20 @@ class TripletMarginLoss(Primitive):
d(x_i, y_i) = \left\lVert {\bf x}_i - {\bf y}_i \right\rVert_p
Args:
p (int): The norm degree for pairwise distance. Default: 2.
eps (float): Default: 1e-06.
swap (bool): The distance swap is described in detail in the paper
`Learning shallow convolutional feature descriptors with triplet losses` by
V. Balntas, E. Riba et al. Default: "False".
reduction (str): Apply specific reduction method to the output: 'none', 'mean', 'sum'. Default: "mean".
p (int, optional): The norm degree for pairwise distance. Default: 2.
eps (float, optional): Default: 1e-06.
swap (bool, optional): The distance swap is described in detail in the paper
`Learning local feature descriptors with triplets and shallow convolutional neural networks`
by V. Balntas, E. Riba et al. Default: "False".
reduction (str, optional): Apply specific reduction method to the
output: 'none', 'mean', 'sum'. Default: "mean".
Inputs:
- **x** (Tensor) - A sample randomly selected from the training set. Data type must be BasicType.
- **positive** (Tensor) - A sample belonging to the same category as x, with the same type and shape as `x`.
- **negative** (Tensor) - A sample belonging to the different class from x, with the same type and shape as `x`.
- **positive** (Tensor) - A sample belonging to the same category as x,
with the same type and shape as `x`.
- **negative** (Tensor) - A sample belonging to the different class from x,
with the same type and shape as `x`.
- **margin** (Tensor) - Make a margin between the positive pair and the negative pair.
Outputs:
@ -9501,15 +9505,17 @@ class TripletMarginLoss(Primitive):
Otherwise, a scalar value will be returned.
Raises:
TypeError: If `x` or `positive` or 'negative' or 'margin' is not a Tensor.
TypeError: If `x` or `positive` or `negative` or `margin` is not a Tensor.
TypeError: If dtype of `x` or `positive` or `negative` is not BasicType.
TypeError: If dtype of `x`, `positive` and `negative` is not the same.
TypeError: If `margin` is not float32.
TypeError: If `p` is not an int.
TypeError: If `eps` is not a float.
TypeError: If `swap` is not a bool.
ValueError: If dimensions of input `x`, `positive` and `negative` are less than or equal to 1 at the same time.
ValueError: If the dimension of input `x` or `positive` or `negative` is bigger than or equal to 8.
ValueError: If dimensions of input `x`, `positive` and `negative` are
less than or equal to 1 at the same time.
ValueError: If the dimension of input `x` or `positive` or `negative`
is bigger than or equal to 8.
ValueError: If length of shape of `margin` is not 0.
ValueError: If shape of `x`, `positive` and `negative` cannot broadcast.
ValueError: If `reduction` is not one of 'none', 'mean', 'sum'.
@ -9719,9 +9725,11 @@ class UpsampleNearest3D(Primitive):
One of `output_size` or `scales` must be given, and cannot specify both.
Args:
output_size (Union[tuple[int], list[int]]): A tuple or list of int specifying the output volumetric size.
output_size (Union[tuple[int], list[int]], optional): A tuple or list of int
specifying the output volumetric size.
Default: None.
scales (Union[tuple[float], list[float]]): A tuple or list of float specifying the upsampling factors.
scales (Union[tuple[float], list[float]], optional): A tuple or list of float
specifying the upsampling factors.
Default: None.
Inputs:
@ -9733,8 +9741,8 @@ class UpsampleNearest3D(Primitive):
Tensor of shape :math:`(N, C, D_{out}, H_{out}, W_{out})`.
Raises:
TypeError: When `output_size` is not none and `output_size` is not list[int] or tuple[int].
TypeError: When `scales` is not none and `scales` is not list[float] or tuple[float].
TypeError: When `output_size` is not None and `output_size` is not list[int] or tuple[int].
TypeError: When `scales` is not None and `scales` is not list[float] or tuple[float].
TypeError: If dtype of `x` is not int [float16, float32, float64].
ValueError: If any value of `output_size` is negative or zero when `output_size` is not empty.
ValueError: If any value of `scales` is negative or zero when `scales` is not empty.

View File

@ -80,14 +80,14 @@ class TruncatedNormal(Primitive):
The generated values follow a normal distribution.
.. warning::
The value of "shape" must be greater than zero. The output length must be less than 1000000.
The value of `shape` must be greater than zero. The output length can not exceed 1000000.
Args:
seed (int): An optional int. Defaults to 0. If either `seed` or `seed2` are set to be non-zero,
the seed is set by the given seed. Otherwise, it is seeded by a random seed.
seed2 (int): An optional int. Defaults to 0. A second seed to avoid seed collision.
dtype (mindspore.dtype): Must be one of the following types: mindspore.float16, mindspore.float32 and
mindspore.float64. Default: mindspore.float32.
dtype (mindspore.dtype): Specified output data type. Must be one of the following types:
mindspore.float16, mindspore.float32 and mindspore.float64. Default: mindspore.float32.
Inputs
- **shape** (Tensor) - The shape of random tensor to be generated. Its type must be one of the following types:
@ -99,8 +99,8 @@ class TruncatedNormal(Primitive):
Raises:
TypeError: If `shape` is not a Tensor.
TypeError: If `dtype` and input tensor type are not allowed.
TypeError: If `Seed` is not an integer.
TypeError: If data type of `dtype` and `shape` are not allowed.
TypeError: If `seed` is not an integer.
ValueError: If `shape` elements are not positive.
ValueError: If `shape` is not a 1-D tensor.
ValueError: If the number of elements of output is more than 1000000.