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
717c88c5
Commit
717c88c5
authored
5 years ago
by
Elizabeth
Browse files
Options
Downloads
Patches
Plain Diff
Fixed bug in the way quantization costs were cached
parent
9636b220
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/soc_simulator/src/table_generator.py
+17
-38
17 additions, 38 deletions
llvm/projects/soc_simulator/src/table_generator.py
with
17 additions
and
38 deletions
llvm/projects/soc_simulator/src/table_generator.py
+
17
−
38
View file @
717c88c5
...
@@ -65,7 +65,7 @@ class TableGenerator:
...
@@ -65,7 +65,7 @@ class TableGenerator:
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
()
...
@@ -117,11 +117,9 @@ class TableGenerator:
...
@@ -117,11 +117,9 @@ class TableGenerator:
approx_type
=
self
.
__get_approximation_type
(
results_file_name
)
approx_type
=
self
.
__get_approximation_type
(
results_file_name
)
results_file
=
open
(
os
.
path
.
join
(
self
.
__results_dir_path
,
results_file_name
),
"
r
"
)
results_file
=
open
(
os
.
path
.
join
(
self
.
__results_dir_path
,
results_file_name
),
"
r
"
)
for
line
in
results_file
:
for
line
in
results_file
:
line
=
line
.
strip
()
line
=
line
.
strip
()
op_name
,
total_time
,
total_energy
=
self
.
__parse_tensor_operation_line
(
line
)
op_name
,
total_time
,
total_energy
=
self
.
__parse_tensor_operation_line
(
line
)
# If the current operation is f2h or h2f
# If the current operation is f2h or h2f
if
any
(
op_name
.
endswith
(
prec_conv
)
for
prec_conv
in
TableGenerator
.
precision_conversions
):
if
any
(
op_name
.
endswith
(
prec_conv
)
for
prec_conv
in
TableGenerator
.
precision_conversions
):
# Get the original operation name (without the f2h/h2f) and the conversion type
# Get the original operation name (without the f2h/h2f) and the conversion type
...
@@ -132,8 +130,9 @@ class TableGenerator:
...
@@ -132,8 +130,9 @@ 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
][
conversion_type
][
TableGenerator
.
__time_col_name
]
=
total_time
approx_type_no_fp_prefix
=
approx_type
[
5
:
]
self
.
__table
[
orig_op_name
][
conversion_type
][
TableGenerator
.
__energy_col_name
]
=
total_energy
self
.
__table
[
orig_op_name
][
conversion_type
+
"
_
"
+
approx_type_no_fp_prefix
][
TableGenerator
.
__time_col_name
]
=
total_time
self
.
__table
[
orig_op_name
][
conversion_type
+
"
_
"
+
approx_type_no_fp_prefix
][
TableGenerator
.
__energy_col_name
]
=
total_energy
# Create a new row in the dictionary
# Create a new row in the dictionary
else
:
else
:
...
@@ -152,8 +151,6 @@ class TableGenerator:
...
@@ -152,8 +151,6 @@ class TableGenerator:
time and the energy
time and the energy
'''
'''
table_file_path
=
os
.
path
.
join
(
self
.
__results_dir_path
,
self
.
__table_filename
)
table_file_path
=
os
.
path
.
join
(
self
.
__results_dir_path
,
self
.
__table_filename
)
print
(
"
FILE PATH:
"
,
table_file_path
)
soc_operations_file
=
open
(
self
.
__soc_ops_filename
,
"
r
"
)
soc_operations_file
=
open
(
self
.
__soc_ops_filename
,
"
r
"
)
table_file
=
open
(
table_file_path
,
"
w
"
)
table_file
=
open
(
table_file_path
,
"
w
"
)
...
@@ -173,7 +170,6 @@ class TableGenerator:
...
@@ -173,7 +170,6 @@ class TableGenerator:
# 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
=
[
TableGenerator
.
__table_header_delimter
,
layer_name
,
str
(
num_ops
)]
header
=
[
TableGenerator
.
__table_header_delimter
,
layer_name
,
str
(
num_ops
)]
found_h2f
=
found_f2h
=
False
# 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
):
# Contains the operation name
# Contains the operation name
...
@@ -182,45 +178,29 @@ class TableGenerator:
...
@@ -182,45 +178,29 @@ class TableGenerator:
# Stores a list of elements that will be joined to make up a row
# Stores a list of elements that will be joined to make up a row
curr_op
=
[
curr_line
]
curr_op
=
[
curr_line
]
operation_data
=
self
.
__table
[
curr_line
]
operation_data
=
self
.
__table
[
curr_line
]
# 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
found_h2f_op
=
found_f2h_op
=
False
for
approx_type
in
operation_data
:
for
approx_type
in
operation_data
:
if
approx_type
==
"
f2h
"
:
found_f2h
=
found_f2h_op
=
True
if
approx_type
==
"
h2f
"
:
found_h2f
=
found_h2f_op
=
True
if
approx_type
==
"
f2h
"
or
approx_type
==
"
h2f
"
:
print
(
curr_op
,
"
approx type
"
,
approx_type
)
op_time
=
operation_data
[
approx_type
][
TableGenerator
.
__time_col_name
]
op_time
=
operation_data
[
approx_type
][
TableGenerator
.
__time_col_name
]
op_energy
=
operation_data
[
approx_type
][
TableGenerator
.
__energy_col_name
]
op_energy
=
operation_data
[
approx_type
][
TableGenerator
.
__energy_col_name
]
# self.__table[op_name][approx_type][TableGenerator.__energy_col_name] = total_energy
if
approx_type
==
"
f2h
"
or
approx_type
==
"
h2f
"
:
print
(
curr_op
,
op_time
,
op_energy
,
op_in_layer_count
)
curr_op
.
append
(
op_time
)
curr_op
.
append
(
op_time
)
curr_op
.
append
(
op_energy
)
curr_op
.
append
(
op_energy
)
if
op_in_layer_count
==
0
:
if
op_in_layer_count
==
0
:
if
approx_type
==
"
f2h
"
or
approx_type
==
"
h2f
"
:
if
approx_type
==
"
fp32_perf20
"
:
print
(
"
found approx type!
"
)
header
.
append
(
"
fp32_time
"
)
header
.
append
(
"
%s_time
"
%
approx_type
)
header
.
append
(
"
fp32_energy
"
)
header
.
append
(
"
%s_energy
"
%
approx_type
)
elif
approx_type
==
"
fp16_perf20
"
:
header
.
append
(
"
fp16_time
"
)
'''
if not found_h2f_op and found_h2f:
header
.
append
(
"
fp16_energy
"
)
curr_op.append(0)
elif
approx_type
.
find
(
"
f2h_perf20
"
)
!=
-
1
:
curr_op.append(0)
header
.
append
(
"
f2h_time
"
)
if not found_f2h_op and found_f2h:
header
.
append
(
"
f2h_energy
"
)
curr_op.append(0)
else
:
curr_op.append(0)
'''
header
.
append
(
"
%s_time
"
%
approx_type
)
header
.
append
(
"
%s_energy
"
%
approx_type
)
ops_in_layer
.
append
(
'
'
.
join
(
curr_op
))
ops_in_layer
.
append
(
'
'
.
join
(
curr_op
))
# Getting all operation rows and then writing everything because
# Getting all operation rows and then writing everything because
# calls to write() are slow (memory vs time tradeoff)
# calls to write() are slow (memory vs time tradeoff)
'''
if found_h2f:
header.append(
"
h2f_time
"
)
header.append(
"
h2f_energy
"
)
if found_f2h:
header.append(
"
f2h_time
"
)
header.append(
"
f2h_energy
"
)
'''
table_file
.
write
(
"
%s
\n
%s
\n
"
%
(
'
'
.
join
(
header
),
'
\n
'
.
join
(
ops_in_layer
)))
table_file
.
write
(
"
%s
\n
%s
\n
"
%
(
'
'
.
join
(
header
),
'
\n
'
.
join
(
ops_in_layer
)))
curr_line
=
soc_operations_file
.
readline
().
strip
()
curr_line
=
soc_operations_file
.
readline
().
strip
()
...
@@ -250,8 +230,7 @@ class TableGenerator:
...
@@ -250,8 +230,7 @@ class TableGenerator:
Returns:
Returns:
the approximation technique (ex: fp16)
the approximation technique (ex: fp16)
'''
'''
approx_type_start_ind
=
results_filename
.
find
(
self
.
__network_name
)
\
approx_type_start_ind
=
results_filename
.
find
(
"
_
"
,
results_filename
.
find
(
"
_
"
)
+
1
)
+
1
+
len
(
self
.
__network_name
)
+
1
# + 1 to account for _ delimiter
approx_type_end_ind
=
results_filename
.
find
(
"
.txt
"
)
approx_type_end_ind
=
results_filename
.
find
(
"
.txt
"
)
return
results_filename
[
approx_type_start_ind
:
approx_type_end_ind
]
return
results_filename
[
approx_type_start_ind
:
approx_type_end_ind
]
...
...
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