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
ea63a67e
Commit
ea63a67e
authored
5 years ago
by
Elizabeth
Browse files
Options
Downloads
Patches
Plain Diff
Replaced hard coded strs with variables for portability
parent
516e468a
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
+17
-13
17 additions, 13 deletions
llvm/projects/hpvm-tensor-rt/build_pldi/table_generator.py
with
17 additions
and
13 deletions
llvm/projects/hpvm-tensor-rt/build_pldi/table_generator.py
+
17
−
13
View file @
ea63a67e
...
@@ -6,7 +6,12 @@ import shutil
...
@@ -6,7 +6,12 @@ import shutil
from
collections
import
defaultdict
from
collections
import
defaultdict
class
TableGenerator
:
class
TableGenerator
:
__ops_header_delimiter
=
"
#
"
__table_header_delimter
=
"
**
"
__time_col_name
=
"
time
"
__energy_col_name
=
"
energy
"
'''
'''
Stores all precision conversions used.
Stores all precision conversions used.
'''
'''
...
@@ -37,8 +42,8 @@ class TableGenerator:
...
@@ -37,8 +42,8 @@ class TableGenerator:
self
.
__table
=
self
.
__build_nested_default_dict
()
self
.
__table
=
self
.
__build_nested_default_dict
()
def
generate_table
(
self
):
def
generate_table
(
self
):
'''
'''
Generates a table file called <network_name>_tensors.txt in the following
Generates a table file called <network_name>_tensors.txt in the following
steps:
steps:
1. Runs the offline profiler against the inputted binaries to generate
1. Runs the offline profiler against the inputted binaries to generate
...
@@ -47,7 +52,7 @@ class TableGenerator:
...
@@ -47,7 +52,7 @@ class TableGenerator:
the offline profiler generated
the offline profiler generated
3. Writes the internal table to <network_name>_tensors.txt file and uses the
3. Writes the internal table to <network_name>_tensors.txt file and uses the
<network_name>_ops.txt file as a guideline in terms of row order
<network_name>_ops.txt file as a guideline in terms of row order
'''
'''
#self.__run_inputted_binaries()
#self.__run_inputted_binaries()
self
.
__build_internal_table
()
self
.
__build_internal_table
()
self
.
__output_table_to_file
()
self
.
__output_table_to_file
()
...
@@ -115,13 +120,13 @@ class TableGenerator:
...
@@ -115,13 +120,13 @@ class TableGenerator:
exit
(
1
)
exit
(
1
)
# Store f2h and h2f as columns in the row belonging to the original operation
# Store f2h and h2f as columns in the row belonging to the original operation
self
.
__table
[
orig_op_name
][
approx_type
][
"
time
"
]
=
total_time
self
.
__table
[
orig_op_name
][
approx_type
][
TableGenerator
.
__time_col_name
]
=
total_time
self
.
__table
[
orig_op_name
][
approx_type
][
"
energy
"
]
=
total_energy
self
.
__table
[
orig_op_name
][
approx_type
][
TableGenerator
.
__energy_col_name
]
=
total_energy
# Create a new row in the dictionary
# Create a new row in the dictionary
else
:
else
:
self
.
__table
[
op_name
][
approx_type
][
"
time
"
]
=
total_time
self
.
__table
[
op_name
][
approx_type
][
TableGenerator
.
__time_col_name
]
=
total_time
self
.
__table
[
op_name
][
approx_type
][
"
energy
"
]
=
total_energy
self
.
__table
[
op_name
][
approx_type
][
TableGenerator
.
__energy_col_name
]
=
total_energy
results_file
.
close
()
results_file
.
close
()
...
@@ -156,7 +161,7 @@ class TableGenerator:
...
@@ -156,7 +161,7 @@ class TableGenerator:
# The header is only generated for the first operation in the layer
# The header is only generated for the first operation in the layer
# CRITICAL ASSUMPTION: All operations within a layer have the same # columns
# CRITICAL ASSUMPTION: All operations within a layer have the same # columns
# or everything breaks bc the header is per layer, not per operation
# or everything breaks bc the header is per layer, not per operation
header
=
[
"
**
"
,
layer_name
,
str
(
num_ops
)]
header
=
[
TableGenerator
.
__table_header_delimter
,
layer_name
,
str
(
num_ops
)]
# Iterate through all operations within the layer
# Iterate through all operations within the layer
for
op_in_layer_count
in
range
(
num_ops
):
for
op_in_layer_count
in
range
(
num_ops
):
...
@@ -170,8 +175,8 @@ class TableGenerator:
...
@@ -170,8 +175,8 @@ class TableGenerator:
# Iterate through time/energy data for each approximation type corresponding
# Iterate through time/energy data for each approximation type corresponding
# to the current operation
# to the current operation
for
approx_type
in
operation_data
:
for
approx_type
in
operation_data
:
op_time
=
operation_data
[
approx_type
][
"
time
"
]
op_time
=
operation_data
[
approx_type
][
TableGenerator
.
__time_col_name
]
op_energy
=
operation_data
[
approx_type
][
"
energy
"
]
op_energy
=
operation_data
[
approx_type
][
TableGenerator
.
__energy_col_name
]
curr_op
.
append
(
op_time
)
curr_op
.
append
(
op_time
)
curr_op
.
append
(
op_energy
)
curr_op
.
append
(
op_energy
)
...
@@ -273,7 +278,7 @@ class TableGenerator:
...
@@ -273,7 +278,7 @@ class TableGenerator:
number of ops in the layer
number of ops in the layer
'''
'''
comma_ind
=
layer_info_line
.
find
(
"
,
"
)
comma_ind
=
layer_info_line
.
find
(
"
,
"
)
return
layer_info_line
[
layer_info_line
.
find
(
"
#
"
)
+
1
:
comma_ind
],
\
return
layer_info_line
[
layer_info_line
.
find
(
TableGenerator
.
__ops_header_delimiter
)
+
1
:
comma_ind
],
\
int
(
layer_info_line
[
comma_ind
+
1
:
])
int
(
layer_info_line
[
comma_ind
+
1
:
])
...
@@ -282,5 +287,4 @@ if __name__ == "__main__":
...
@@ -282,5 +287,4 @@ if __name__ == "__main__":
num_iters
=
1
num_iters
=
1
profiler_binary_name
=
"
/home/nvidia/awesome_profiler/pp
"
profiler_binary_name
=
"
/home/nvidia/awesome_profiler/pp
"
table_gen
=
TableGenerator
(
binary_dir_path
,
num_iters
,
profiler_binary_name
)
table_gen
=
TableGenerator
(
binary_dir_path
,
num_iters
,
profiler_binary_name
)
#table_gen.run_inputted_binaries()
table_gen
.
generate_table
()
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