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
e768c3b4
Commit
e768c3b4
authored
6 years ago
by
Hashim Sharif
Browse files
Options
Downloads
Patches
Plain Diff
Adding Half precision support in PROMISE layer API
parent
68905098
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/hpvm-tensor-rt/tensor_runtime/src/tensor_runtime.cu
+69
-9
69 additions, 9 deletions
...jects/hpvm-tensor-rt/tensor_runtime/src/tensor_runtime.cu
with
69 additions
and
9 deletions
llvm/projects/hpvm-tensor-rt/tensor_runtime/src/tensor_runtime.cu
+
69
−
9
View file @
e768c3b4
...
@@ -67,6 +67,12 @@ void llvm_hpvm_initTensorRt(int gpuid){
...
@@ -67,6 +67,12 @@ void llvm_hpvm_initTensorRt(int gpuid){
readOpenTunerFlags
(
"opentuner_flags"
);
readOpenTunerFlags
(
"opentuner_flags"
);
#endif
#endif
#ifdef PROMISE_TUNER_ENABLED
readOpenTunerFlags
(
"opentuner_flags"
);
#endif
//#ifdef PROMISE_MODE
//#ifdef PROMISE_MODE
// readQuantRanges("quant_ranges");
// readQuantRanges("quant_ranges");
//#endif
//#endif
...
@@ -671,8 +677,8 @@ void* tensorGemmGPU(void* lhs_ptr, void* rhs_ptr){
...
@@ -671,8 +677,8 @@ void* tensorGemmGPU(void* lhs_ptr, void* rhs_ptr){
Tensor
*
lhs
=
(
Tensor
*
)
lhs_ptr
;
Tensor
*
lhs
=
(
Tensor
*
)
lhs_ptr
;
Tensor
*
rhs
=
(
Tensor
*
)
rhs_ptr
;
Tensor
*
rhs
=
(
Tensor
*
)
rhs_ptr
;
printTensorDims2
(
lhs
);
//
printTensorDims2(lhs);
printTensorDims2
(
rhs
);
//
printTensorDims2(rhs);
INFO
(
"rhs->dims.num_dims = %d
\n
"
,
rhs
->
dims
.
num_dims
);
INFO
(
"rhs->dims.num_dims = %d
\n
"
,
rhs
->
dims
.
num_dims
);
INFO
(
"lhs->dims.num_dims = %d
\n
"
,
lhs
->
dims
.
num_dims
);
INFO
(
"lhs->dims.num_dims = %d
\n
"
,
lhs
->
dims
.
num_dims
);
...
@@ -726,7 +732,7 @@ void* tensorGemmGPU(void* lhs_ptr, void* rhs_ptr){
...
@@ -726,7 +732,7 @@ void* tensorGemmGPU(void* lhs_ptr, void* rhs_ptr){
#ifdef ERROR_INJECTION_ENABLED
#ifdef ERROR_INJECTION_ENABLED
if
(
op_counter
>=
total_ops
){
if
(
op_counter
>=
total_ops
){
ERROR
(
"No accuracy flag found
\n
"
);
ERROR
(
"No accuracy flag found
\n
"
);
...
@@ -1133,6 +1139,18 @@ void* ConvLayer_PROMISE(void* input, float i_min, float i_max,
...
@@ -1133,6 +1139,18 @@ void* ConvLayer_PROMISE(void* input, float i_min, float i_max,
float
out_min
,
float
out_max
,
int
swing
){
// NOTE: min_val, max_val apply to 'ClippedRelu'
float
out_min
,
float
out_max
,
int
swing
){
// NOTE: min_val, max_val apply to 'ClippedRelu'
#ifdef PROMISE_TUNER_ENABLED
if
(
op_counter
>=
total_ops
){
ERROR
(
"No accuracy flag found
\n
"
);
}
swing
=
op_accuracies
[
op_counter
];
op_counter
++
;
#endif
if
(
swing
<
0
||
swing
>
9
){
if
(
swing
<
0
||
swing
>
9
){
ERROR
(
"Incorrect swing value"
);
ERROR
(
"Incorrect swing value"
);
}
}
...
@@ -1144,14 +1162,30 @@ void* ConvLayer_PROMISE(void* input, float i_min, float i_max,
...
@@ -1144,14 +1162,30 @@ void* ConvLayer_PROMISE(void* input, float i_min, float i_max,
// aRead error
// aRead error
input
=
addPromiseError
(
input
,
swing
);
input
=
addPromiseError
(
input
,
swing
);
}
}
void
*
conv_out
=
tensorConvolution
(
input
,
filter
,
void
*
conv_out
;
if
(
swing
==
8
){
conv_out
=
tensorHalfConvolution
(
input
,
filter
,
conv_pad_h
,
conv_pad_w
,
conv_pad_h
,
conv_pad_w
,
conv_stride_h
,
conv_stride_w
,
conv_stride_h
,
conv_stride_w
,
1
,
0
);
1
,
0
);
}
else
{
conv_out
=
tensorConvolution
(
input
,
filter
,
conv_pad_h
,
conv_pad_w
,
conv_stride_h
,
conv_stride_w
,
1
,
0
);
}
void
*
conv_add
;
void
*
conv_add
;
if
(
bias
!=
NULL
){
if
(
bias
!=
NULL
){
conv_add
=
tensorAdd
(
conv_out
,
bias
);
if
(
swing
==
8
){
conv_add
=
tensorHalfAdd
(
conv_out
,
bias
);
}
else
{
conv_add
=
tensorAdd
(
conv_out
,
bias
);
}
}
}
else
{
else
{
conv_add
=
conv_out
;
conv_add
=
conv_out
;
...
@@ -1201,6 +1235,19 @@ void* FCLayer_PROMISE(void* input, float i_min, float i_max,
...
@@ -1201,6 +1235,19 @@ void* FCLayer_PROMISE(void* input, float i_min, float i_max,
int
activation_id
,
int
activation_id
,
float
out_min
,
float
out_max
,
int
swing
){
// NOTE: min_val, max_val apply to 'ClippedRelu'
float
out_min
,
float
out_max
,
int
swing
){
// NOTE: min_val, max_val apply to 'ClippedRelu'
#ifdef PROMISE_TUNER_ENABLED
if
(
op_counter
>=
total_ops
){
ERROR
(
"No accuracy flag found
\n
"
);
}
swing
=
op_accuracies
[
op_counter
];
op_counter
++
;
#endif
if
(
swing
<
0
||
swing
>
9
){
if
(
swing
<
0
||
swing
>
9
){
ERROR
(
"Incorrect swing value"
);
ERROR
(
"Incorrect swing value"
);
}
}
...
@@ -1213,13 +1260,26 @@ void* FCLayer_PROMISE(void* input, float i_min, float i_max,
...
@@ -1213,13 +1260,26 @@ void* FCLayer_PROMISE(void* input, float i_min, float i_max,
// NOTE: Modelling aRead error in PROMISE
// NOTE: Modelling aRead error in PROMISE
input
=
addPromiseError
(
input
,
swing
);
input
=
addPromiseError
(
input
,
swing
);
}
}
void
*
gemm_out
=
tensorGemmGPU
(
input
,
weights
);
void
*
gemm_out
;
if
(
swing
==
8
){
gemm_out
=
tensorHalfGemm
(
input
,
weights
);
}
else
{
gemm_out
=
tensorGemmGPU
(
input
,
weights
);
}
void
*
gemmbias_out
;
void
*
gemmbias_out
;
if
(
bias
!=
NULL
){
if
(
bias
!=
NULL
){
gemmbias_out
=
tensorAdd
(
gemm_out
,
bias
);
// Swing 8 corresponds to FP32
if
(
swing
==
8
){
gemmbias_out
=
tensorHalfAdd
(
gemm_out
,
bias
);
}
else
{
gemmbias_out
=
tensorAdd
(
gemm_out
,
bias
);
}
}
}
else
{
else
{
gemmbias_out
=
gemm_out
;
gemmbias_out
=
gemm_out
;
...
...
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