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
7005d0cc
"hpvm/include/SupportHPVM/HPVMUtils.h" did not exist on "27911af0a14a6b7c5b9d07c4f585e353ab71f99a"
Commit
7005d0cc
authored
5 years ago
by
Elizabeth
Browse files
Options
Downloads
Patches
Plain Diff
FFinalized internal table storage code
parent
abb1f8a7
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/build_pldi/table_generator.py
+34
-21
34 additions, 21 deletions
llvm/projects/hpvm-tensor-rt/build_pldi/table_generator.py
with
34 additions
and
21 deletions
llvm/projects/hpvm-tensor-rt/build_pldi/table_generator.py
+
34
−
21
View file @
7005d0cc
...
...
@@ -11,10 +11,13 @@ class TableGenerator:
def
__init__
(
self
,
dir_name
,
iters
,
profiler_binary_name
):
self
.
__dir_name
=
dir_name
self
.
__network_name
=
dir_name
# directory/path/network_name (last item in path)
self
.
__network_name
=
os
.
path
.
split
(
dir_name
)[
-
1
]
self
.
__iters
=
iters
self
.
__profiler_binary_name
=
profiler_binary_name
self
.
__results_dir_name
=
"
%s_results
"
%
self
.
__dir_name
def
__is_binary
(
self
,
file_path
):
...
...
@@ -27,7 +30,6 @@ class TableGenerator:
if
not
os
.
path
.
isdir
(
self
.
__dir_name
):
print
(
"
ERROR: Directory %s not found
"
%
self
.
__dir_name
)
exit
(
1
)
self
.
__results_dir_name
=
"
%s_results
"
%
self
.
__dir_name
try
:
os
.
mkdir
(
self
.
__results_dir_name
)
...
...
@@ -56,13 +58,14 @@ class TableGenerator:
def
__get_approximation_type
(
self
,
results_filename
):
approx_type_start_ind
=
results_file
.
find
(
self
.
__network_name
)
\
approx_type_start_ind
=
results_file
name
.
find
(
self
.
__network_name
)
\
+
len
(
self
.
__network_name
)
+
1
# + 1 to account for _ delimiter
approx_type_end_ind
=
results_file
.
find
(
"
.txt
"
)
approx_type_end_ind
=
results_file
name
.
find
(
"
.txt
"
)
return
results_filename
[
approx_type_start_ind
:
approx_type_end_ind
]
def
__parse_tensor_operation_line
(
self
,
tensor_op_line
):
print
(
tensor_op_line
)
line_as_list
=
tensor_op_line
.
split
(
"
,
"
)
return
line_as_list
[
0
],
line_as_list
[
1
],
line_as_list
[
2
]
...
...
@@ -76,19 +79,13 @@ class TableGenerator:
return
op_name
[
:
underscore_ind
],
op_name
[
underscore_ind
+
1
:
]
def
generate_table
(
self
):
# Copy ops file to results directory to use as empty table
table_filename
=
os
.
path
.
join
(
self
.
__results_dir_name
,
\
"
%s_tensors.txt
"
%
self
.
__network_name
)
# TODO un hard code this
soc_operations_file_name
=
os
.
path
.
join
(
"
/home/nvidia/soc_simulator
"
,
\
"
%s_cifar10
"
%
self
.
__network_name
)
shutil
.
copyfile
(
soc_operations_file_name
,
table_filename
)
table
=
self
.
__build_nested_default_dict
()
for
results_file_name
in
os
.
listdir
(
self
.
__results_dir_name
):
# Ignore if not a results file
if
not
results_file_name
.
startswith
(
self
.
__network_name
):
print
(
results_file_name
,
self
.
__network_name
)
# Ignore if it's the output file or if it's not a results file
if
results_file_name
==
table_filename
or
\
not
results_file_name
.
startswith
(
self
.
__network_name
):
continue
approx_type
=
self
.
__get_approximation_type
(
results_file_name
)
...
...
@@ -96,12 +93,13 @@ class TableGenerator:
results_file
=
open
(
os
.
path
.
join
(
self
.
__results_dir_name
,
results_file_name
),
"
r
"
)
for
line
in
results_file
:
line
=
line
.
strip
()
op_name
,
total_time
,
total_energy
=
self
.
__parse_tensor_operation_line
(
line
)
print
(
op_name
,
total_time
,
total_energy
)
# Handle _f2h and _h2f output for tensor operation
# Store as columns of original operation rather than independent rows
if
any
(
op_name
.
endswith
(
prec_conv
)
for
prec_conv
in
precision_conversions
):
if
any
(
op_name
.
endswith
(
prec_conv
)
for
prec_conv
in
TableGenerator
.
precision_conversions
):
orig_op_name
,
conversion_type
=
self
.
__get_original_operation_name
(
op_name
)
print
(
"
f2h/h2f
"
,
orig_op_name
,
conversion_type
)
# Error bc original op name should ALWAYS be in the table
...
...
@@ -117,16 +115,31 @@ class TableGenerator:
table
[
op_name
][
approx_type
][
"
energy
"
]
=
total_energy
results_file
.
close
()
# Then output everything
# <operation name> <type of approx> <time> <energy>
# Need to map to soc_operations file
# final file should be in the format of the soc_operations file
# output file --> just need to search by the conv name
# generate header
# Copy ops file to results directory to use as empty table
table_filename
=
"
%s_tensors.txt
"
%
self
.
__network_name
table_file_path
=
os
.
path
.
join
(
self
.
__results_dir_name
,
table_filename
)
# TODO un hard code this
soc_operations_file_name
=
os
.
path
.
join
(
"
/home/nvidia/soc_simulator
"
,
\
"
%s_cifar10
"
%
self
.
__network_name
,
"
%s_ops.txt
"
%
self
.
__network_name
)
#shutil.copyfile(soc_operations_file_name, table_file_path)
# Output in the order of everything in the file
# Conv1,1 = leave the same
# Next line: Conv1 --> find it
# don't need to copy the file over --> can use the original file as a reference
soc_operations_file
=
open
(
soc_operations_file_name
,
"
r
"
)
table_file
=
open
(
table_filename
,
"
w
"
)
for
line
in
soc_operations_file
:
if
line
.
startswith
(
"
#
"
):
# TODO variable
table_file
.
write
(
line
)
# Copy to table file
# Then write the new header for
binary_dir_name
=
"
/home/nvidia/Gitlab/hpvm/llvm/projects/hpvm-tensor-rt/build_pldi/mobilenet
"
num_iters
=
1
profiler_binary_name
=
"
/home/nvidia/awesome_profiler/pp
"
table_gen
=
TableGenerator
(
binary_dir_name
,
num_iters
,
profiler_binary_name
)
table_gen
.
run_binaries_in_input_dir
()
#
table_gen.run_binaries_in_input_dir()
table_gen
.
generate_table
()
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