Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hpvm-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
llvm
hpvm-release
Commits
014fc8d3
Commit
014fc8d3
authored
4 years ago
by
Hashim Sharif
Browse files
Options
Downloads
Patches
Plain Diff
Adding test script for Keras Accuracy Check
parent
d4ef8765
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hpvm/projects/keras/scripts/test_benchmarks.py
+115
-0
115 additions, 0 deletions
hpvm/projects/keras/scripts/test_benchmarks.py
hpvm/projects/keras/src/Benchmark.py
+4
-0
4 additions, 0 deletions
hpvm/projects/keras/src/Benchmark.py
with
119 additions
and
0 deletions
hpvm/projects/keras/scripts/test_benchmarks.py
0 → 100644
+
115
−
0
View file @
014fc8d3
import
subprocess
class
Benchmark
:
def
__init__
(
self
,
binary_path
,
test_accuracy
):
self
.
binary_path
=
binary_path
self
.
test_accuracy
=
test_accuracy
self
.
epsilon
=
0.05
# Adding some slack for accuracy difference
def
getPath
(
self
):
return
self
.
binary_path
def
readAccuracy
(
self
):
f
=
open
(
"
final_accuracy
"
,
"
r
"
)
# File with final benchmark accuracy
acc_str
=
f
.
read
()
return
float
(
acc_str
)
def
run
(
self
):
# Test Bechmark accuracy with pretrained weights (hpvm_relaod)
run_cmd
=
"
python
"
+
self
.
binary_path
+
"
hpvm_reload
"
try
:
subprocess
.
call
(
run_cmd
,
shell
=
True
)
except
:
return
False
accuracy
=
self
.
readAccuracy
()
print
(
"
accuracy =
"
,
accuracy
,
"
test_accuracy =
"
,
self
.
test_accuracy
)
test_success
=
False
if
(
abs
(
self
.
test_accuracy
-
accuracy
)
<
self
.
epsilon
):
print
(
"
Test for
"
+
self
.
binary_path
+
"
Passed
"
)
test_success
=
True
else
:
print
(
"
Test Failed for
"
+
self
.
binary_path
)
test_success
=
False
return
test_success
class
BenchmarkTests
:
def
__init__
(
self
):
self
.
benchmarks
=
[]
self
.
passed_tests
=
[]
self
.
failed_tests
=
[]
def
addBenchmark
(
self
,
benchmark
):
self
.
benchmarks
.
append
(
benchmark
)
def
runTests
(
self
):
for
benchmark
in
self
.
benchmarks
:
test_success
=
benchmark
.
run
()
if
not
test_success
:
self
.
failed_tests
.
append
(
benchmark
.
getPath
())
else
:
self
.
passed_tests
.
append
(
benchmark
.
getPath
())
def
printSummary
(
self
):
failed_test_count
=
len
(
self
.
failed_tests
)
passed_test_count
=
len
(
self
.
passed_tests
)
print
(
"
Tests Passed =
"
+
str
(
passed_test_count
)
+
"
/
"
+
str
(
len
(
self
.
benchmarks
)))
print
(
"
******* Passed Tests **
\n
"
)
for
passed_test
in
self
.
passed_tests
:
print
(
"
Passed:
"
+
passed_test
)
print
(
"
Tests Failed =
"
+
str
(
failed_test_count
)
+
"
/
"
+
str
(
len
(
self
.
benchmarks
)))
print
(
"
****** Failed Tests ***
\n
"
)
for
failed_test
in
self
.
failed_tests
:
print
(
"
Failed:
"
+
failed_test
)
if
__name__
==
"
__main__
"
:
testMgr
=
BenchmarkTests
()
AlexNet
=
Benchmark
(
"
src/alexnet.py
"
,
79.28
)
AlexNet2
=
Benchmark
(
"
src/alexnet2.py
"
,
84.98
)
LeNet
=
Benchmark
(
"
src/lenet.py
"
,
98.70
)
MobileNet
=
Benchmark
(
"
src/mobilenet_cifar10.py
"
,
84.42
)
ResNet18
=
Benchmark
(
"
src/resnet18_cifar10.py
"
,
89.56
)
VGG16_cifar10
=
Benchmark
(
"
src/vgg16_cifar10.py
"
,
89.96
)
VGG16_cifar100
=
Benchmark
(
"
src/vgg16_cifar100.py
"
,
66.50
)
testMgr
.
addBenchmark
(
AlexNet
)
testMgr
.
addBenchmark
(
AlexNet2
)
testMgr
.
addBenchmark
(
LeNet
)
testMgr
.
addBenchmark
(
MobileNet
)
testMgr
.
addBenchmark
(
ResNet18
)
testMgr
.
addBenchmark
(
VGG16_cifar10
)
testMgr
.
addBenchmark
(
VGG16_cifar100
)
testMgr
.
runTests
()
testMgr
.
printSummary
()
This diff is collapsed.
Click to expand it.
hpvm/projects/keras/src/Benchmark.py
+
4
−
0
View file @
014fc8d3
...
@@ -90,6 +90,10 @@ class Benchmark:
...
@@ -90,6 +90,10 @@ class Benchmark:
score
=
model
.
evaluate
(
X_test
,
to_categorical
(
y_test
,
self
.
num_classes
),
verbose
=
0
)
score
=
model
.
evaluate
(
X_test
,
to_categorical
(
y_test
,
self
.
num_classes
),
verbose
=
0
)
print
(
'
Test accuracy2:
'
,
score
[
1
])
print
(
'
Test accuracy2:
'
,
score
[
1
])
f
=
open
(
"
final_accuracy
"
,
"
w+
"
)
f
.
write
(
str
(
score
[
1
]
*
100
))
f
.
close
()
if
len
(
argv
)
>
2
:
if
len
(
argv
)
>
2
:
if
argv
[
2
]
==
"
frontend
"
:
if
argv
[
2
]
==
"
frontend
"
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment