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
4a800845
Commit
4a800845
authored
Nov 01, 2017
by
Adam Procter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for apparent autodiff bug with nested adds
parent
3970b477
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
2 deletions
+24
-2
all_close.cpp
test/util/all_close.cpp
+4
-2
autodiff.cpp
test/util/autodiff.cpp
+20
-0
No files found.
test/util/all_close.cpp
View file @
4a800845
...
...
@@ -90,14 +90,16 @@ template <typename T>
bool
ngraph
::
test
::
all_close
(
const
std
::
vector
<
T
>&
a
,
const
std
::
vector
<
T
>&
b
,
T
rtol
,
T
atol
)
{
assert
(
a
.
size
()
==
b
.
size
());
bool
retval
=
true
;
for
(
size_t
i
=
0
;
i
<
a
.
size
();
++
i
)
{
if
(
std
::
abs
(
a
[
i
]
-
b
[
i
])
>
atol
+
rtol
*
std
::
abs
(
b
[
i
]))
{
return
false
;
std
::
cout
<<
"a["
<<
i
<<
"] = "
<<
a
[
i
]
<<
", b["
<<
i
<<
"] = "
<<
b
[
i
]
<<
std
::
endl
;
retval
=
false
;
}
}
return
true
;
return
retval
;
}
template
bool
ngraph
::
test
::
all_close
<
float
>
(
const
std
::
vector
<
float
>&
a
,
...
...
test/util/autodiff.cpp
View file @
4a800845
...
...
@@ -65,6 +65,26 @@ TEST(backwards, add)
manager
,
backend
,
make_graph
,
{
x0
,
x1
},
.01
f
,
.01
f
));
}
TEST
(
backwards
,
add_nested
)
{
auto
manager
=
runtime
::
Manager
::
get
(
"NGVM"
);
auto
backend
=
manager
->
allocate_backend
();
test
::
Uniform
<
element
::
Float32
>
rng
(
-
1.0
f
,
1.0
f
);
auto
shape
=
Shape
{
2
,
3
};
auto
x0
=
rng
.
initialize
(
backend
->
make_parameterized_tensor_view
<
element
::
Float32
>
(
shape
));
auto
x1
=
rng
.
initialize
(
backend
->
make_parameterized_tensor_view
<
element
::
Float32
>
(
shape
));
auto
make_graph
=
[
shape
]()
{
auto
X0
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
X1
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
return
make_shared
<
Function
>
(
(
X0
+
X1
)
+
(
X1
+
X0
),
nullptr
,
std
::
vector
<
std
::
shared_ptr
<
op
::
Parameter
>>
{
X0
,
X1
});
};
EXPECT_TRUE
(
autodiff_numeric_compare
<
element
::
Float32
>
(
manager
,
backend
,
make_graph
,
{
x0
,
x1
},
.01
f
,
.01
f
));
}
TEST
(
backwards
,
broadcast0
)
{
auto
manager
=
runtime
::
Manager
::
get
(
"NGVM"
);
...
...
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