From 0fafe22222d6d7699d9ec55ef326e8cc70030cb0 Mon Sep 17 00:00:00 2001
From: Hashim Sharif <hsharif3@tyler.cs.illinois.edu>
Date: Mon, 6 Apr 2020 17:15:04 -0500
Subject: [PATCH] Adding unit tests for sampling and baseline for 1*1 filter

---
 .../dnn_sources/src/test_ops.cc               | 63 ++++++++++++++++++-
 1 file changed, 61 insertions(+), 2 deletions(-)

diff --git a/llvm/projects/hpvm-tensor-rt/dnn_sources/src/test_ops.cc b/llvm/projects/hpvm-tensor-rt/dnn_sources/src/test_ops.cc
index 56ceb6a5af..a58f4b1d47 100644
--- a/llvm/projects/hpvm-tensor-rt/dnn_sources/src/test_ops.cc
+++ b/llvm/projects/hpvm-tensor-rt/dnn_sources/src/test_ops.cc
@@ -659,16 +659,72 @@ void testSampling2(){
   
   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, 2, 1);
+  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* res4 = tensorConvApprox(input, filter, 0, 0, 1, 1, 1, 1, 1, 1, 3, 1);
+  
+  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");
+
+  
 }
 
 
@@ -708,7 +764,7 @@ int main(){
   //testSampleFilter();
   
 
-  //testPerforation();
+  testPerforation();
 
 
   // testPerforation2();
@@ -719,6 +775,9 @@ int main(){
 
   testSampling2();
 
+
+  testSampling3();
+
   
   
   stopProfiling();
-- 
GitLab