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
dd41bb62
Unverified
Commit
dd41bb62
authored
Dec 13, 2018
by
Scott Cyphers
Committed by
GitHub
Dec 13, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return correct value from autodiff tests. Make batchnorm autodiff test a little bigger. (#2218)
parent
e526aeef
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
18 deletions
+20
-18
autodiff.in.cpp
test/autodiff.in.cpp
+5
-5
numeric_compare.hpp
test/util/autodiff/numeric_compare.hpp
+15
-13
No files found.
test/autodiff.in.cpp
View file @
dd41bb62
...
...
@@ -1626,7 +1626,7 @@ NGRAPH_TEST(${BACKEND_NAME}, backwards_maxpool_n2c1h5w5_kh3kw3_sh2sw2)
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
backwards_batch_norm_training
)
{
const
Shape
input_shape
{
5
,
3
,
2
,
2
};
const
Shape
input_shape
{
10
,
4
,
5
,
5
};
const
Shape
channel_shape
{
input_shape
.
at
(
1
)};
const
double
eps
=
1e-3
;
const
element
::
Type
&
et
=
element
::
f32
;
...
...
@@ -1647,19 +1647,19 @@ NGRAPH_TEST(${BACKEND_NAME}, backwards_batch_norm_training)
goes
.
push_back
(
mean
);
goes
.
push_back
(
variance
);
// TODO autodiff testing with more than one result
auto
f
=
make_shared
<
Function
>
(
ResultVector
{
normed_input
/* , mean, variance*/
},
ParameterVector
{
input
,
gamma
,
beta
});
auto
f
=
make_shared
<
Function
>
(
ResultVector
{
normed_input
},
ParameterVector
{
input
,
gamma
,
beta
});
return
f
;
};
auto
backend
=
runtime
::
Backend
::
create
(
"${BACKEND_NAME}"
);
test
::
Uniform
<
T
>
rng
(
-
1.0
,
1
.0
);
test
::
Uniform
<
T
>
rng
(
-
5.0
,
2
.0
);
auto
input
=
rng
.
initialize
(
backend
->
create_tensor
<
T
>
(
input_shape
));
auto
gamma
=
rng
.
initialize
(
backend
->
create_tensor
<
T
>
(
channel_shape
));
auto
beta
=
rng
.
initialize
(
backend
->
create_tensor
<
T
>
(
channel_shape
));
EXPECT_TRUE
(
autodiff_numeric_compare
<
T
>
(
backend
.
get
(),
make_graph
,
{
input
,
gamma
,
beta
},
.00
1
,
.001
));
autodiff_numeric_compare
<
T
>
(
backend
.
get
(),
make_graph
,
{
input
,
gamma
,
beta
},
.00
5
,
.005
));
}
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
backwards_reverse_sequence_n3_c2_h3
)
...
...
test/util/autodiff/numeric_compare.hpp
View file @
dd41bb62
...
...
@@ -25,12 +25,13 @@
// derivative does not work with int types
// TODO: Always compute the numerical derivatives in double
template
<
typename
T
>
bool
autodiff_numeric_compare
(
ngraph
::
runtime
::
Backend
*
backend
,
std
::
shared_ptr
<
ngraph
::
Function
>
f
,
std
::
shared_ptr
<
ngraph
::
Function
>
g
,
const
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
Tensor
>>&
args
,
T
rtol
,
T
atol
)
::
testing
::
AssertionResult
autodiff_numeric_compare
(
ngraph
::
runtime
::
Backend
*
backend
,
std
::
shared_ptr
<
ngraph
::
Function
>
f
,
std
::
shared_ptr
<
ngraph
::
Function
>
g
,
const
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
Tensor
>>&
args
,
T
rtol
,
T
atol
)
{
T
delta
=
static_cast
<
T
>
(
0.0009765625
f
);
// Binary-representable number near 0.001
...
...
@@ -75,17 +76,18 @@ bool autodiff_numeric_compare(ngraph::runtime::Backend* backend,
}
template
<
typename
T
>
bool
autodiff_numeric_compare
(
ngraph
::
runtime
::
Backend
*
backend
,
std
::
function
<
std
::
shared_ptr
<
ngraph
::
Function
>
()
>
make_graph
,
const
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
Tensor
>>&
args
,
T
rtol
,
T
atol
)
::
testing
::
AssertionResult
autodiff_numeric_compare
(
ngraph
::
runtime
::
Backend
*
backend
,
std
::
function
<
std
::
shared_ptr
<
ngraph
::
Function
>
()
>
make_graph
,
const
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
Tensor
>>&
args
,
T
rtol
,
T
atol
)
{
return
autodiff_numeric_compare
(
backend
,
make_graph
(),
make_graph
(),
args
,
rtol
,
atol
);
}
template
<
typename
T
>
bool
autodiff_numeric_compare_selective
(
::
testing
::
AssertionResult
autodiff_numeric_compare_selective
(
ngraph
::
runtime
::
Backend
*
backend
,
std
::
shared_ptr
<
ngraph
::
Function
>
f
,
std
::
shared_ptr
<
ngraph
::
Function
>
g
,
...
...
@@ -160,7 +162,7 @@ bool autodiff_numeric_compare_selective(
}
template
<
typename
T
>
bool
autodiff_numeric_compare_selective
(
::
testing
::
AssertionResult
autodiff_numeric_compare_selective
(
ngraph
::
runtime
::
Backend
*
backend
,
std
::
function
<
std
::
shared_ptr
<
ngraph
::
Function
>
()
>
make_graph
,
const
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
Tensor
>>&
args
,
...
...
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