Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
c36e7f15
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c36e7f15
编写于
5月 08, 2020
作者:
J
jiangjinsheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support vm for log1p
上级
4a8fcf5d
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
95 addition
and
1 deletion
+95
-1
mindspore/ops/_grad/grad_math_ops.py
mindspore/ops/_grad/grad_math_ops.py
+13
-0
mindspore/ops/_op_impl/tbe/__init__.py
mindspore/ops/_op_impl/tbe/__init__.py
+1
-0
mindspore/ops/_op_impl/tbe/log1p.py
mindspore/ops/_op_impl/tbe/log1p.py
+38
-0
mindspore/ops/operations/__init__.py
mindspore/ops/operations/__init__.py
+1
-1
mindspore/ops/operations/math_ops.py
mindspore/ops/operations/math_ops.py
+29
-0
tests/ut/python/ops/test_math_ops.py
tests/ut/python/ops/test_math_ops.py
+13
-0
未找到文件。
mindspore/ops/_grad/grad_math_ops.py
浏览文件 @
c36e7f15
...
...
@@ -331,6 +331,19 @@ def get_bprop_log(self):
return
bprop
@
bprop_getters
.
register
(
P
.
Log1p
)
def
get_bprop_log1p
(
self
):
"""Grad definition for `Log1p` operation."""
reciprocal
=
P
.
Reciprocal
()
def
bprop
(
x
,
out
,
dout
):
x_1p
=
x
+
1
g
=
reciprocal
(
x_1p
)
dx
=
g
*
dout
return
dx
,
0
return
bprop
@
bprop_getters
.
register
(
P
.
Erf
)
def
get_bprop_erf
(
self
):
"""Grad definition for `Erf` operation."""
...
...
mindspore/ops/_op_impl/tbe/__init__.py
浏览文件 @
c36e7f15
...
...
@@ -159,3 +159,4 @@ from .ones_like import _ones_like_tbe
from
.batch_to_space
import
_batch_to_space_tbe
from
.space_to_batch
import
_space_to_batch_tbe
from
.floor
import
_floor_tbe
from
.log1p
import
_log1p_tbe
mindspore/ops/_op_impl/tbe/log1p.py
0 → 100644
浏览文件 @
c36e7f15
# Copyright 2020 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""Log1p op"""
from
mindspore.ops.op_info_register
import
op_info_register
,
TBERegOp
,
DataType
log1p_op_info
=
TBERegOp
(
"Log1p"
)
\
.
fusion_type
(
"ELEMWISE"
)
\
.
async_flag
(
False
)
\
.
binfile_name
(
"log1p.so"
)
\
.
compute_cost
(
10
)
\
.
kernel_name
(
"log1p"
)
\
.
partial_flag
(
True
)
\
.
input
(
0
,
"x"
,
False
,
"required"
,
"all"
)
\
.
output
(
0
,
"y"
,
False
,
"required"
,
"all"
)
\
.
dtype_format
(
DataType
.
F16_Default
,
DataType
.
F16_Default
)
\
.
dtype_format
(
DataType
.
F16_5HD
,
DataType
.
F16_5HD
)
\
.
dtype_format
(
DataType
.
F32_Default
,
DataType
.
F32_Default
)
\
.
dtype_format
(
DataType
.
F32_5HD
,
DataType
.
F32_5HD
)
\
.
get_op_info
()
@
op_info_register
(
log1p_op_info
)
def
_log1p_tbe
():
"""Log1p TBE register"""
return
mindspore/ops/operations/__init__.py
浏览文件 @
c36e7f15
...
...
@@ -40,7 +40,7 @@ from .inner_ops import ScalarCast
from
.math_ops
import
(
Abs
,
ACos
,
AddN
,
AssignAdd
,
AssignSub
,
Atan2
,
BatchMatMul
,
ReduceMax
,
ReduceMin
,
ReduceMean
,
ReduceSum
,
ReduceAll
,
ReduceProd
,
CumProd
,
Cos
,
Div
,
Equal
,
EqualCount
,
Exp
,
Erf
,
Floor
,
FloorDiv
,
FloorMod
,
Acosh
,
Greater
,
GreaterEqual
,
Less
,
LessEqual
,
Log
,
LogicalAnd
,
Greater
,
GreaterEqual
,
Less
,
LessEqual
,
Log
,
Log
1p
,
Log
icalAnd
,
LogicalNot
,
LogicalOr
,
MatMul
,
Maximum
,
Minimum
,
Mul
,
Neg
,
NMSWithMask
,
NotEqual
,
NPUAllocFloatStatus
,
NPUClearFloatStatus
,
...
...
mindspore/ops/operations/math_ops.py
浏览文件 @
c36e7f15
...
...
@@ -1007,6 +1007,35 @@ class Log(PrimitiveWithInfer):
return
x
class
Log1p
(
PrimitiveWithInfer
):
"""
Returns the natural logarithm of one plus the input tensor element-wise.
Inputs:
- **input_x** (Tensor) - The input tensor.
Outputs:
Tensor, has the same shape as the `input_x`.
Examples:
>>> input_x = Tensor(np.array([1.0, 2.0, 4.0]), mindspore.float32)
>>> log1p = P.Log1p()
>>> log1p(input_x)
[0.6931472, 1.0986123, 1.609438]
"""
@
prim_attr_register
def
__init__
(
self
):
self
.
init_prim_io_names
(
inputs
=
[
'x'
],
outputs
=
[
'y'
])
def
infer_shape
(
self
,
x
):
return
x
def
infer_dtype
(
self
,
x
):
validator
.
check_subclass
(
"x"
,
x
,
mstype
.
tensor
,
self
.
name
)
return
x
class
Erf
(
PrimitiveWithInfer
):
r
"""
Computes the Gauss error function of `input_x` element-wise.
...
...
tests/ut/python/ops/test_math_ops.py
浏览文件 @
c36e7f15
...
...
@@ -359,6 +359,14 @@ class FloorNet(nn.Cell):
def
construct
(
self
,
x
):
return
self
.
floor
(
x
)
class
Log1pNet
(
nn
.
Cell
):
def
__init__
(
self
):
super
(
Log1pNet
,
self
).
__init__
()
self
.
log1p
=
P
.
Log1p
()
def
construct
(
self
,
x
):
return
self
.
log1p
(
x
)
test_case_math_ops
=
[
(
'MatMulGrad'
,
{
...
...
@@ -405,6 +413,11 @@ test_case_math_ops = [
'desc_inputs'
:
[
Tensor
(
np
.
array
([[
1.
,
0.
,
-
2.
]],
np
.
float32
))],
'desc_bprop'
:
[
Tensor
(
np
.
array
([[
1.
,
0.
,
-
2.
]],
np
.
float32
))],
'skip'
:
[
'backward'
]}),
(
'Log1p'
,
{
'block'
:
Log1pNet
(),
'desc_inputs'
:
[
Tensor
(
np
.
array
([[
1.0
,
2.0
,
4.0
]],
np
.
float32
))],
'desc_bprop'
:
[
Tensor
(
np
.
array
([[
1.0
,
2.0
,
4.0
]],
np
.
float32
))],
'skip'
:
[
'backward'
]}),
]
test_case_lists
=
[
test_case_math_ops
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录