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
4a861b77
Unverified
Commit
4a861b77
authored
Feb 15, 2019
by
Robert Kimball
Committed by
GitHub
Feb 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update unit tests (#2444)
parent
1b52a67f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
36 deletions
+32
-36
abc.cpp
doc/examples/abc/abc.cpp
+2
-1
abc_operator.cpp
doc/examples/abc_operator/abc_operator.cpp
+2
-1
dist_mnist_mlp.cpp
doc/examples/mnist_mlp/dist_mnist_mlp.cpp
+14
-17
mnist_mlp.cpp
doc/examples/mnist_mlp/mnist_mlp.cpp
+14
-17
No files found.
doc/examples/abc/abc.cpp
View file @
4a861b77
...
...
@@ -55,7 +55,8 @@ int main()
t_c
->
write
(
&
v_c
,
0
,
sizeof
(
v_c
));
// Invoke the function
backend
->
call
(
f
,
{
t_result
},
{
t_a
,
t_b
,
t_c
});
auto
exec
=
backend
->
compile
(
f
);
exec
->
call
({
t_result
},
{
t_a
,
t_b
,
t_c
});
// Get the result
float
r
[
2
][
3
];
...
...
doc/examples/abc_operator/abc_operator.cpp
View file @
4a861b77
...
...
@@ -54,7 +54,8 @@ int main()
t_c
->
write
(
&
v_c
,
0
,
sizeof
(
v_c
));
// Invoke the function
backend
->
call
(
f
,
{
t_result
},
{
t_a
,
t_b
,
t_c
});
auto
exec
=
backend
->
compile
(
f
);
exec
->
call
({
t_result
},
{
t_a
,
t_b
,
t_c
});
// Get the result
float
r
[
2
][
3
];
...
...
doc/examples/mnist_mlp/dist_mnist_mlp.cpp
View file @
4a861b77
...
...
@@ -73,8 +73,7 @@ size_t accuracy_count(const std::shared_ptr<runtime::Tensor>& t_softmax,
}
float
test_accuracy
(
MNistDataLoader
&
loader
,
std
::
shared_ptr
<
runtime
::
Backend
>
backend
,
std
::
shared_ptr
<
Function
>
function
,
std
::
shared_ptr
<
runtime
::
Executable
>
exec
,
const
std
::
shared_ptr
<
runtime
::
Tensor
>&
t_X
,
const
std
::
shared_ptr
<
runtime
::
Tensor
>&
t_Y
,
const
std
::
shared_ptr
<
runtime
::
Tensor
>&
t_softmax
,
...
...
@@ -96,8 +95,7 @@ float test_accuracy(MNistDataLoader& loader,
t_Y
->
write
(
loader
.
get_label_floats
(),
0
,
loader
.
get_label_batch_size
()
*
sizeof
(
float
));
backend
->
call
(
function
,
{
t_softmax
},
{
t_X
,
t_W0
,
t_b0
,
t_W1
,
t_b1
});
exec
->
call
({
t_softmax
},
{
t_X
,
t_W0
,
t_b0
,
t_W1
,
t_b1
});
size_t
acc
=
accuracy_count
(
t_softmax
,
t_Y
);
acc_count
+=
acc
;
sample_count
+=
batch_size
;
...
...
@@ -236,6 +234,7 @@ int main(int argc, char* argv[])
NodeVector
{
loss
,
softmax
,
W0_next
,
b0_next
,
W1_next
,
b1_next
},
ParameterVector
{
X
,
Y
,
N
,
learning_rate
,
W0
,
b0
,
W1
,
b1
}),
train_node_map
);
auto
train_exec
=
backend
->
compile
(
train_function
);
// Plain inference
// X, W0, b0, W1, b1 -> softmax
...
...
@@ -243,6 +242,7 @@ int main(int argc, char* argv[])
auto
inference_function
=
clone_function
(
Function
(
NodeVector
{
softmax
},
ParameterVector
{
X
,
W0
,
b0
,
W1
,
b1
}),
inference_node_map
);
auto
inference_exec
=
backend
->
compile
(
inference_function
);
set_scalar
(
t_learning_rate
,
.03
f
);
...
...
@@ -256,8 +256,7 @@ int main(int argc, char* argv[])
t_Y
->
write
(
train_loader
.
get_label_floats
(),
0
,
train_loader
.
get_label_batch_size
()
*
sizeof
(
float
));
backend
->
call
(
train_function
,
train_exec
->
call
(
{
t_loss
,
t_softmax
,
t_W0_next
,
...
...
@@ -274,17 +273,15 @@ int main(int argc, char* argv[])
if
(
train_loader
.
get_epoch
()
!=
last_epoch
)
{
last_epoch
=
train_loader
.
get_epoch
();
std
::
cout
<<
"Test accuracy: "
<<
test_accuracy
(
test_loader
,
backend
,
inference_function
,
t_X
,
t_Y
,
t_softmax
,
t_W0
,
t_b0
,
t_W1
,
t_b1
)
std
::
cout
<<
"Test accuracy: "
<<
test_accuracy
(
test_loader
,
inference_exec
,
t_X
,
t_Y
,
t_softmax
,
t_W0
,
t_b0
,
t_W1
,
t_b1
)
<<
std
::
endl
;
}
}
...
...
doc/examples/mnist_mlp/mnist_mlp.cpp
View file @
4a861b77
...
...
@@ -72,8 +72,7 @@ size_t accuracy_count(const std::shared_ptr<runtime::Tensor>& t_softmax,
}
float
test_accuracy
(
MNistDataLoader
&
loader
,
std
::
shared_ptr
<
runtime
::
Backend
>
backend
,
std
::
shared_ptr
<
Function
>
function
,
std
::
shared_ptr
<
runtime
::
Executable
>
exec
,
const
std
::
shared_ptr
<
runtime
::
Tensor
>&
t_X
,
const
std
::
shared_ptr
<
runtime
::
Tensor
>&
t_Y
,
const
std
::
shared_ptr
<
runtime
::
Tensor
>&
t_softmax
,
...
...
@@ -95,8 +94,7 @@ float test_accuracy(MNistDataLoader& loader,
t_Y
->
write
(
loader
.
get_label_floats
(),
0
,
loader
.
get_label_batch_size
()
*
sizeof
(
float
));
backend
->
call
(
function
,
{
t_softmax
},
{
t_X
,
t_W0
,
t_b0
,
t_W1
,
t_b1
});
exec
->
call
({
t_softmax
},
{
t_X
,
t_W0
,
t_b0
,
t_W1
,
t_b1
});
size_t
acc
=
accuracy_count
(
t_softmax
,
t_Y
);
acc_count
+=
acc
;
sample_count
+=
batch_size
;
...
...
@@ -223,6 +221,7 @@ int main(int argc, const char* argv[])
NodeVector
{
loss
,
softmax
,
W0_next
,
b0_next
,
W1_next
,
b1_next
},
ParameterVector
{
X
,
Y
,
N
,
learning_rate
,
W0
,
b0
,
W1
,
b1
}),
train_node_map
);
auto
train_exec
=
backend
->
compile
(
train_function
);
// Plain inference
// X, W0, b0, W1, b1 -> softmax
...
...
@@ -230,6 +229,7 @@ int main(int argc, const char* argv[])
auto
inference_function
=
clone_function
(
Function
(
NodeVector
{
softmax
},
ParameterVector
{
X
,
W0
,
b0
,
W1
,
b1
}),
inference_node_map
);
auto
inference_exe
=
backend
->
compile
(
inference_function
);
set_scalar
(
t_learning_rate
,
.03
f
);
...
...
@@ -243,8 +243,7 @@ int main(int argc, const char* argv[])
t_Y
->
write
(
train_loader
.
get_label_floats
(),
0
,
train_loader
.
get_label_batch_size
()
*
sizeof
(
float
));
backend
->
call
(
train_function
,
train_exec
->
call
(
{
t_loss
,
t_softmax
,
t_W0_next
,
...
...
@@ -261,17 +260,15 @@ int main(int argc, const char* argv[])
if
(
train_loader
.
get_epoch
()
!=
last_epoch
)
{
last_epoch
=
train_loader
.
get_epoch
();
std
::
cout
<<
"Test accuracy: "
<<
test_accuracy
(
test_loader
,
backend
,
inference_function
,
t_X
,
t_Y
,
t_softmax
,
t_W0
,
t_b0
,
t_W1
,
t_b1
)
std
::
cout
<<
"Test accuracy: "
<<
test_accuracy
(
test_loader
,
exec
,
t_X
,
t_Y
,
t_softmax
,
t_W0
,
t_b0
,
t_W1
,
t_b1
)
<<
std
::
endl
;
}
}
...
...
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