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
fc8fcc2a
Commit
fc8fcc2a
authored
5 years ago
by
Elizabeth
Browse files
Options
Downloads
Patches
Plain Diff
Added code that copies over setup CMakeLists instructions
parent
fe24d072
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/hpvm-tensor-rt/code_autogenerators/cmakelists_generator.py
+59
-0
59 additions, 0 deletions
...pvm-tensor-rt/code_autogenerators/cmakelists_generator.py
with
59 additions
and
0 deletions
llvm/projects/hpvm-tensor-rt/code_autogenerators/cmakelists_generator.py
0 → 100644
+
59
−
0
View file @
fc8fcc2a
# Generates a CMakeLists.txt file for all generated files in a specific directory
# Input: Arbitrarily long list containing names of all generated files directories
# Ex: alexnet_cifar10_autogenerated_knobs mobilenet_cifar10_autogenerated_knobs
# If inputted 0 parameters: Generates CMakeLists.txt file for all generated files in CURRENT dir
import
sys
import
os
def
get_all_generated_directory_names
():
'''
Returns a list of all generated source code directories (<>_autogenerated_knobs)
in the current directory. Called when program is run with 0 args
'''
generated_dir_names
=
[]
for
dir_name
in
os
.
listdir
(
"
.
"
):
if
dir_name
.
endswith
(
"
autogenerated_knobs
"
):
generated_dir_names
.
append
(
dir_name
)
return
generated_dir_names
def
generate_cmakelists_setup
(
cmakelists_file
):
'''
Copies over all the setup instructions (ex: finding libraries) from a
"
base
"
CMakeLists.txt
file. Ends copyng when we find the first instance of add_executable
Args:
cmakelists_file: File object to write cmake instructions to
Assumption: All setup instructions are being any add_executable instructions
'''
BASE_CMAKELISTS_PATH
=
"
/home/nvidia/Gitlab/hpvm/llvm/projects/hpvm-tensor-rt/CMakeLists.txt
"
base_cmakelists_file
=
open
(
BASE_CMAKELISTS_PATH
,
"
r
"
)
for
line
in
base_cmakelists_file
:
if
line
.
find
(
"
add_executable
"
)
!=
-
1
:
break
cmakelists_file
.
write
(
line
)
base_cmakelists_file
.
close
()
def
generate_cmakelists_file
(
cmakelists_file
,
source_code_dirs
):
generate_cmakelists_setup
(
cmakelists_file
)
for
source_code_dir
in
source_code_dirs
:
pass
if
__name__
==
"
__main__
"
:
num_args
=
len
(
sys
.
argv
)
if
num_args
>=
2
and
sys
.
argv
[
1
]
==
"
--usage
"
:
print
(
"
python cmakelists_generator.py <names of all generated files directories>
"
)
print
(
"
If given no parameters: Generates CMakeLists.txt file for all generated files in CURRENT directory
"
)
exit
(
1
)
cmakelists_file
=
open
(
"
CMakeLists.txt
"
,
"
w
"
)
if
num_args
==
1
:
generate_cmakelists_file
(
cmakelists_file
,
get_all_generated_directory_names
())
else
:
generate_cmakelists_file
(
cmakelists_file
,
sys
.
argv
[
1
:])
cmakelists_file
.
close
()
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