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
7159ab99
Commit
7159ab99
authored
3 years ago
by
Yifan Zhao
Browse files
Options
Downloads
Patches
Plain Diff
Make approxhpvm.py an installable package (hpvmpy)
parent
8d8e7abe
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
hpvm/tools/py-approxhpvm/CMakeLists.txt
+31
-10
31 additions, 10 deletions
hpvm/tools/py-approxhpvm/CMakeLists.txt
hpvm/tools/py-approxhpvm/main.py.in
+5
-1
5 additions, 1 deletion
hpvm/tools/py-approxhpvm/main.py.in
hpvm/tools/py-approxhpvm/setup.py
+15
-0
15 additions, 0 deletions
hpvm/tools/py-approxhpvm/setup.py
with
51 additions
and
11 deletions
hpvm/tools/py-approxhpvm/CMakeLists.txt
+
31
−
10
View file @
7159ab99
# This file is very tightly coupled with main.py.in.
# This file is very tightly coupled with main.py.in.
# Watch out and keep them in sync.
# Watch out and keep them in sync.
# main.py.in (to become approxhpvm.py) requires the following variables:
# CMake fills in some variables in main.py.in and generate it into a python package:
# `hpvmpy`, which is the main entry point and Python API for HPVM.
# ---[ Define variables for main.py.in
# main.py.in requires the following variables:
# LLVM_PROJECT_DIR, LLVM_BUILD_DIR
# LLVM_PROJECT_DIR, LLVM_BUILD_DIR
# TRT_PATH, TRT_INCLUDE_DIRS, TRT_LINK_DIRS, TRT_LINK_LIBS
# TRT_PATH, TRT_INCLUDE_DIRS, TRT_LINK_DIRS, TRT_LINK_LIBS
# DIRECT_LINK_LIBS
# DIRECT_LINK_LIBS
...
@@ -34,21 +39,37 @@ set(
...
@@ -34,21 +39,37 @@ set(
LLVMGenHPVM
LLVMGenHPVM
)
)
# ---[ Create package folder structure
# This sounds crazy but since main.py.in is generated into another file under build/ dir,
# to make a python package around it, we'll have to generate the whole package structure
# in build/ as well.
# Target dir structure:
# ${CMAKE_CURRENT_BINARY_DIR}
# hpvmpy/
# __init__.py <- generated from main.py.in
# setup.py <- copied from setup.py
file
(
MAKE_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
/hpvmpy
)
file
(
COPY setup.py DESTINATION
${
CMAKE_CURRENT_BINARY_DIR
}
)
# ---[ Generate main.py.in to hpvmpy/__init__.py
set
(
init_path
${
CMAKE_CURRENT_BINARY_DIR
}
/hpvmpy/__init__.py
)
# First resolve all `@symbol@` by configuring the file
# First resolve all `@symbol@` by configuring the file
configure_file
(
main.py.in
${
CMAKE_CURRENT_BINARY_DIR
}
/main.py.conf
)
configure_file
(
main.py.in
${
CMAKE_CURRENT_BINARY_DIR
}
/main.py.conf
)
# Then resolve all generator expressions we configured into the previous file
# Then resolve all generator expressions we configured into the previous file
file
(
GENERATE OUTPUT
${
CMAKE_CURRENT_BINARY_DIR
}
/main.py INPUT
${
CMAKE_CURRENT_BINARY_DIR
}
/main.py.conf
)
file
(
GENERATE OUTPUT
${
CMAKE_CURRENT_BINARY_DIR
}
/main.py INPUT
${
CMAKE_CURRENT_BINARY_DIR
}
/main.py.conf
)
# Delibrately create an extra step of moving file
# Delibrately create an extra step of moving file
# which is carried out at build time (as a target)
# which is carried out at build time (as a target)
# so we can set these dependencies on it
# so we can set these dependencies on it.
set
(
set
(
DEPS tensor_runtime hpvm-rt-bc clang opt llvm-link
${
AVAILABLE_PASSES
}
)
DEPS
tensor_runtime hpvm-rt-bc clang opt llvm-link
${
AVAILABLE_PASSES
}
)
add_custom_command
(
add_custom_command
(
OUTPUT
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/approxhpvm.py
OUTPUT
${
init_path
}
COMMAND cp
${
CMAKE_CURRENT_BINARY_DIR
}
/main.py
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/approxhpvm.py
COMMAND cp
${
CMAKE_CURRENT_BINARY_DIR
}
/main.py
${
init_path
}
COMMAND chmod +x
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/approxhpvm.py
DEPENDS
${
DEPS
}
${
CMAKE_CURRENT_BINARY_DIR
}
/main.py
DEPENDS
${
DEPS
}
${
CMAKE_CURRENT_BINARY_DIR
}
/main.py
)
)
add_custom_target
(
approxhpvm.py ALL DEPENDS
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/approxhpvm.py
)
# ---[ Call python3 -m pip to install this package.
add_custom_target
(
hpvmpy
COMMAND python3 -m pip install ./
DEPENDS
${
init_path
}
setup.py
)
This diff is collapsed.
Click to expand it.
hpvm/tools/py-approxhpvm/main.py.in
+
5
−
1
View file @
7159ab99
...
@@ -183,5 +183,9 @@ def parse_args():
...
@@ -183,5 +183,9 @@ def parse_args():
return
args
return
args
if
__name__
==
"
__
main
__
"
:
def
main
()
:
compile_hpvm_c
(
**
vars
(
parse_args
()))
compile_hpvm_c
(
**
vars
(
parse_args
()))
if
__name__
==
"
__main__
"
:
main
()
This diff is collapsed.
Click to expand it.
hpvm/tools/py-approxhpvm/setup.py
0 → 100644
+
15
−
0
View file @
7159ab99
import
setuptools
setuptools
.
setup
(
name
=
"
hpvmpy
"
,
version
=
"
1.0
"
,
author
=
"
Yifan Zhao
"
,
author_email
=
"
yifanz16@illinois.edu
"
,
description
=
"
HPVM Python API
"
,
packages
=
[
"
hpvmpy
"
],
entry_points
=
{
"
console_scripts
"
:
[
"
hpvm-clang = hpvmpy:main
"
,
],
},
)
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