mindspore/docs/api/api_python/ops/mindspore.ops.Mod.rst

30 lines
1.7 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.ops.Mod
==================
.. py:class:: mindspore.ops.Mod
将第一个输入Tensor逐元素除以第二个输入Tensor并取余。
`x``y` 的输入遵循隐式类型转换规则使数据类型一致。输入必须是两个Tensor或一个Tensor和一个Scalar。当输入是两个Tensor时两个数据类型都不能是bool它们的shape可以广播。当输入是一个Tensor和一个Scalar时Scalar只能是一个常量。
.. math::
out_{i} = x_{i} \text{ % } y_{i}
.. warning::
- 输入数据不支持0。
- 当输出包含的元素个数超过2048时该算子不能保证双千分之一的精度要求。
- 由于架构的差异在NPU和CPU上生成的结果可能不一致。
- 如果shape表示为 :math:`(D1、D2...、Dn)` ,则 :math:`D1*D2... *DN<=1000000,n<=8`
输入:
- **x** (Union[Tensor, numbers.Number, bool]) - 第一个输入是数值型、bool或数据类型为数值型的Tensor。
- **y** (Union[Tensor, numbers.Number, bool]) - 当第一个输入是Tensor时第二个输入可以是数值型、bool或数据类型为数值型的Tensor。当第一个输入是数值型或bool时第二个输入必须是数据类型为数值型的Tensor。
输出:
Tensorshape与广播后的shape相同数据类型为两个输入中精度较高或数据类型相对最高的类型。
异常:
- **TypeError** - 如果 `x``y` 都不是以下之一Tensor、数值型、bool。
- **TypeError** - 如果 `x``y` 都不是Tensor。
- **ValueError** - 如果 `x``y` 的shape不能相互广播。