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
6b962ae4
"docs/rdd-programming-guide.md" did not exist on "5ffd5d3838da40ad408a6f40071fe6f4dcacf2a1"
Commit
6b962ae4
authored
4 years ago
by
Hashim Sharif
Browse files
Options
Downloads
Patches
Plain Diff
Adding source compile option (incomplete) to common Benchmark script
parent
611f946d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
llvm/projects/keras/src/Benchmark.py
+24
-4
24 additions, 4 deletions
llvm/projects/keras/src/Benchmark.py
with
24 additions
and
4 deletions
llvm/projects/keras/src/Benchmark.py
+
24
−
4
View file @
6b962ae4
import
sys
import
os
import
shutil
from
keras.utils.np_utils
import
to_categorical
from
keras.models
import
load_model
from
frontend.approxhpvm_translator
import
translate_to_approxhpvm
...
...
@@ -8,7 +10,8 @@ from frontend.weight_utils import dumpCalibrationData
from
frontend.weight_utils
import
dumpHPVMToKerasModel
# Every CNN Benchmark must inherit from Benchmark class
# Defines common interfaces and virtual methods to be overridden by child classes
class
Benchmark
:
def
__init__
(
self
,
name
,
reload_dir
,
keras_model_file
,
hpvm_dir
,
num_classes
):
...
...
@@ -32,14 +35,30 @@ class Benchmark:
return
# Compiles frontend generated sources
def
compileSource
(
self
,
working_dir
):
# set LLVM_SRC_ROOT
os
.
environ
[
"
CFLAGS
"
]
=
""
os
.
environ
[
"
CXXFLAGS
"
]
=
""
dest_file
=
working_dir
+
"
CMakeLists.txt
"
shutil
.
copy
(
"
cmake_template/CMakeLists.txt
"
,
dest_file
)
# Cmake ../
# make
def
run
(
self
,
argv
):
if
len
(
argv
)
<
2
:
print
(
"
Usage: python ${benchmark.py} [hpvm_reload|keras_reload|train] [frontend]
"
)
print
(
"
Usage: python ${benchmark.py} [hpvm_reload|keras_reload|train] [frontend]
[compile]
"
)
sys
.
exit
(
0
)
# Virtual method call implemented by each CNN
model
=
self
.
buildModel
()
# Virtual method call to preprocess test and train data
X_train
,
Y_train
,
X_test
,
Y_test
=
self
.
data_preprocess
()
if
argv
[
1
]
==
"
hpvm_reload
"
:
...
...
@@ -60,11 +79,12 @@ class Benchmark:
print
(
"
ERROR: Must load HPVM model to invoke frontend - use
'
hpvm_reload
'"
)
sys
.
exit
(
1
)
# Main call to ApproxHPVM-Keras Frontend
working_dir
=
translate_to_approxhpvm
(
model
,
self
.
hpvm_dir
,
X_test
,
Y_test
,
self
.
num_classes
)
print
(
"
*** working_dir =
"
,
working_dir
)
if
len
(
argv
)
>
3
and
argv
[
3
]
==
"
compile
"
:
self
.
compileSource
(
working_dir
)
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