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

Updating unit tessts

parent 4be5f914
No related branches found
No related tags found
No related merge requests found
...@@ -62,24 +62,23 @@ void testTensorHgemm(){ ...@@ -62,24 +62,23 @@ void testTensorHgemm(){
void testTensorSgemm2(){ void testTensorSgemm(){
printf("***** TensorSgemm ***** \n\n"); printf("***** TensorSgemm ***** \n\n");
void* lhs_ptr = create4DTensor(CUDNN_DATA_FLOAT, CUDNN_TENSOR_NCHW, void* lhs_ptr = create4DTensor(CUDNN_DATA_FLOAT, CUDNN_TENSOR_NCHW, 5, 4, 1, 1);
10000, 800, 1, 1);
struct Tensor* lhs = (struct Tensor*) lhs_ptr; struct Tensor* lhs = (struct Tensor*) lhs_ptr;
fillTensorWithOnes(lhs);
float* data_arr = (float*) lhs->host_data; float* data_arr = (float*) lhs->host_data;
for(int i = 0; i < lhs->num_elems; i++){ for(int i = 0; i < lhs->num_elems; i++){
data_arr[i] = (i / 4) + 1; data_arr[i] = (i / 4) + 1;
} }
void* rhs = create4DTensor(CUDNN_TENSOR_NCHW, CUDNN_DATA_FLOAT, void* rhs = create4DTensor(CUDNN_TENSOR_NCHW, CUDNN_DATA_FLOAT, 1, 1, 4, 3);
1, 1, 800, 800);
fillTensorWithOnes(rhs); fillTensorWithOnes(rhs);
void* output = tensorGemmGPU(lhs, rhs); void* output = tensorGemmGPU(lhs, rhs);
//printTensorValues(output); printTensorValues(output);
} }
...@@ -291,24 +290,42 @@ void testTensorError(){ ...@@ -291,24 +290,42 @@ void testTensorError(){
void testTensorConv(){ void testTensorConv(){
// NOTE: The input channel count value (param2 to Tensor and Filter) must be the same void* input = create4DTensor(CUDNN_DATA_FLOAT, CUDNN_TENSOR_NCHW, 1, 2, 4, 4);
void* x3 = create4DTensor(CUDNN_DATA_FLOAT, CUDNN_TENSOR_NCHW, 1, 2, 4, 4); void* filter = create4DTensor(CUDNN_DATA_FLOAT, CUDNN_TENSOR_NCHW, 2, 2, 3, 3);
// NOTE: Filter descriptors do NOT have batch size
// NOTE: First two dims are output channels (configurable), input channels (MUST match input channels) fillTensorWithOnes(input);
void* filter = create4DTensor(CUDNN_DATA_FLOAT, CUDNN_TENSOR_NCHW, 2, 2, 2, 2);
fillTensorWithOnes(x3);
fillTensorWithOnes(filter); fillTensorWithOnes(filter);
int conv_mode = 1; // NOTE: uses CROSS_CORRELATION int conv_mode = 1; // NOTE: uses CROSS_CORRELATION
int compute_precision = 0; // floating point precision for conv int compute_precision = 0; // floating point precision for conv
void* conv1 = tensorConvolution(x3, filter, 0, 0, void* conv_out = tensorConvolution(input, filter, 0, 0,
1, 1, conv_mode, compute_precision); 1, 1, conv_mode, compute_precision);
printTensorValues(conv1); printTensorValues(conv_out);
} }
void testTensorHalfConv(){
void* input = create4DTensor(CUDNN_DATA_FLOAT, CUDNN_TENSOR_NCHW, 1, 2, 4, 4);
void* filter = create4DTensor(CUDNN_DATA_FLOAT, CUDNN_TENSOR_NCHW, 2, 2, 3, 3);
fillTensorWithOnes(input);
fillTensorWithOnes(filter);
int conv_mode = 1; // NOTE: uses CROSS_CORRELATION
int compute_precision = 0; // floating point precision for conv
void* conv_out = tensorHalfConvolution(input, filter, 0, 0,
1, 1, conv_mode, compute_precision);
printTensorValues(conv_out);
}
void testTensorGroupedConv(){ void testTensorGroupedConv(){
// NOTE: The input channel count value (param2 to Tensor and Filter) must be the same // NOTE: The input channel count value (param2 to Tensor and Filter) must be the same
...@@ -1176,11 +1193,14 @@ int main(){ ...@@ -1176,11 +1193,14 @@ int main(){
llvm_hpvm_initTensorRt(0); llvm_hpvm_initTensorRt(0);
startProfiling(); startProfiling();
// Function call per unit test
testTensorHgemm();
testTensorSgemm();
testTensorHgemm(); testTensorConv();
testTensorHalfConv();
//testTensorSgemm2();
//testTensorConv();
//testTensorError(); //testTensorError();
//testQuantization(); //testQuantization();
......
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