Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
69d54033
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看板
提交
69d54033
编写于
4月 01, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
4月 01, 2020
浏览文件
操作
浏览文件
下载
差异文件
!14 add adapter for ge atan2
Merge pull request !14 from zhaozhenlong/op/atan2
上级
0f2ed0b1
bed5997a
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
56 addition
and
4 deletion
+56
-4
mindspore/ccsrc/transform/convert.cc
mindspore/ccsrc/transform/convert.cc
+3
-1
mindspore/ccsrc/transform/op_declare.cc
mindspore/ccsrc/transform/op_declare.cc
+6
-0
mindspore/ccsrc/transform/op_declare.h
mindspore/ccsrc/transform/op_declare.h
+2
-0
mindspore/ops/_grad/grad_math_ops.py
mindspore/ops/_grad/grad_math_ops.py
+13
-0
mindspore/ops/operations/__init__.py
mindspore/ops/operations/__init__.py
+3
-2
mindspore/ops/operations/math_ops.py
mindspore/ops/operations/math_ops.py
+23
-0
tests/ut/python/ops/test_ops.py
tests/ut/python/ops/test_ops.py
+6
-1
未找到文件。
mindspore/ccsrc/transform/convert.cc
浏览文件 @
69d54033
...
...
@@ -182,6 +182,7 @@ const char kNameDiag[] = "Diag";
const
char
kNameDiagPart
[]
=
"DiagPart"
;
const
char
kNameSpaceToBatch
[]
=
"SpaceToBatch"
;
const
char
kNameBatchToSpace
[]
=
"BatchToSpace"
;
const
char
kNameAtan2
[]
=
"Atan2"
;
// -----------------OpAdapter initialization--------------
std
::
unordered_map
<
std
::
string
,
OpAdapterDescPtr
>
&
DfGraphConvertor
::
get_adpt_map
()
{
...
...
@@ -365,7 +366,8 @@ std::unordered_map<std::string, OpAdapterDescPtr> &DfGraphConvertor::get_adpt_ma
{
string
(
kNameDiag
),
ADPT_DESC
(
Diag
)},
{
string
(
kNameDiagPart
),
ADPT_DESC
(
DiagPart
)},
{
string
(
kNameSpaceToBatch
),
ADPT_DESC
(
SpaceToBatchD
)},
{
string
(
kNameBatchToSpace
),
ADPT_DESC
(
BatchToSpaceD
)}};
{
string
(
kNameBatchToSpace
),
ADPT_DESC
(
BatchToSpaceD
)},
{
string
(
kNameAtan2
),
ADPT_DESC
(
Atan2
)}};
#ifdef ENABLE_GE
adpt_map
[
string
(
kNamePrint
)]
=
ADPT_DESC
(
Print
);
#endif
...
...
mindspore/ccsrc/transform/op_declare.cc
浏览文件 @
69d54033
...
...
@@ -1196,6 +1196,12 @@ ATTR_MAP(BatchToSpaceD) = {
{
"block_size"
,
ATTR_DESC
(
block_size
,
AnyTraits
<
int64_t
>
())},
{
"crops"
,
ATTR_DESC
(
crops
,
AnyTraits
<
std
::
vector
<
std
::
vector
<
int64_t
>>>
(),
AnyTraits
<
std
::
vector
<
int64_t
>>
())}};
OUTPUT_MAP
(
BatchToSpaceD
)
=
{{
0
,
OUTPUT_DESC
(
y
)}};
// Atan2
INPUT_MAP
(
Atan2
)
=
{{
1
,
INPUT_DESC
(
x1
)},
{
2
,
INPUT_DESC
(
x2
)}};
ATTR_MAP
(
Atan2
)
=
EMPTY_ATTR_MAP
;
OUTPUT_MAP
(
Atan2
)
=
{{
0
,
OUTPUT_DESC
(
y
)}};
#ifdef ENABLE_GE
// Print
INPUT_MAP
(
Print
)
=
EMPTY_INPUT_MAP
;
...
...
mindspore/ccsrc/transform/op_declare.h
浏览文件 @
69d54033
...
...
@@ -443,6 +443,8 @@ DECLARE_OP_ADAPTER(SpaceToBatchD)
DECLARE_OP_USE_OUTPUT
(
SpaceToBatchD
)
DECLARE_OP_ADAPTER
(
BatchToSpaceD
)
DECLARE_OP_USE_OUTPUT
(
BatchToSpaceD
)
DECLARE_OP_ADAPTER
(
Atan2
)
DECLARE_OP_USE_OUTPUT
(
Atan2
)
#ifdef ENABLE_GE
DECLARE_OP_ADAPTER
(
Print
)
DECLARE_OP_USE_DYN_INPUT
(
Print
)
...
...
mindspore/ops/_grad/grad_math_ops.py
浏览文件 @
69d54033
...
...
@@ -738,3 +738,16 @@ def get_bprop_round(self):
def
bprop
(
x
,
out
,
dout
):
return
(
zeros_like
(
x
),)
return
bprop
@
bprop_getters
.
register
(
P
.
Atan2
)
def
get_bprop_atan2
(
self
):
"""Generate bprop for Atan2"""
square
=
P
.
Square
()
def
bprop
(
x
,
y
,
out
,
dout
):
tmp
=
dout
/
(
square
(
x
)
+
square
(
y
))
dx
=
tmp
*
y
dy
=
tmp
*
(
-
x
)
return
(
dx
,
dy
)
return
bprop
mindspore/ops/operations/__init__.py
浏览文件 @
69d54033
...
...
@@ -37,7 +37,7 @@ from .debug_ops import (ImageSummary, InsertGradientOf, ScalarSummary,
TensorSummary
,
Print
)
from
.control_ops
import
ControlDepend
,
GeSwitch
,
Merge
from
.inner_ops
import
ScalarCast
from
.math_ops
import
(
Abs
,
ACos
,
AddN
,
AssignAdd
,
AssignSub
,
BatchMatMul
,
from
.math_ops
import
(
Abs
,
ACos
,
AddN
,
AssignAdd
,
AssignSub
,
Atan2
,
BatchMatMul
,
ReduceMax
,
ReduceMin
,
ReduceMean
,
ReduceSum
,
ReduceAll
,
ReduceProd
,
CumProd
,
Cos
,
Div
,
Equal
,
EqualCount
,
Exp
,
Floor
,
FloorDiv
,
Greater
,
GreaterEqual
,
Less
,
LessEqual
,
Log
,
LogicalAnd
,
...
...
@@ -226,7 +226,8 @@ __all__ = [
"Round"
,
"ApplyFtrl"
,
"SpaceToBatch"
,
"BatchToSpace"
"BatchToSpace"
,
"Atan2"
,
]
__all__
.
sort
()
mindspore/ops/operations/math_ops.py
浏览文件 @
69d54033
...
...
@@ -1858,3 +1858,26 @@ class Round(PrimitiveWithInfer):
validator
.
check_subclass
(
"x_dtype"
,
x_type
,
mstype
.
tensor
)
validator
.
check_typename
(
'x_dtype'
,
x_type
,
mstype
.
number_type
)
return
x_type
class
Atan2
(
_MathBinaryOp
):
r
"""
Returns arctangent of input_x/input_y element-wise.
It returns :math:`\theta\ \in\ (-\frac{\pi}{2}, \frac{\pi}{2})`
such that :math:`x = r*\sin(\theta), y = r*\cos(\theta)`, where :math:`r = \sqrt{x^2 + y^2}`.
Inputs:
- **input_x** (Tensor) - The input tensor.
- **input_y** (Tensor) - The input tensor.
Outputs:
Tensor, the shape is same as the shape after broadcasting, and the data type is same as 'input_x'.
Examples:
>>> input_x = Tensor(np.array([[0, 1]]), mstype.float32)
>>> input_y = Tensor(np.array([[1, 1]]), mstype.float32)
>>> atan2 = Atan2()
>>> atan2(input_x, input_y)
[[0. 0.7853982]]
"""
tests/ut/python/ops/test_ops.py
浏览文件 @
69d54033
...
...
@@ -481,7 +481,12 @@ test_case_math_ops = [
(
'Round'
,
{
'block'
:
P
.
Round
(),
'desc_inputs'
:
[[
3
]],
'desc_bprop'
:
[[
3
]]})
'desc_bprop'
:
[[
3
]]}),
(
'Atan2'
,
{
'block'
:
P
.
Atan2
(),
'desc_inputs'
:
[
Tensor
(
np
.
array
([
0
,
1
]).
astype
(
np
.
float32
)),
Tensor
(
np
.
array
([
1
,
1
]).
astype
(
np
.
float32
))],
'desc_bprop'
:
[[
2
]]})
]
test_case_nn_ops
=
[
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录