Skip to content
Snippets Groups Projects
Commit 285a8069 authored by Hashim Sharif's avatar Hashim Sharif
Browse files

Adding test cases for quantizzation

parent 7f8b4a9f
No related branches found
No related tags found
No related merge requests found
......@@ -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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment