mindspore/docs/api/api_python/mint/mindspore.mint.func_div.rst

32 lines
1.6 KiB
ReStructuredText
Raw Permalink 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.mint.div
=====================
.. py:function:: mindspore.mint.div(input, other, *, rounding_mode=None) -> Tensor
逐元素计算 `input` 除以 `other` 的商。
.. math::
out_{i} = input_{i} / other_{i}
.. note::
- 当两个输入具有不同的shape时它们的shape必须要能广播为一个共同的shape。
- 两个输入不能同时为bool类型。[True, Tensor(True), Tensor(np.array([True]))]等都为bool类型。
- 两个输入遵循隐式类型转换规则,使数据类型保持一致。
参数:
- **input** (Union[Tensor, Number, bool]) - 被除数。
- **other** (Union[Tensor, Number, bool]) - 除数。
关键字参数:
- **rounding_mode** (str, 可选) - 应用于结果的舍入类型。三种类型被定义为 ``None````"floor"````"trunc"`` 。默认值: ``None``
- **None**默认行为。相当于Python中的 `true division` 或NumPy中的 `true_divide`
- **"floor"**将除法的结果向下舍入。相当于Python中的 `floor division` 或NumPy中的 `floor_divide`
- **"trunc"**将除法的结果舍入到零。相当于C语言风格的整数除法。
返回:
Tensor输出的shape与广播后的shape相同数据类型取两个输入中精度较高或数字较高的。
异常:
- **TypeError** - 如果 `input``other` 不是以下之一Tensor、Number、bool。
- **ValueError** - 如果 `rounding_mode` 不是以下之一: ``None````"floor"````"trunc"``