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
5bd169b8
Commit
5bd169b8
authored
Oct 12, 2017
by
Scott Cyphers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Format
parent
d2d200e6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
16 deletions
+14
-16
adjoints.cpp
src/ngraph/autodiff/adjoints.cpp
+2
-3
node.cpp
src/ngraph/node.cpp
+1
-3
node.hpp
src/ngraph/node.hpp
+2
-1
execute.cpp
test/execute.cpp
+9
-9
No files found.
src/ngraph/autodiff/adjoints.cpp
View file @
5bd169b8
...
...
@@ -160,11 +160,10 @@ void autodiff::Adjoints::add_delta(const std::shared_ptr<Node>& x,
auto
adjoint_it
=
m_adjoint_map
.
find
(
x
.
get
());
if
(
m_adjoint_map
.
end
()
==
adjoint_it
)
{
m_adjoint_map
.
insert
({
x
.
get
(),
delta
});
m_adjoint_map
.
insert
({
x
.
get
(),
delta
});
}
else
{
m_adjoint_map
.
insert
(
{
x
.
get
(),
std
::
make_shared
<
op
::
Add
>
(
adjoint_it
->
second
,
delta
)});
m_adjoint_map
.
insert
({
x
.
get
(),
std
::
make_shared
<
op
::
Add
>
(
adjoint_it
->
second
,
delta
)});
}
}
src/ngraph/node.cpp
View file @
5bd169b8
...
...
@@ -166,9 +166,7 @@ std::shared_ptr<Node> Node::backwards_derivative(const std::shared_ptr<Node>& x,
if
(
adjoints_it
==
m_adjoint_map
.
end
())
{
adjoints_it
=
m_adjoint_map
.
insert
({
c
.
get
(),
autodiff
::
Adjoints
(
shared_from_this
(),
c
)})
.
first
;
m_adjoint_map
.
insert
({
c
.
get
(),
autodiff
::
Adjoints
(
shared_from_this
(),
c
)}).
first
;
}
return
adjoints_it
->
second
.
get
(
x
);
}
...
...
src/ngraph/node.hpp
View file @
5bd169b8
...
...
@@ -18,6 +18,7 @@
#include <memory>
#include <set>
#include <string>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#include <vector>
...
...
@@ -76,7 +77,7 @@ namespace ngraph
bool
is_same_op_type
(
const
std
::
shared_ptr
<
Node
>&
node
)
const
{
Node
*
n
=
node
.
get
();
return
typeid
(
*
this
)
==
typeid
(
*
n
);
return
std
::
type_index
(
typeid
(
*
this
))
==
std
::
type_index
(
typeid
(
*
n
)
);
}
std
::
shared_ptr
<
const
ValueType
>
get_value_type
();
...
...
test/execute.cpp
View file @
5bd169b8
...
...
@@ -1882,7 +1882,7 @@ TEST(execute, sin)
auto
result
=
backend
->
make_parameterized_tensor_view
<
element
::
Float32
>
(
shape
);
std
::
transform
(
input
.
begin
(),
input
.
end
(),
input
.
begin
(),
[](
float
f
)
->
float
{
return
sinf
(
f
);
});
input
.
begin
(),
input
.
end
(),
input
.
begin
(),
[](
float
v
)
->
float
{
return
sinf
(
v
);
});
(
*
cf
)({
a
},
{
result
});
ASSERT_EQ
(
input
,
result
->
get_vector
());
...
...
@@ -1908,7 +1908,7 @@ TEST(execute, cos)
auto
result
=
backend
->
make_parameterized_tensor_view
<
element
::
Float32
>
(
shape
);
std
::
transform
(
input
.
begin
(),
input
.
end
(),
input
.
begin
(),
[](
float
f
)
->
float
{
return
cosf
(
f
);
});
input
.
begin
(),
input
.
end
(),
input
.
begin
(),
[](
float
v
)
->
float
{
return
cosf
(
v
);
});
(
*
cf
)({
a
},
{
result
});
ASSERT_EQ
(
input
,
result
->
get_vector
());
...
...
@@ -1934,7 +1934,7 @@ TEST(execute, tan)
auto
result
=
backend
->
make_parameterized_tensor_view
<
element
::
Float32
>
(
shape
);
std
::
transform
(
input
.
begin
(),
input
.
end
(),
input
.
begin
(),
[](
float
f
)
->
float
{
return
tanf
(
f
);
});
input
.
begin
(),
input
.
end
(),
input
.
begin
(),
[](
float
v
)
->
float
{
return
tanf
(
v
);
});
(
*
cf
)({
a
},
{
result
});
ASSERT_EQ
(
input
,
result
->
get_vector
());
...
...
@@ -1959,7 +1959,7 @@ TEST(execute, asin)
auto
result
=
backend
->
make_parameterized_tensor_view
<
element
::
Float32
>
(
shape
);
std
::
transform
(
input
.
begin
(),
input
.
end
(),
input
.
begin
(),
[](
float
f
)
->
float
{
return
asinf
(
f
);
});
input
.
begin
(),
input
.
end
(),
input
.
begin
(),
[](
float
v
)
->
float
{
return
asinf
(
v
);
});
(
*
cf
)({
a
},
{
result
});
ASSERT_EQ
(
input
,
result
->
get_vector
());
...
...
@@ -1984,7 +1984,7 @@ TEST(execute, acos)
auto
result
=
backend
->
make_parameterized_tensor_view
<
element
::
Float32
>
(
shape
);
std
::
transform
(
input
.
begin
(),
input
.
end
(),
input
.
begin
(),
[](
float
f
)
->
float
{
return
acosf
(
f
);
});
input
.
begin
(),
input
.
end
(),
input
.
begin
(),
[](
float
v
)
->
float
{
return
acosf
(
v
);
});
(
*
cf
)({
a
},
{
result
});
ASSERT_EQ
(
input
,
result
->
get_vector
());
...
...
@@ -2009,7 +2009,7 @@ TEST(execute, atan)
auto
result
=
backend
->
make_parameterized_tensor_view
<
element
::
Float32
>
(
shape
);
std
::
transform
(
input
.
begin
(),
input
.
end
(),
input
.
begin
(),
[](
float
f
)
->
float
{
return
atanf
(
f
);
});
input
.
begin
(),
input
.
end
(),
input
.
begin
(),
[](
float
v
)
->
float
{
return
atanf
(
v
);
});
(
*
cf
)({
a
},
{
result
});
ASSERT_EQ
(
input
,
result
->
get_vector
());
...
...
@@ -2034,7 +2034,7 @@ TEST(execute, sinh)
auto
result
=
backend
->
make_parameterized_tensor_view
<
element
::
Float32
>
(
shape
);
std
::
transform
(
input
.
begin
(),
input
.
end
(),
input
.
begin
(),
[](
float
f
)
->
float
{
return
sinhf
(
f
);
});
input
.
begin
(),
input
.
end
(),
input
.
begin
(),
[](
float
v
)
->
float
{
return
sinhf
(
v
);
});
(
*
cf
)({
a
},
{
result
});
ASSERT_EQ
(
input
,
result
->
get_vector
());
...
...
@@ -2059,7 +2059,7 @@ TEST(execute, cosh)
auto
result
=
backend
->
make_parameterized_tensor_view
<
element
::
Float32
>
(
shape
);
std
::
transform
(
input
.
begin
(),
input
.
end
(),
input
.
begin
(),
[](
float
f
)
->
float
{
return
coshf
(
f
);
});
input
.
begin
(),
input
.
end
(),
input
.
begin
(),
[](
float
v
)
->
float
{
return
coshf
(
v
);
});
(
*
cf
)({
a
},
{
result
});
ASSERT_EQ
(
input
,
result
->
get_vector
());
...
...
@@ -2084,7 +2084,7 @@ TEST(execute, tanh)
auto
result
=
backend
->
make_parameterized_tensor_view
<
element
::
Float32
>
(
shape
);
std
::
transform
(
input
.
begin
(),
input
.
end
(),
input
.
begin
(),
[](
float
f
)
->
float
{
return
tanhf
(
f
);
});
input
.
begin
(),
input
.
end
(),
input
.
begin
(),
[](
float
v
)
->
float
{
return
tanhf
(
v
);
});
(
*
cf
)({
a
},
{
result
});
ASSERT_EQ
(
input
,
result
->
get_vector
());
...
...
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