From abd63b0e06320ba17795b90f2519614c8e6c251e Mon Sep 17 00:00:00 2001 From: Hashim Sharif <hsharif3@tyler.cs.illinois.edu> Date: Tue, 7 Apr 2020 01:10:01 -0500 Subject: [PATCH] Pushing latest unit test source - with tests for baseline FP32 FP16 --- .../dnn_sources/src/test_ops.cc | 65 ++++++++++++++----- 1 file changed, 47 insertions(+), 18 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 14a8f2924c..29733fd58b 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 @@ -689,12 +689,38 @@ void testSamplingCalls(void* input, void* filter, printf("\n\n\n\**Test -- pad_h = %d pad_w = %d stride_h = %d stride_w = %d skip_every = %d offset= %d \n\n", pad_h, pad_w, stride_h, stride_w, skip_every, offset); + + + void* res_exact = tensorConvolution(input, filter, pad_h, pad_w, + stride_h, stride_w, + 1, 1); + + printf ("tensorConvolution Result :"); + printTensorValues(res_exact); + + + void* res_exact2 = tensorConvApprox(input, filter, pad_h, pad_w, + stride_h, stride_w, + 1, 1, 1, 1, 1, 1); + + printf ("\nBaseline Result :"); + printTensorValues(res_exact2); + + + void* res_exact3 = tensorConvApproxHalf2(input, filter, pad_h, pad_w, + stride_h, stride_w, + 1, 1, 1, 1, 1, 1); + convertToFP32((struct Tensor*) res_exact3); + + printf ("\nFP16_Baseline Result :"); + printTensorValues(res_exact3); + void* res_sim = tensorConvSampSim(input, filter, pad_h, pad_w, stride_h, stride_w, 1, 1, skip_every, offset); - printf ("ConvSampSim Result :"); + printf ("\nConvSampSim Result :"); printTensorValues(res_sim); @@ -703,7 +729,7 @@ void testSamplingCalls(void* input, void* filter, 1, 1, 1, 1, skip_every, offset); - printf ("ConvApprox Result :"); + printf ("\nConvApprox Result :"); printTensorValues(res); @@ -713,7 +739,7 @@ void testSamplingCalls(void* input, void* filter, convertToFP32((struct Tensor*) res_half); - printf ("ConvApproxHalf2 Result :"); + printf ("\nConvApproxHalf2 Result :"); printTensorValues(res_half); } @@ -735,6 +761,24 @@ void testSampling_3_3(){ Tensor* filter = (Tensor*) create4DTensor(CUDNN_DATA_FLOAT, CUDNN_TENSOR_NCHW, 1, 3, 3, 3); fillTensorWithVal(filter, 1); + + + float* host_ptr = (float*) ((struct Tensor*) filter)->host_data; + host_ptr[0] = 2; + host_ptr[2] = 2; + host_ptr[4] = 2; + host_ptr[6] = 2; + host_ptr[8] = 2; + host_ptr[10] = 2; + host_ptr[12] = 2; + host_ptr[14] = 2; + host_ptr[16] = 2; + host_ptr[18] = 2; + host_ptr[20] = 2; + host_ptr[22] = 2; + host_ptr[24] = 2; + host_ptr[26] = 2; + testSamplingCalls(input, filter, 0, 0, 1, 1, 2); @@ -761,21 +805,6 @@ void testSampling_3_3(){ /* - float* host_ptr = (float*) ((struct Tensor*) filter)->host_data; - host_ptr[0] = 2; - host_ptr[2] = 2; - host_ptr[4] = 2; - host_ptr[6] = 2; - host_ptr[8] = 2; - host_ptr[10] = 2; - host_ptr[12] = 2; - host_ptr[14] = 2; - host_ptr[16] = 2; - host_ptr[18] = 2; - host_ptr[20] = 2; - host_ptr[22] = 2; - host_ptr[24] = 2; - host_ptr[26] = 2; //printTensorValues(input); void* res = tensorConvApprox(input, filter, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1); -- GitLab