Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
ngraph
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ngraph
Commits
6e1b308d
Unverified
Commit
6e1b308d
authored
Nov 07, 2019
by
Scott Cyphers
Committed by
GitHub
Nov 07, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Autodiff for atan2 (#3865)
* Autodiff for atan2 * atan2 not supported on PlaidML
parent
41a44f92
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
1 deletion
+29
-1
atan2.cpp
src/ngraph/op/atan2.cpp
+11
-1
unit_test.manifest
src/ngraph/runtime/plaidml/unit_test.manifest
+1
-0
autodiff.in.cpp
test/backend/autodiff.in.cpp
+17
-0
No files found.
src/ngraph/op/atan2.cpp
View file @
6e1b308d
...
...
@@ -15,6 +15,12 @@
//*****************************************************************************
#include "ngraph/op/atan2.hpp"
#include "ngraph/op/add.hpp"
#include "ngraph/op/divide.hpp"
#include "ngraph/op/multiply.hpp"
#include "ngraph/op/negative.hpp"
#include "ngraph/op/sqrt.hpp"
#include "ngraph/op/subtract.hpp"
using
namespace
std
;
using
namespace
ngraph
;
...
...
@@ -39,5 +45,9 @@ void op::Atan2::generate_adjoints(autodiff::Adjoints& adjoints, const NodeVector
{
throw
ngraph_error
(
"Autodiff not supported with auto broadcasting"
);
}
throw
ngraph_error
(
"Autodiff not supported for Atan2"
);
auto
y
=
input_value
(
0
);
auto
x
=
input_value
(
1
);
auto
delta_over_r
=
deltas
.
at
(
0
)
/
(
x
*
x
+
y
*
y
);
adjoints
.
add_delta
(
y
,
x
*
delta_over_r
);
adjoints
.
add_delta
(
x
,
-
y
*
delta_over_r
);
}
src/ngraph/runtime/plaidml/unit_test.manifest
View file @
6e1b308d
...
...
@@ -54,6 +54,7 @@ top_k_opset_11_const_k_smallest # No plans to implement TopK
# unsupported op: `Atan2`
atan2
backwards_atan2
# unsupported op: `Erf`
erf
...
...
test/backend/autodiff.in.cpp
View file @
6e1b308d
...
...
@@ -521,6 +521,23 @@ NGRAPH_TEST(${BACKEND_NAME}, backwards_atan)
EXPECT_TRUE
(
autodiff_numeric_compare
<
float
>
(
backend
.
get
(),
make_graph
,
{
x0
},
.01
f
,
.01
f
));
}
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
backwards_atan2
)
{
auto
backend
=
runtime
::
Backend
::
create
(
"${BACKEND_NAME}"
);
Shape
shape
{
30
};
test
::
Uniform
<
float
>
rng
(
-
5.0
f
,
5.0
f
);
auto
y
=
rng
.
initialize
(
backend
->
create_tensor
<
float
>
(
shape
));
auto
x
=
rng
.
initialize
(
backend
->
create_tensor
<
float
>
(
shape
));
auto
make_graph
=
[
shape
]()
{
auto
X
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
shape
);
auto
Y
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
shape
);
return
make_shared
<
Function
>
(
make_shared
<
op
::
Atan2
>
(
Y
,
X
),
ParameterVector
{
Y
,
X
});
};
EXPECT_TRUE
(
autodiff_numeric_compare
<
float
>
(
backend
.
get
(),
make_graph
,
{
y
,
x
},
.01
f
,
.01
f
));
}
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
backwards_broadcast0
)
{
auto
backend
=
runtime
::
Backend
::
create
(
"${BACKEND_NAME}"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment