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
abb1f8a7
Commit
abb1f8a7
authored
5 years ago
by
Elizabeth
Browse files
Options
Downloads
Patches
Plain Diff
Implemented fucode to parse results files
parent
4fa3448b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
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
+44
-8
44 additions, 8 deletions
llvm/projects/hpvm-tensor-rt/build_pldi/table_generator.py
with
44 additions
and
8 deletions
llvm/projects/hpvm-tensor-rt/build_pldi/table_generator.py
+
44
−
8
View file @
abb1f8a7
import
collections
import
glob
import
os
import
subprocess
import
shutil
from
collections
import
defaultdict
class
TableGenerator
:
precision_conversions
=
frozenset
([
"
h2f
"
,
"
f2h
"
])
def
__init__
(
self
,
dir_name
,
iters
,
profiler_binary_name
):
self
.
__dir_name
=
dir_name
self
.
__network_name
=
dir_name
...
...
@@ -58,6 +62,19 @@ class TableGenerator:
return
results_filename
[
approx_type_start_ind
:
approx_type_end_ind
]
def
__parse_tensor_operation_line
(
self
,
tensor_op_line
):
line_as_list
=
tensor_op_line
.
split
(
"
,
"
)
return
line_as_list
[
0
],
line_as_list
[
1
],
line_as_list
[
2
]
def
__build_nested_default_dict
(
self
):
return
defaultdict
(
self
.
__build_nested_default_dict
)
# h2f or f2h
def
__get_original_operation_name
(
self
,
op_name
):
underscore_ind
=
op_name
.
find
(
"
_
"
)
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
,
\
...
...
@@ -67,9 +84,8 @@ class TableGenerator:
"
%s_cifar10
"
%
self
.
__network_name
)
shutil
.
copyfile
(
soc_operations_file_name
,
table_filename
)
# Local table --> avoid setting any global variables in case this class is
# reused multiple times
table
=
defaultdict
(
defaultdict
(
str
))
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
):
...
...
@@ -78,19 +94,39 @@ class TableGenerator:
approx_type
=
self
.
__get_approximation_type
(
results_file_name
)
print
(
approx_type
)
results_file
=
open
(
os
.
path
.
join
(
self
.
__results_dir_name
,
results_file_name
),
"
r
"
)
for
line
in
results_file
:
print
(
line
)
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
):
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
if
orig_op_name
not
in
table
:
print
(
"
ERROR: Conversion found but original %s is not in the table
"
%
orig_op_name
)
exit
(
1
)
table
[
orig_op_name
][
conversion_type
][
"
time
"
]
=
total_time
table
[
orig_op_name
][
conversion_type
][
"
energy
"
]
=
total_energy
# Create a new row in the dictionary
else
:
table
[
op_name
][
approx_type
][
"
time
"
]
=
total_time
table
[
op_name
][
approx_type
][
"
energy
"
]
=
total_energy
results_file
.
close
()
# For each output file --> parse and get the storage files
# For each line --> store the time and energy
# <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
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
.
generate_table
s
()
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