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
6449390a
Commit
6449390a
authored
5 years ago
by
Hashim Sharif
Browse files
Options
Downloads
Patches
Plain Diff
Adding tested AlexNet piped version
parent
19924fac
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
llvm/projects/hpvm-tensor-rt/dnn_sources/include/utils.h
+55
-1
55 additions, 1 deletion
llvm/projects/hpvm-tensor-rt/dnn_sources/include/utils.h
llvm/projects/hpvm-tensor-rt/dnn_sources/src/promise/alexnet_piped.cc
+166
-0
166 additions, 0 deletions
...s/hpvm-tensor-rt/dnn_sources/src/promise/alexnet_piped.cc
with
221 additions
and
1 deletion
llvm/projects/hpvm-tensor-rt/dnn_sources/include/utils.h
+
55
−
1
View file @
6449390a
...
...
@@ -3,7 +3,10 @@
#ifndef UTILS_HEADER
#define UTILS_HEADER
#include
<stdio.h>
#include
<stdlib.h>
#include
<unistd.h>
#include
<fcntl.h>
#include
<sstream>
#include
<vector>
#include
<bits/stdc++.h>
...
...
@@ -931,4 +934,55 @@ void dumpClassConfsAndLabels(float* classConfs,
}
/**** Routines for Handling Piped Execution ***/
void
stallOnOpenTunerSignal
(){
const
char
*
myfifo
=
"/tmp/opentuner_fifo"
;
int
fd
=
open
(
myfifo
,
O_RDONLY
);
if
(
fd
==
-
1
){
printf
(
"OpenTuner pipe could not be opened
\n
"
);
abort
();
}
int
ret_val
=
fcntl
(
fd
,
F_GETFD
);
if
(
ret_val
==
-
1
){
printf
(
"Invalid descriptor
\n
"
);
abort
();
}
char
str
[
100
];
read
(
fd
,
str
,
100
);
readOpenTunerFlags
(
"promise_flags"
);
if
(
strcmp
(
str
,
"stop_run"
)
==
0
){
abort
();
}
close
(
fd
);
}
void
signalPipeToOpenTuner
(){
const
char
*
myfifo
=
"/tmp/opentuner_fifo"
;
int
fd_out
=
open
(
myfifo
,
O_WRONLY
);
int
ret_val
=
fcntl
(
fd_out
,
F_GETFD
);
if
(
ret_val
==
-
1
){
printf
(
"Invalid descriptor
\n
"
);
abort
();
}
const
char
*
str
=
"completed***!
\n\0
"
;
write
(
fd_out
,
str
,
80
);
close
(
fd_out
);
}
#endif
This diff is collapsed.
Click to expand it.
llvm/projects/hpvm-tensor-rt/dnn_sources/src/promise/alexnet_piped.cc
0 → 100644
+
166
−
0
View file @
6449390a
#include
<stdio.h>
#include
<stdlib.h>
#include
<unistd.h>
#include
<fcntl.h>
#include
<sys/types.h>
#include
<sys/stat.h>
#include
<string.h>
#include
"tensor_runtime.h"
#include
"utils.h"
int
total_runs
=
1
;
float
bench_acc
=
0
;
int
to_skip
=
5
;
int
main
(
int
argc
,
char
*
argv
[]){
int
test_input_size
=
3000
;
int
batch_size
=
1000
;
int
offset
=
5000
;
if
(
argc
>
1
){
total_runs
=
atoi
(
argv
[
1
]);
}
if
(
argc
>
2
){
bench_acc
=
atof
(
argv
[
2
]);
}
if
(
argc
>
3
){
to_skip
=
atoi
(
argv
[
3
]);
}
if
(
argc
>
4
){
test_input_size
=
atoi
(
argv
[
4
]);
}
if
(
argc
>
5
){
offset
=
atoi
(
argv
[
5
]);
}
if
(
argc
>
6
){
batch_size
=
atoi
(
argv
[
6
]);
}
bool
shouldDumpClassConf
=
false
;
float
*
classConfs
;
int
*
predictedLabels
;
if
(
argc
>
7
){
shouldDumpClassConf
=
true
;
classConfs
=
(
float
*
)
malloc
(
sizeof
(
float
)
*
test_input_size
);
predictedLabels
=
(
int
*
)
malloc
(
sizeof
(
int
)
*
test_input_size
);
}
llvm_hpvm_initTensorRt
(
0
);
std
::
string
dir_prefix
=
std
::
string
(
"../model_params/alexnet_cifar10_test/"
);
std
::
string
input_path
=
dir_prefix
+
std
::
string
(
"input.bin"
);
std
::
string
labels_path
=
dir_prefix
+
std
::
string
(
"labels.bin"
);
std
::
string
labels32_path
=
dir_prefix
+
std
::
string
(
"labels32.bin"
);
std
::
string
conv2d_1_w_path
=
dir_prefix
+
std
::
string
(
"conv2d_1_w.bin"
);
void
*
conv2d_1_w
=
readTrainedWeights
(
conv2d_1_w_path
.
c_str
(),
0
,
64
,
3
,
11
,
11
);
std
::
string
conv2d_1_b_path
=
dir_prefix
+
std
::
string
(
"conv2d_1_b.bin"
);
void
*
conv2d_1_b
=
readTrainedWeights
(
conv2d_1_b_path
.
c_str
(),
0
,
1
,
64
,
1
,
1
);
std
::
string
conv2d_2_w_path
=
dir_prefix
+
std
::
string
(
"conv2d_2_w.bin"
);
void
*
conv2d_2_w
=
readTrainedWeights
(
conv2d_2_w_path
.
c_str
(),
0
,
192
,
64
,
5
,
5
);
std
::
string
conv2d_2_b_path
=
dir_prefix
+
std
::
string
(
"conv2d_2_b.bin"
);
void
*
conv2d_2_b
=
readTrainedWeights
(
conv2d_2_b_path
.
c_str
(),
0
,
1
,
192
,
1
,
1
);
std
::
string
conv2d_3_w_path
=
dir_prefix
+
std
::
string
(
"conv2d_3_w.bin"
);
void
*
conv2d_3_w
=
readTrainedWeights
(
conv2d_3_w_path
.
c_str
(),
0
,
384
,
192
,
3
,
3
);
std
::
string
conv2d_3_b_path
=
dir_prefix
+
std
::
string
(
"conv2d_3_b.bin"
);
void
*
conv2d_3_b
=
readTrainedWeights
(
conv2d_3_b_path
.
c_str
(),
0
,
1
,
384
,
1
,
1
);
std
::
string
conv2d_4_w_path
=
dir_prefix
+
std
::
string
(
"conv2d_4_w.bin"
);
void
*
conv2d_4_w
=
readTrainedWeights
(
conv2d_4_w_path
.
c_str
(),
0
,
256
,
384
,
3
,
3
);
std
::
string
conv2d_4_b_path
=
dir_prefix
+
std
::
string
(
"conv2d_4_b.bin"
);
void
*
conv2d_4_b
=
readTrainedWeights
(
conv2d_4_b_path
.
c_str
(),
0
,
1
,
256
,
1
,
1
);
std
::
string
conv2d_5_w_path
=
dir_prefix
+
std
::
string
(
"conv2d_5_w.bin"
);
void
*
conv2d_5_w
=
readTrainedWeights
(
conv2d_5_w_path
.
c_str
(),
0
,
256
,
256
,
3
,
3
);
std
::
string
conv2d_5_b_path
=
dir_prefix
+
std
::
string
(
"conv2d_5_b.bin"
);
void
*
conv2d_5_b
=
readTrainedWeights
(
conv2d_5_b_path
.
c_str
(),
0
,
1
,
256
,
1
,
1
);
std
::
string
dense_1_w_path
=
dir_prefix
+
std
::
string
(
"dense_1_w.bin"
);
void
*
dense_1_w
=
readTrainedWeights
(
dense_1_w_path
.
c_str
(),
0
,
1
,
1
,
4096
,
10
);
std
::
string
dense_1_b_path
=
dir_prefix
+
std
::
string
(
"dense_1_b.bin"
);
void
*
dense_1_b
=
readTrainedWeights
(
dense_1_b_path
.
c_str
(),
0
,
1
,
10
,
1
,
1
);
int
missed
=
0
;
for
(
int
i
=
0
;
i
<
total_runs
;
i
++
){
// NOTE: Wait on signal from OpenTuner
stallOnOpenTunerSignal
();
if
(
missed
>=
to_skip
){
break
;
}
startMemTracking
();
int
batch_count
=
test_input_size
/
batch_size
;
float
final_accuracy
=
0.0
;
for
(
int
i
=
0
;
i
<
batch_count
;
i
++
){
int
start
=
i
*
batch_size
+
offset
;
int
end
=
(
i
+
1
)
*
batch_size
+
offset
;
void
*
input
=
readInputBatch
(
input_path
.
c_str
(),
0
,
start
,
end
,
3
,
32
,
32
);
void
*
var_0
=
ConvLayer_PROMISE
(
input
,
-
1.8816426241908337
,
2.0934095498544254
,
conv2d_1_w
,
-
0.33087718
,
0.3323643
,
conv2d_1_b
,
-
0.7782218
,
0.6020472
,
5
,
5
,
1
,
1
,
0
,
2
,
0
,
-
0.978641152381897
,
0.9989452958106995
,
9
);
void
*
var_1
=
ConvLayer_PROMISE
(
var_0
,
-
0.978641152381897
,
0.9989452958106995
,
conv2d_2_w
,
-
0.2095158
,
0.33543423
,
conv2d_2_b
,
-
0.45020863
,
0.30596754
,
2
,
2
,
1
,
1
,
0
,
2
,
0
,
-
0.9997039437294006
,
0.999930202960968
,
9
);
void
*
var_2
=
ConvLayer_PROMISE
(
var_1
,
-
0.9997039437294006
,
0.999930202960968
,
conv2d_3_w
,
-
0.1715614
,
0.17037082
,
conv2d_3_b
,
-
0.6519161
,
0.5939945
,
1
,
1
,
1
,
1
,
-
1
,
0
,
0
,
-
0.9999336004257202
,
0.999940037727356
,
9
);
void
*
var_3
=
ConvLayer_PROMISE
(
var_2
,
-
0.9999336004257202
,
0.999940037727356
,
conv2d_4_w
,
-
0.15575546
,
0.14456555
,
conv2d_4_b
,
-
0.55873865
,
0.4704539
,
1
,
1
,
1
,
1
,
-
1
,
0
,
0
,
-
0.9999991059303284
,
0.9999993443489075
,
9
);
void
*
var_4
=
ConvLayer_PROMISE
(
var_3
,
-
0.9999991059303284
,
0.9999993443489075
,
conv2d_5_w
,
-
0.16108225
,
0.16864482
,
conv2d_5_b
,
-
0.22135437
,
0.10401678
,
1
,
1
,
1
,
1
,
0
,
2
,
0
,
-
0.9994344115257263
,
0.9996342062950134
,
9
);
void
*
var_5
=
FCLayer_PROMISE
(
var_4
,
-
0.9994344115257263
,
0.9996342062950134
,
dense_1_w
,
-
0.18183032
,
0.19018902
,
dense_1_b
,
-
0.07189204
,
0.106005594
,
-
1
,
-
15.076565380096437
,
19.422585220336913
,
9
);
void
*
var_6
=
tensorSoftmax
(
var_5
);
uint8_t
*
labels
=
readLabelsBatch
(
labels_path
.
c_str
(),
start
,
end
);
float
accuracy
=
computeAccuracy2
(
labels
,
batch_size
,
var_6
);
final_accuracy
+=
accuracy
;
if
(
shouldDumpClassConf
){
int
relative_start
=
start
-
offset
;
int
relative_end
=
end
-
offset
;
copyClassConfsAndLabels
(
var_6
,
classConfs
,
predictedLabels
,
relative_start
,
relative_end
);
}
freeBatchMemory
();
}
final_accuracy
=
final_accuracy
/
batch_count
;
dumpFinalAccuracy
(
final_accuracy
);
if
(
final_accuracy
<
bench_acc
)
missed
+=
1
;
if
(
shouldDumpClassConf
){
int
labels_start
=
offset
;
int
labels_end
=
offset
+
test_input_size
;
uint32_t
*
goldLabels
=
readLabelsBatch3
(
labels32_path
.
c_str
(),
labels_start
,
labels_end
);
dumpClassConfsAndLabels
(
classConfs
,
predictedLabels
,
goldLabels
,
test_input_size
);
}
// NOTE: Signal back to OpenTuner
signalPipeToOpenTuner
();
}
dumpExecutionAccuracies
();
llvm_hpvm_cleanupTensorRt
();
return
0
;
}
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