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
9636b220
Commit
9636b220
authored
5 years ago
by
Elizabeth
Browse files
Options
Downloads
Patches
Plain Diff
Fixed bug that always reads fp16/fp32 value
parent
53e5579d
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/soc_simulator/src/driver_new_config.py
+38
-31
38 additions, 31 deletions
llvm/projects/soc_simulator/src/driver_new_config.py
with
38 additions
and
31 deletions
llvm/projects/soc_simulator/src/driver_new_config.py
+
38
−
31
View file @
9636b220
...
...
@@ -139,14 +139,10 @@ class Driver:
operation_data
[
"
Name
"
]
=
op_name
# Number of data items (#s) needs to match up with the # of cols
print
(
len
(
op_data
)
-
1
,
len
(
col_names
))
print
(
op_data
)
print
(
col_names
)
assert
(
len
(
op_data
)
-
1
==
len
(
col_names
))
assert
(
len
(
op_data
)
-
1
==
len
(
col_names
))
# Go through all data items (each col element) per operation
for
i
in
range
(
len
(
col_names
)):
print
(
col_names
[
i
],
float
(
op_data
[
i
+
1
]))
operation_data
[
col_names
[
i
]]
=
float
(
op_data
[
i
+
1
])
layer_operations
.
append
(
operation_data
)
...
...
@@ -154,7 +150,7 @@ class Driver:
self
.
__tensor_table
[
layer_name
]
=
layer_operations
line
=
table_file
.
readline
().
strip
()
table_file
.
close
()
print
(
self
.
__tensor_table
[
"
Conv2
"
])
@staticmethod
def
is_promise
(
layer_hardware
):
...
...
@@ -223,23 +219,25 @@ class Driver:
op_number
=
layer_as_lst
[
i
+
2
]
approx_type
=
None
if
precision_type
==
"
fp16
"
or
line
.
find
(
"
fp16
"
)
!=
-
1
:
if
line
.
find
(
"
fp16
"
)
!=
-
1
:
curr_layer
=
Driver
.
PrecisionTypes
.
FP16
elif
precision_type
==
"
fp32
"
or
line
.
find
(
"
fp32
"
)
!=
-
1
:
elif
line
.
find
(
"
fp32
"
)
!=
-
1
:
curr_layer
=
Driver
.
PrecisionTypes
.
FP32
elif
precision_type
==
"
perf
"
or
precision_type
==
"
samp
"
:
# Handle approx type
if
precision_type
==
"
perf
"
or
precision_type
==
"
samp
"
:
# Handle approx type
if
precision_type
==
"
perf
"
:
approx_type
=
Driver
.
ApproxTypes
.
PERF
elif
precision_type
==
"
samp
"
:
approx_type
=
Driver
.
ApproxTypes
.
SAMP
if
line
.
find
(
"
fp16
"
)
!=
-
1
:
curr_layer
=
Driver
.
PrecisionTypes
.
FP16
elif
line
.
find
(
"
fp32
"
)
!=
-
1
:
curr_layer
=
Driver
.
PrecisionTypes
.
FP32
quant_time
,
quant_energy
=
self
.
__quantize
(
curr_layer
,
prev_layer
,
\
tensor_count
,
layer_table_data
)
quant_time
,
quant_energy
=
0
,
0
#self.__quantize(curr_layer, prev_layer, \
#tensor_count, layer_table_data)
if
quant_time
!=
0
:
print
(
"
QUANT TIME/ENERGY
"
,
quant_time
,
quant_energy
)
conv_time
,
conv_energy
=
self
.
__run_gpu_simulation
(
curr_layer
,
layer_name
,
\
tensor_count
,
approx_type
,
op_number
)
layer_results
.
append
((
quant_time
+
conv_time
,
quant_energy
+
conv_energy
,
'
'
.
join
(
layer_as_lst
[
i
:
i
+
3
])))
...
...
@@ -251,10 +249,10 @@ class Driver:
curr_conf_results
.
append
(
layer_results
)
#self.__conf_results[conf_name] = (first_line, curr_conf_results)
print
(
curr_conf_results
)
self
.
__conf_results
.
append
(
(
first_line
,
curr_conf_results
)
)
line
=
config_file
.
readline
().
strip
()
config_file
.
close
()
#print("AGGREGATE RESULTS", self.__aggregate_results)
def
__quantize
(
self
,
curr_layer
,
prev_layer
,
h2f_f2h_operation_ind
,
layer_data
):
if
curr_layer
==
prev_layer
or
curr_layer
==
Driver
.
PrecisionTypes
.
PROMISE
\
...
...
@@ -280,7 +278,6 @@ class Driver:
energy_key
=
"
f2h_energy
"
time
=
tensor_op_row
[
time_key
]
energy
=
tensor_op_row
[
energy_key
]
print
(
time_key
,
energy_key
,
time
,
energy
)
print
(
"
Quantization: (%f, %f)
"
%
(
time
,
energy
))
return
(
time
,
energy
)
...
...
@@ -312,17 +309,19 @@ class Driver:
total_time_energy
=
output
.
strip
().
split
(
'
,
'
)
assert
(
len
(
total_time_energy
)
==
2
)
print
(
"
PROMISE: (%s, %s)
"
%
(
total_time_energy
[
0
],
total_time_energy
[
1
]))
return
float
(
total_time_energy
[
0
]),
float
(
total_time_energy
[
1
])
def
__run_gpu_simulation
(
self
,
curr_layer
,
layer_name
,
tensor_ind
,
\
approx_type
=
None
,
knob_number
=
None
):
tensor_info
=
self
.
__tensor_table
[
layer_name
][
tensor_ind
]
#print(tensor_info)
#print(layer_name)
#print(tensor_ind)
time_key
=
None
energy_key
=
None
print
(
self
.
__get_str
(
approx_type
))
if
approx_type
==
Driver
.
ApproxTypes
.
PERF
or
approx_type
==
Driver
.
ApproxTypes
.
SAMP
:
# fp16_perf2_energy
approx_type_str
=
None
if
approx_type
==
Driver
.
ApproxTypes
.
PERF
:
...
...
@@ -331,12 +330,10 @@ class Driver:
approx_type_str
=
"
samp
"
if
curr_layer
==
Driver
.
PrecisionTypes
.
FP32
:
print
(
"
in fp32
"
,
approx_type_str
)
time_key
=
"
fp32_%s%s_time
"
%
(
approx_type_str
,
knob_number
)
energy_key
=
"
fp32_%s%s_energy
"
%
(
approx_type_str
,
knob_number
)
elif
curr_layer
==
Driver
.
PrecisionTypes
.
FP16
:
print
(
"
in fp16
"
,
approx_type_str
)
time_key
=
"
fp16_%s%s_time
"
%
(
approx_type_str
,
knob_number
)
energy_key
=
"
fp16_%s%s_energy
"
%
(
approx_type_str
,
knob_number
)
...
...
@@ -351,8 +348,7 @@ class Driver:
print
(
time_key
,
energy_key
)
conversion_time
=
tensor_info
[
time_key
]
conversion_energy
=
tensor_info
[
energy_key
]
print
(
conversion_time
,
conversion_energy
)
print
(
"
GPU: (%f, %f)
"
%
(
conversion_time
,
conversion_energy
))
print
(
"
GPU: (%f, %f)
\n
"
%
(
conversion_time
,
conversion_energy
))
return
conversion_time
,
conversion_energy
...
...
@@ -387,9 +383,9 @@ class Driver:
baseline_conf
=
None
baseline_total_time
=
baseline_total_energy
=
0
def
get_baseline_times_enegies
():
def
get_baseline_times_ene
r
gies
(
conf
):
curr_time
=
curr_energy
=
0
for
layer
in
baseline_
conf
[
1
]:
for
layer
in
conf
[
1
]:
for
op_time
,
op_energy
,
tensor_op
in
layer
:
curr_time
+=
op_time
curr_energy
+=
op_energy
...
...
@@ -406,14 +402,15 @@ class Driver:
for
tensor_ind
,
(
op_time
,
op_energy
,
tensor_op
)
in
enumerate
(
layer
):
baseline_time
,
baseline_energy
,
baseline_op
=
baseline_conf
[
1
][
layer_ind
][
tensor_ind
]
final_tensor_op
=
tensor_op
''''
if op_time > baseline_time:
final_time += baseline_time
final_energy += baseline_energy
final_tensor_op = baseline_op
else:
final_time
+=
op_time
final_energy
+=
op_energy
'''
final_time
+=
op_time
final_energy
+=
op_energy
'''
# Ignoring bigger energies for now
if op_energy > baseline_energy:
...
...
@@ -429,23 +426,33 @@ class Driver:
return
final_time
,
final_energy
,
(
curr_conf
[
0
],
final_conf
)
conf_index
=
0
print
(
"
RESULTS
"
)
#print(self.__conf_results)
for
line
in
config_file
:
if
line
.
startswith
(
"
conf
"
):
orig_line_lst
=
line
.
split
(
'
'
)
conf_name
=
orig_line_lst
[
0
]
print
(
"
\n
"
)
if
not
baseline_conf
:
baseline_conf
=
self
.
__conf_results
[
conf_index
]
#conf_name]
print
(
"
FOUND baseline
"
,
baseline_conf
)
baseline_total_time
,
baseline_total_energy
=
get_baseline_times_enegies
()
print
(
"
BASELINE
"
)
#print(baseline_conf)
print
(
"
\n
"
)
baseline_total_time
,
baseline_total_energy
=
get_baseline_times_energies
(
baseline_conf
)
results_file
.
write
(
"
%s %s
\n
"
%
(
repr
(
baseline_total_time
),
repr
(
baseline_total_energy
)))
# write baseline time to top of file
write_conf_to_file
(
conf_name
,
baseline_conf
,
1
,
1
)
print
(
baseline_total_time
,
baseline_total_energy
)
else
:
curr_conf
=
self
.
__conf_results
[
conf_index
]
#conf_name]
final_time
,
final_energy
,
curr_conf
=
get_final_times_energies_conf
(
curr_conf
)
assert
(
final_time
<=
baseline_total_time
)
print
(
"
CURRENT
"
)
#print(curr_conf)
print
(
"
\n
"
)
final_time
,
final_energy
=
get_baseline_times_energies
(
curr_conf
)
#final_time, final_energy, curr_conf = get_final_times_energies_conf(curr_conf)
#assert(final_time <= baseline_total_time)
#assert(final_energy <= baseline_total_energy)
#write_conf_to_file(conf_name, curr_conf, final_time, final_energy)
print
(
baseline_total_time
,
final_time
,
baseline_total_energy
,
final_energy
)
write_conf_to_file
(
conf_name
,
curr_conf
,
baseline_total_time
/
final_time
,
baseline_total_energy
/
final_energy
)
conf_index
+=
1
results_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