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 b75b0934f12161f72df8b2cc2c5dc75a8ae35ab7..8b1cfbf5371c71d5f6d01897ed3d93d74a434c0f 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 @@ -450,7 +450,7 @@ void testSoftmaxOutput(void* output_ptr){ void testQuantization(){ printf("***** TensorQuantize ***** \n\n"); - void* input = create4DTensor(CUDNN_DATA_FLOAT, CUDNN_TENSOR_NCHW, 2, 4, 1, 1); + void* input = create4DTensor(CUDNN_DATA_FLOAT, CUDNN_TENSOR_NCHW, 2, 6, 1, 1); float* host_ptr = (float*) ((struct Tensor*) input)->host_data; host_ptr[0] = -0.1; @@ -461,14 +461,83 @@ void testQuantization(){ host_ptr[5] = -2.9; host_ptr[6] = 0.7; host_ptr[7] = 0.99; + host_ptr[8] = 7; + host_ptr[9] = 7.2; + host_ptr[10] = 2.5; + host_ptr[11] = 3; + + + void* quantize_result1 = quantizeTensorPromise(input, -4, 6); + + printf ("\n ** quantizing with range min = %d max = %d \n", -4, 6); + printTensorValues(quantize_result1); + + host_ptr[0] = -0.1; + host_ptr[1] = -25; + host_ptr[2] = 0.2; + host_ptr[3] = -0.4; + host_ptr[4] = 1.7; + host_ptr[5] = -2.9; + host_ptr[6] = 0.7; + host_ptr[7] = 0.99; + host_ptr[8] = 7; + host_ptr[9] = 7.2; + host_ptr[10] = 2.5; + host_ptr[11] = 3; + + void* quantize_result2 = quantizeTensorPromise(input, -2, 2); + + printf ("\n ** quantizing with range min = %d max = %d \n", -2, 2); + printTensorValues(quantize_result2); + + host_ptr[0] = -0.1; + host_ptr[1] = -25; + host_ptr[2] = 0.2; + host_ptr[3] = -0.4; + host_ptr[4] = 1.7; + host_ptr[5] = -2.9; + host_ptr[6] = 0.7; + host_ptr[7] = 0.99; + host_ptr[8] = 7; + host_ptr[9] = 7.2; + host_ptr[10] = 2.5; + host_ptr[11] = 3; + + + void* quantize_result3 = quantizeTensorPromise(input, -25, 8); + + printf ("\n ** quantizing with range min = %d max = %d \n", -25, 8); + printTensorValues(quantize_result3); - void* quantize_result = quantizeTensorPromise(input, -4, 6); + printf ("\n ** quantizing with range min = %d max = %d \n", -10, 10); + + host_ptr[0] = -0.1; + host_ptr[1] = -25; + host_ptr[2] = 0.2; + host_ptr[3] = -0.4; + host_ptr[4] = 1.7; + host_ptr[5] = -2.9; + host_ptr[6] = 0.7; + host_ptr[7] = 0.99; + host_ptr[8] = 7; + host_ptr[9] = 7.2; + host_ptr[10] = 2.5; + host_ptr[11] = 3; + + + void* quantize_result4 = quantizeTensorPromise(input, -10, 10); - printTensorValues(quantize_result); + printTensorValues(quantize_result4); + - void* error_out = addPromiseError(quantize_result, 1); - printTensorValues(error_out); + void* quantize_result5 = quantizeTensorPromise(input, -10, 10); + + printTensorValues(quantize_result5); + + + //void* error_out = addPromiseError(quantize_result, 1); + //printTensorValues(error_out); } @@ -969,7 +1038,7 @@ int main(){ //testTensorConv(); //testTensorError(); - //testQuantization(); + testQuantization(); //testTensorConv(); //testTensorGroupedConv(); @@ -1002,7 +1071,7 @@ int main(){ //testSampling3(); - testSampling_3_3(); + // testSampling_3_3(); //- testSampling_1_1();