Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
92012c84
MegEngine
项目概览
MegEngine 天元
/
MegEngine
1 年多 前同步成功
通知
403
Star
4705
Fork
582
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MegEngine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
92012c84
编写于
12月 17, 2021
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #398 from ErikQQY:docstring-mul
GitOrigin-RevId: 440dcee8836852723987165008ac19d2d8260e25
上级
501eadc1
2d1d5e9b
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
50 addition
and
2 deletion
+50
-2
imperative/python/megengine/functional/elemwise.py
imperative/python/megengine/functional/elemwise.py
+50
-2
未找到文件。
imperative/python/megengine/functional/elemwise.py
浏览文件 @
92012c84
...
@@ -131,8 +131,56 @@ def sub(x, y):
...
@@ -131,8 +131,56 @@ def sub(x, y):
return
_elwise
(
x
,
y
,
mode
=
Elemwise
.
Mode
.
SUB
)
return
_elwise
(
x
,
y
,
mode
=
Elemwise
.
Mode
.
SUB
)
def
mul
(
x
,
y
):
def
mul
(
x
:
Tensor
,
y
:
Tensor
)
->
Tensor
:
r
"""Element-wise `multiplication`."""
r
"""Calculates the product for each element :math:`x_i` of the input tensor `x` with the respective element :math:`y_i` of the input tensor `y`.
Note:
* If either :math:`x_i` or :math:`y_i` is `NaN`, the result is `NaN`.
* If :math:`x_i` is either `+infinity` or `-infinity` and :math:`y_i` is either `+0` or `-0`, the result is `NaN`.
* If :math:`x_i` is either `+0` or `-0` and :math:`y_i` is either `+infinity` or `-infinity`, the result is `NaN`.
* If :math:`x_i` and :math:`y_i` have different mathematical signs, the result has a negative mathematical sign, unless the result is `NaN`.
* If :math:`x_i` is either `+infinity` or `-infinity` and :math:`y_i` is either `+infinity` or `-infinity`,
the result is a signed infinity with the mathematical sign determined by the rule already stated above.
* If :math:`x_i` is either `+infinity` or `-infinity` and :math:`y_i` is a nonzero finite number,
the result is a signed infinity with the mathematical sign determined by the rule already stated above.
* If :math:`x_i` is a nonzero finite number and :math:`y_i` is either `+infinity` or `-infinity`,
the result is a signed infinity with the mathematical sign determined by the rule already stated above.
* In the remaining cases, where neither `infinity` nor `NaN` is involved,
the product must be computed and rounded to the nearest representable value according to IEEE 754-2019 and a supported rounding mode.
If the magnitude is too large to represent, the result is an `infinity` of appropriate mathematical sign.
If the magnitude is too small to represent, the result is a zero of appropriate mathematical sign.
* Floating-point multiplication is not always associative due to finite precision.
Args:
x: first input tensor. Should have a numeric data type.
y: second input tensor. Must be compatible with `x` (see :ref:`broadcasting-rule` ). Should have a numeric data type.
Returns:
A tensor containing the element-wise products. The returned array must have a data type determined by :ref:`dtype-promotion`.
Examples:
>>> F.mul(2, 3)
Tensor(6, dtype=int32, device=xpux:0)
>>> F.mul(2.0, 3.0)
Tensor(6.0, device=xpux:0)
>>> x = F.arange(6.0).reshape(2, 3)
>>> y = F.arange(3.0)
>>> F.mul(x, y)
Tensor([[ 0. 1. 4.]
[ 0. 4. 10.]], device=xpux:0)
The `*` operator can be used as a shorthand for :func:`~.functional.mul` on tensors.
>>> x = F.arange(6.0).reshape(2, 3)
>>> y = F.arange(3.0)
>>> x * y
Tensor([[ 0. 1. 4.]
[ 0. 4. 10.]], device=xpux:0)
"""
return
_elwise
(
x
,
y
,
mode
=
Elemwise
.
Mode
.
MUL
)
return
_elwise
(
x
,
y
,
mode
=
Elemwise
.
Mode
.
MUL
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录