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
8da90445
Commit
8da90445
authored
4 years ago
by
Hashim Sharif
Browse files
Options
Downloads
Patches
Plain Diff
Adding unit test calls for sampling tests
parent
a331f82f
No related branches found
Branches containing commit
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/unit_tests.cc
+43
-127
43 additions, 127 deletions
llvm/projects/hpvm-tensor-rt/dnn_sources/src/unit_tests.cc
with
43 additions
and
127 deletions
llvm/projects/hpvm-tensor-rt/dnn_sources/src/unit_tests.cc
+
43
−
127
View file @
8da90445
...
@@ -806,7 +806,7 @@ void testPerforationCalls(void* input, void* filter,
...
@@ -806,7 +806,7 @@ void testPerforationCalls(void* input, void* filter,
/**** Tests Perforation for a set of different inputs */
/**** Tests Perforation for a set of different inputs */
void
testPerforation
(){
void
testPerforation
(
UnitTestResults
&
unitTestResults
){
printf
(
"***** Tests Sample for a sample 3 * 3 Filter *****
\n\n
"
);
printf
(
"***** Tests Sample for a sample 3 * 3 Filter *****
\n\n
"
);
...
@@ -926,7 +926,7 @@ void testSampling(){
...
@@ -926,7 +926,7 @@ void testSampling(){
void
testSamplingCalls
(
void
*
input
,
void
*
filter
,
void
testSamplingCalls
(
void
*
input
,
void
*
filter
,
int
pad_h
,
int
pad_w
,
int
pad_h
,
int
pad_w
,
int
stride_h
,
int
stride_w
,
int
stride_h
,
int
stride_w
,
int
skip_every
){
int
skip_every
,
UnitTestResults
&
unitTestResults
){
float
interpolation_rate
=
1.0
;
float
interpolation_rate
=
1.0
;
...
@@ -988,6 +988,19 @@ void testSamplingCalls(void* input, void* filter,
...
@@ -988,6 +988,19 @@ void testSamplingCalls(void* input, void* filter,
printf
(
"
\n
ConvApproxHalf2 Result :"
);
printf
(
"
\n
ConvApproxHalf2 Result :"
);
printTensorValues
(
res_half
);
printTensorValues
(
res_half
);
std
::
string
suffix
=
std
::
string
(
" pad_h = "
)
+
std
::
to_string
(
pad_h
)
+
std
::
string
(
" pad_w = "
)
+
std
::
to_string
(
pad_w
)
+
std
::
string
(
" stride_h = "
)
+
std
::
to_string
(
stride_h
)
+
std
::
string
(
" stride_w = "
)
+
std
::
to_string
(
stride_w
)
+
std
::
string
(
" skip_every = "
)
+
std
::
to_string
(
skip_every
)
+
std
::
string
(
" offset = "
)
+
std
::
to_string
(
offset
);
std
::
string
test_name
=
std
::
string
(
"SAMP_FP32 "
)
+
suffix
;
unitTestResults
.
compareTensors
((
Tensor
*
)
res
,
(
Tensor
*
)
res_sim
,
0.01
,
test_name
);
std
::
string
fp16_test_name
=
std
::
string
(
"SAMP_FP16 "
)
+
suffix
;
unitTestResults
.
compareTensors
((
Tensor
*
)
res_half
,
(
Tensor
*
)
res_sim
,
0.0001
,
fp16_test_name
);
}
}
...
@@ -997,7 +1010,7 @@ void testSamplingCalls(void* input, void* filter,
...
@@ -997,7 +1010,7 @@ void testSamplingCalls(void* input, void* filter,
/**** Tests Sample for a sample 3 * 3 Filter */
/**** Tests Sample for a sample 3 * 3 Filter */
void
testSampling_3_3
(){
void
testSampling_3_3
(
UnitTestResults
&
unitTestResults
){
printf
(
"***** Tests Sample for a sample 3 * 3 Filter *****
\n\n
"
);
printf
(
"***** Tests Sample for a sample 3 * 3 Filter *****
\n\n
"
);
...
@@ -1026,28 +1039,26 @@ void testSampling_3_3(){
...
@@ -1026,28 +1039,26 @@ void testSampling_3_3(){
host_ptr
[
26
]
=
2
;
host_ptr
[
26
]
=
2
;
// Tests with padding = 0 stride = 1
testSamplingCalls
(
input
,
filter
,
0
,
0
,
1
,
1
,
2
,
unitTestResults
);
testSamplingCalls
(
input
,
filter
,
0
,
0
,
1
,
1
,
2
);
testSamplingCalls
(
input
,
filter
,
0
,
0
,
1
,
1
,
3
,
unitTestResults
);
testSamplingCalls
(
input
,
filter
,
0
,
0
,
1
,
1
,
3
);
testSamplingCalls
(
input
,
filter
,
0
,
0
,
1
,
1
,
4
);
testSamplingCalls
(
input
,
filter
,
0
,
0
,
1
,
1
,
4
,
unitTestResults
);
testSamplingCalls
(
input
,
filter
,
1
,
1
,
1
,
1
,
2
);
// Tests with padding = 1 stride = 1
testSamplingCalls
(
input
,
filter
,
1
,
1
,
1
,
1
,
2
,
unitTestResults
);
testSamplingCalls
(
input
,
filter
,
1
,
1
,
1
,
1
,
3
);
testSamplingCalls
(
input
,
filter
,
1
,
1
,
1
,
1
,
3
,
unitTestResults
);
testSamplingCalls
(
input
,
filter
,
1
,
1
,
1
,
1
,
4
);
testSamplingCalls
(
input
,
filter
,
1
,
1
,
1
,
1
,
4
,
unitTestResults
);
// Tests with padding = 1 stride = 2
testSamplingCalls
(
input
,
filter
,
1
,
1
,
2
,
2
,
2
,
unitTestResults
);
testSamplingCalls
(
input
,
filter
,
1
,
1
,
2
,
2
,
3
,
unitTestResults
);
testSamplingCalls
(
input
,
filter
,
1
,
1
,
2
,
2
,
2
);
testSamplingCalls
(
input
,
filter
,
1
,
1
,
2
,
2
,
4
,
unitTestResults
);
testSamplingCalls
(
input
,
filter
,
1
,
1
,
2
,
2
,
3
);
testSamplingCalls
(
input
,
filter
,
1
,
1
,
2
,
2
,
4
);
}
}
...
@@ -1058,105 +1069,8 @@ void testSampling_3_3(){
...
@@ -1058,105 +1069,8 @@ void testSampling_3_3(){
void
testSampling2
(){
printf
(
"***** TestingSampling2 *****
\n\n
"
);
Tensor
*
input
=
(
Tensor
*
)
create4DTensor
(
CUDNN_DATA_FLOAT
,
CUDNN_TENSOR_NCHW
,
1
,
4
,
2
,
2
);
fillTensorWithVal
(
input
,
2
);
//fillWithOnesAndTwos(input);
Tensor
*
filter
=
(
Tensor
*
)
create4DTensor
(
CUDNN_DATA_FLOAT
,
CUDNN_TENSOR_NCHW
,
4
,
4
,
1
,
1
);
fillTensorWithVal
(
filter
,
2
);
// Interpolation not being applied most likely
void
*
res
=
tensorConvApprox
(
input
,
filter
,
0
,
0
,
1
,
1
,
1
,
1
,
1
,
1
,
2
,
0
);
printTensorValues
(
res
);
fillTensorWithVal
(
filter
,
2
);
// Start from offset 1 completely failing
void
*
res2
=
tensorConvApprox
(
input
,
filter
,
0
,
0
,
1
,
1
,
1
,
1
,
1
,
1
,
2
,
0
);
printTensorValues
(
res2
);
fillTensorWithVal
(
filter
,
2
);
// NOTE -- even after reinitializing --- error remains - this is indicative of input corruption
// Results are strange. Are filters being overwritten?
void
*
res3
=
tensorConvApprox
(
input
,
filter
,
0
,
0
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
);
printTensorValues
(
res3
);
}
void
testSampling3
(){
printf
(
"***** TestingSampling3 *****
\n\n
"
);
Tensor
*
input
=
(
Tensor
*
)
create4DTensor
(
CUDNN_DATA_FLOAT
,
CUDNN_TENSOR_NCHW
,
1
,
9
,
2
,
2
);
fillTensorWithVal
(
input
,
2
);
//fillWithOnesAndTwos(input);
Tensor
*
filter
=
(
Tensor
*
)
create4DTensor
(
CUDNN_DATA_FLOAT
,
CUDNN_TENSOR_NCHW
,
4
,
9
,
1
,
1
);
fillTensorWithVal
(
filter
,
2
);
// BASELINE : expected result -- 36, 36, 36, ...
void
*
res1
=
tensorConvApprox
(
input
,
filter
,
0
,
0
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
);
printTensorValues
(
res1
);
printf
(
"
\n
"
);
// BASELINE: expected result - 32, 32, 32,
void
*
res2
=
tensorConvApprox
(
input
,
filter
,
0
,
0
,
1
,
1
,
1
,
1
,
1
,
1
,
2
,
0
);
printTensorValues
(
res2
);
printf
(
"
\n
"
);
void
*
res3
=
tensorConvApprox
(
input
,
filter
,
0
,
0
,
1
,
1
,
1
,
1
,
1
,
1
,
3
,
0
);
printTensorValues
(
res3
);
printf
(
"
\n
"
);
void
*
res2_sim
=
tensorConvSampSim
(
input
,
filter
,
0
,
0
,
1
,
1
,
1
,
1
,
3
,
0
);
printTensorValues
(
res2_sim
);
printf
(
"
\n
"
);
void
*
res4
=
tensorConvApprox
(
input
,
filter
,
0
,
0
,
1
,
1
,
1
,
1
,
1
,
1
,
3
,
0
);
printTensorValues
(
res4
);
printf
(
"
\n
"
);
void
*
res5
=
tensorConvApprox
(
input
,
filter
,
0
,
0
,
1
,
1
,
1
,
1
,
1
,
1
,
4
,
0
);
printTensorValues
(
res5
);
printf
(
"
\n
"
);
void
*
res6
=
tensorConvApprox
(
input
,
filter
,
0
,
0
,
1
,
1
,
1
,
1
,
1
,
1
,
4
,
1
);
printTensorValues
(
res6
);
printf
(
"
\n
"
);
}
/**** Tests Sample for a sample 1 * 1 Filter */
/**** Tests Sample for a sample 1 * 1 Filter */
void
testSampling_1_1
(){
void
testSampling_1_1
(
UnitTestResults
&
unitTestResults
){
Tensor
*
input
=
(
Tensor
*
)
create4DTensor
(
CUDNN_DATA_FLOAT
,
CUDNN_TENSOR_NCHW
,
1
,
9
,
2
,
2
);
Tensor
*
input
=
(
Tensor
*
)
create4DTensor
(
CUDNN_DATA_FLOAT
,
CUDNN_TENSOR_NCHW
,
1
,
9
,
2
,
2
);
...
@@ -1167,19 +1081,20 @@ void testSampling_1_1(){
...
@@ -1167,19 +1081,20 @@ void testSampling_1_1(){
fillTensorWithVal
(
filter
,
2
);
fillTensorWithVal
(
filter
,
2
);
testSamplingCalls
(
input
,
filter
,
0
,
0
,
1
,
1
,
2
);
// Tests with padding = 0 stride = 1
testSamplingCalls
(
input
,
filter
,
0
,
0
,
1
,
1
,
2
,
unitTestResults
);
testSamplingCalls
(
input
,
filter
,
0
,
0
,
1
,
1
,
3
);
testSamplingCalls
(
input
,
filter
,
0
,
0
,
1
,
1
,
3
,
unitTestResults
);
testSamplingCalls
(
input
,
filter
,
0
,
0
,
1
,
1
,
4
);
testSamplingCalls
(
input
,
filter
,
0
,
0
,
1
,
1
,
4
,
unitTestResults
);
// Tests with padding = 1 stride = 1
testSamplingCalls
(
input
,
filter
,
1
,
1
,
1
,
1
,
2
,
unitTestResults
);
testSamplingCalls
(
input
,
filter
,
1
,
1
,
1
,
1
,
2
);
testSamplingCalls
(
input
,
filter
,
1
,
1
,
1
,
1
,
3
,
unitTestResults
);
testSamplingCalls
(
input
,
filter
,
1
,
1
,
1
,
1
,
3
);
testSamplingCalls
(
input
,
filter
,
1
,
1
,
1
,
1
,
4
,
unitTestResults
);
testSamplingCalls
(
input
,
filter
,
1
,
1
,
1
,
1
,
4
);
}
}
...
@@ -1314,13 +1229,14 @@ int main(){
...
@@ -1314,13 +1229,14 @@ int main(){
testTensorPooling();
testTensorPooling();
testTensorHalfPooling();
testTensorHalfPooling();
testSampling_3_3();
testSampling_1_1();
testPerforation();
*/
*/
testSampling_3_3
(
unitTestResults
);
testSampling_1_1
(
unitTestResults
);
testPerforation
(
unitTestResults
);
unitTestResults
.
printSummary
();
unitTestResults
.
printSummary
();
...
...
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