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
d2c75855
Commit
d2c75855
authored
4 years ago
by
Hashim Sharif
Browse files
Options
Downloads
Patches
Plain Diff
Adding automatic HPVM compile option to Keras frontend
parent
4f3e3d90
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hpvm/projects/keras/frontend/approxhpvm_translator.py
+1
-1
1 addition, 1 deletion
hpvm/projects/keras/frontend/approxhpvm_translator.py
hpvm/projects/keras/src/Benchmark.py
+29
-10
29 additions, 10 deletions
hpvm/projects/keras/src/Benchmark.py
with
30 additions
and
11 deletions
hpvm/projects/keras/frontend/approxhpvm_translator.py
+
1
−
1
View file @
d2c75855
...
...
@@ -1127,5 +1127,5 @@ def translate_to_approxhpvm(model,
print
(
"
-- ApproxHPVM src :
"
,
src_dir
+
"
approxhpvm_src.cc
"
)
return
weights
_dir
return
src
_dir
This diff is collapsed.
Click to expand it.
hpvm/projects/keras/src/Benchmark.py
+
29
−
10
View file @
d2c75855
...
...
@@ -3,6 +3,7 @@
import
sys
import
os
import
shutil
import
subprocess
from
keras.utils.np_utils
import
to_categorical
from
keras.models
import
load_model
from
frontend.approxhpvm_translator
import
translate_to_approxhpvm
...
...
@@ -39,18 +40,36 @@ class Benchmark:
# Compiles frontend generated sources
def
compileSource
(
self
,
working_dir
):
src_file
=
os
.
getcwd
()
+
"
/
"
+
working_dir
+
"
/approxhpvm_src.cc
"
target_binary
=
os
.
getcwd
()
+
"
/
"
+
working_dir
+
"
/HPVM_binary
"
approx_conf_file
=
"
tuner_confs.txt
"
# 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
FNULL
=
open
(
os
.
devnull
,
'
w
'
)
try
:
subprocess
.
run
([
"
approxhpvm.py
"
,
"
-h
"
],
check
=
True
,
stdout
=
FNULL
)
except
:
print
(
"
\n\n
ERROR: Could not find approxhpvm.py (HPVM compile script)!!
\n\n
"
)
print
(
"
To Compile, Must set PATH to include approxhpvm.py script. Do the following:
"
)
print
(
"
**** export PATH=${PATH_TO_YOUR_HPVM_INSTALLATION}/build/bin/:$PATH *****
"
)
sys
.
exit
(
1
)
try
:
subprocess
.
run
([
"
approxhpvm.py
"
,
src_file
,
target_binary
,
"
-t
"
,
"
tensor
"
,
"
--conf-file
"
,
approx_conf_file
],
check
=
True
)
except
:
print
(
"
\n\n
ERROR: HPVM Compilation Failed!!
\n\n
"
)
sys
.
exit
(
1
)
def
printUsage
(
self
):
print
(
"
Usage: python ${benchmark.py} [hpvm_reload|train] [frontend] [compile]
"
)
...
...
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