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
209bf7a4
"git@gitlab.engr.illinois.edu:llvm/hpvm-release.git" did not exist on "832f43610797512d8f2b40e060b6a4215b6dc89c"
Commit
209bf7a4
authored
6 years ago
by
Hashim Sharif
Browse files
Options
Downloads
Patches
Plain Diff
Adding Promise sources for Alexnet2-CIFAR10
parent
460d6568
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/dnn_sources/src/promise/alexnet2_cifar10_promise.cc
+163
-0
163 additions, 0 deletions
...or-rt/dnn_sources/src/promise/alexnet2_cifar10_promise.cc
with
163 additions
and
0 deletions
llvm/projects/hpvm-tensor-rt/dnn_sources/src/promise/alexnet2_cifar10_promise.cc
0 → 100644
+
163
−
0
View file @
209bf7a4
#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/include/tensor_runtime.h"
#include
"../../include/utils.h"
bool
Opentuner_run
=
false
;
/* NOTE: Reference Architecture to use for profiling */
void
testLenetTanh
(){
int
total_runs
=
1
;
if
(
Opentuner_run
){
total_runs
=
100000
;
}
printf
(
"********* Lenet-2 Architecture **********
\n
"
);
int
test_batch_size
=
5000
;
uint8_t
*
labels
=
readLabels
(
"../model_params/alexnet2_cifar10/test_labels.bin"
,
test_batch_size
);
for
(
int
i
=
0
;
i
<
total_runs
;
i
++
){
void
*
input
=
readTrainedWeights
(
"../model_params/alexnet2_cifar10/norm_cifar_input.bin"
,
float_type
,
test_batch_size
,
3
,
32
,
32
);
void
*
conv1_filter
=
readTrainedWeights
(
"../model_params/alexnet2_cifar10/conv1.bin"
,
float_type
,
32
,
3
,
3
,
3
);
void
*
conv1_bias
=
readTrainedWeights
(
"../model_params/alexnet2_cifar10/conv1_bias.bin"
,
float_type
,
1
,
32
,
1
,
1
);
void
*
conv2_filter
=
readTrainedWeights
(
"../model_params/alexnet2_cifar10/conv2.bin"
,
float_type
,
32
,
32
,
3
,
3
);
void
*
conv2_bias
=
readTrainedWeights
(
"../model_params/alexnet2_cifar10/conv2_bias.bin"
,
float_type
,
1
,
32
,
1
,
1
);
void
*
conv3_filter
=
readTrainedWeights
(
"../model_params/alexnet2_cifar10/conv3.bin"
,
float_type
,
64
,
32
,
3
,
3
);
void
*
conv3_bias
=
readTrainedWeights
(
"../model_params/alexnet2_cifar10/conv3_bias.bin"
,
float_type
,
1
,
64
,
1
,
1
);
void
*
conv4_filter
=
readTrainedWeights
(
"../model_params/alexnet2_cifar10/conv4.bin"
,
float_type
,
64
,
64
,
3
,
3
);
void
*
conv4_bias
=
readTrainedWeights
(
"../model_params/alexnet2_cifar10/conv4_bias.bin"
,
float_type
,
1
,
64
,
1
,
1
);
void
*
conv5_filter
=
readTrainedWeights
(
"../model_params/alexnet2_cifar10/conv5.bin"
,
float_type
,
128
,
64
,
3
,
3
);
void
*
conv5_bias
=
readTrainedWeights
(
"../model_params/alexnet2_cifar10/conv5_bias.bin"
,
float_type
,
1
,
128
,
1
,
1
);
void
*
conv6_filter
=
readTrainedWeights
(
"../model_params/alexnet2_cifar10/conv6.bin"
,
float_type
,
128
,
128
,
3
,
3
);
void
*
conv6_bias
=
readTrainedWeights
(
"../model_params/alexnet2_cifar10/conv6_bias.bin"
,
float_type
,
1
,
128
,
1
,
1
);
void
*
fc1_weights
=
readTrainedWeights
(
"../model_params/alexnet2_cifar10/fc1.bin"
,
float_type
,
1
,
1
,
2048
,
10
);
void
*
fc1_bias
=
readTrainedWeights
(
"../model_params/alexnet2_cifar10/fc1_bias.bin"
,
float_type
,
1
,
10
,
1
,
1
);
clearTensorMap
();
if
(
Opentuner_run
){
char
*
myfifo
=
"/tmp/myfifo"
;
int
fd
=
open
(
myfifo
,
O_RDONLY
);
int
ret_val
=
fcntl
(
fd
,
F_GETFD
);
if
(
ret_val
==
-
1
){
printf
(
"Invalid descriptor
\n
"
);
abort
();
}
char
str
[
100
];
read
(
fd
,
str
,
80
);
if
(
strcmp
(
str
,
"stop_run"
)
==
0
){
abort
();
}
close
(
fd
);
}
readOpenTunerFlags
(
"opentuner_flags"
);
// Resets the OpenTuner counters
// Start power and performance profiling
startProfiling
();
//-1.881, 2.09
//-0.18,0.174
void
*
conv1_out
=
ConvLayer_PROMISE
(
input
,
-
1.881
,
2.09
,
conv1_filter
,
-
0.542
,
0.371
,
conv1_bias
,
-
0.066
,
0.04
,
1
,
1
,
1
,
1
,
0
,
0
,
0
,
-
1
,
1
,
9
);
void
*
conv2_out
=
ConvLayer_PROMISE
(
conv1_out
,
-
1
,
1
,
conv2_filter
,
-
0.424
,
0.314
,
conv2_bias
,
-
0.355
,
-
0.172
,
1
,
1
,
1
,
1
,
0
,
2
,
0
,
-
1
,
1
,
9
);
void
*
conv3_out
=
ConvLayer_PROMISE
(
conv2_out
,
-
1
,
1
,
conv3_filter
,
-
0.441
,
0.795
,
conv3_bias
,
-
0.804
,
0.753
,
1
,
1
,
1
,
1
,
0
,
0
,
0
,
-
1
,
1
,
9
);
void
*
conv4_out
=
ConvLayer_PROMISE
(
conv3_out
,
-
1
,
1
,
conv4_filter
,
-
0.288
,
0.31
,
conv4_bias
,
-
0.635
,
0.29
,
1
,
1
,
1
,
1
,
0
,
2
,
0
,
-
1
,
1
,
9
);
void
*
conv5_out
=
ConvLayer_PROMISE
(
conv4_out
,
-
1
,
1
,
conv5_filter
,
-
0.279
,
0.376
,
conv5_bias
,
-
1.13
,
1.239
,
1
,
1
,
1
,
1
,
0
,
0
,
0
,
-
1
,
1
,
9
);
void
*
conv6_out
=
ConvLayer_PROMISE
(
conv5_out
,
-
1
,
1
,
conv6_filter
,
-
0.27
,
0.279
,
conv6_bias
,
-
0.503
,
0.127
,
1
,
1
,
1
,
1
,
0
,
2
,
0
,
-
1
,
1
,
9
);
// No Activation
void
*
fc1_out
=
FCLayer_PROMISE
(
conv6_out
,
-
1
,
1
,
fc1_weights
,
-
0.242
,
0.584
,
fc1_bias
,
-
0.537
,
0.558
,
-
1
,
-
1
,
1
,
9
);
void
*
result
=
tensorSoftmax
(
fc1_out
);
// End profiling and dump output to profile.txt
stopProfiling
();
computeAccuracy2
(
labels
,
test_batch_size
,
result
);
dumpAccuracyNorms
();
freeOutputTensors
();
if
(
Opentuner_run
){
char
*
myfifo
=
"/tmp/myfifo"
;
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
);
}
}
}
int
main
(
int
argc
,
char
*
argv
[]){
if
(
argc
>
1
)
Opentuner_run
=
true
;
llvm_hpvm_initTensorRt
(
1
);
testLenetTanh
();
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