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

Fixing overflow bug in utils

parent 431e92f6
No related branches found
No related tags found
No related merge requests found
...@@ -225,14 +225,16 @@ void* readInputTensor(const char* file_name, int data_type, int dim1_size, int d ...@@ -225,14 +225,16 @@ void* readInputTensor(const char* file_name, int data_type, int dim1_size, int d
struct Tensor* readTrainedWeights(const char* file_name, int data_type, struct Tensor* readTrainedWeights(const char* file_name, int data_type,
int dim1_size, int dim2_size, long int dim1_size, long int dim2_size,
int dim3_size, int dim4_size){ long int dim3_size, long int dim4_size){
// FIXIT: Don't assume floating point types // FIXIT: Don't assume floating point types
int type_size = 4; // NOTE: Assuming floating point tensors int type_size = 4; // NOTE: Assuming floating point tensors
long int num_elems = dim1_size * dim2_size * dim3_size * dim4_size; long int num_elems = dim1_size * dim2_size * dim3_size * dim4_size;
long int size_in_bytes = type_size * dim1_size * dim2_size * dim3_size * dim4_size; long int size_in_bytes = type_size * dim1_size * dim2_size * dim3_size * dim4_size;
float* tensor_data = (float*) malloc(sizeof(float) * num_elems); float* tensor_data = (float*) malloc(sizeof(float) * num_elems);
printf("size_in_bytes = %lu \n", size_in_bytes);
int file_header_size = 0; int file_header_size = 0;
FILE* file = fopen(file_name, "rb"); FILE* file = fopen(file_name, "rb");
...@@ -578,5 +580,12 @@ float computePSNRViolation(void* gold_ptr, void* approx_ptr, float PSNR_threshol ...@@ -578,5 +580,12 @@ float computePSNRViolation(void* gold_ptr, void* approx_ptr, float PSNR_threshol
} }
void dumpOutput(void* output){
}
#endif #endif
...@@ -26,16 +26,17 @@ void testLenetTanh(){ ...@@ -26,16 +26,17 @@ void testLenetTanh(){
printf("********* Pipeline: Gaussian - Outline - Motion Blur - Emboss ********** \n"); printf("********* Pipeline: Gaussian - Outline - Motion Blur - Emboss ********** \n");
// FIXIT: Extend this to batch of images - currently 5 images // FIXIT: Extend this to batch of images - currently 5 images
int test_batch_size = 9145; //long int test_batch_size = 9145;
int H = 240; long int test_batch_size = 2000;
int W = 300; long int H = 240;
long int W = 300;
printf("Reading input\n"); printf("Reading input\n");
void* input = readTrainedWeights("../pipeline/dataset/caltech101_255_float32.bin", void* input = readTrainedWeights("../model_params/pipeline/dataset/caltech101_255_float32.bin",
float_type, float_type,
test_batch_size, 1, H, W); test_batch_size, 1, H, W);
printf("Reading golden output\n"); printf("Reading golden output\n");
void* golden_output = readTrainedWeights("../pipeline/golden_output/caltech-gaussian-outline-motionblur-emboss.bin", void* golden_output = readTrainedWeights("../model_params/pipeline/golden_output/caltech-gaussian-outline-motionblur-emboss.bin",
float_type, float_type,
test_batch_size, 1, H, W); test_batch_size, 1, H, W);
...@@ -43,19 +44,19 @@ void testLenetTanh(){ ...@@ -43,19 +44,19 @@ void testLenetTanh(){
// NOTE: Filter descriptors do NOT have batch size // NOTE: Filter descriptors do NOT have batch size
// NOTE: First two dims are output channels (configurable), input channels (MUST match input channels) // NOTE: First two dims are output channels (configurable), input channels (MUST match input channels)
// IMP: The output channels matches the trained model - not the Lenet arch proposed in Andrew Ng's class // IMP: The output channels matches the trained model - not the Lenet arch proposed in Andrew Ng's class
void* gaussian_filter = readTrainedWeights("../pipeline/filters/GaussianFilter.bin", void* gaussian_filter = readTrainedWeights("../model_params/pipeline/filters/GaussianFilter.bin",
float_type, 1, 1, 9, 9); float_type, 1, 1, 9, 9);
void* outline_filter = readTrainedWeights("../pipeline/filters/OutlineFilter.bin", void* outline_filter = readTrainedWeights("../model_params/pipeline/filters/OutlineFilter.bin",
float_type, 1, 1, 3, 3); float_type, 1, 1, 3, 3);
void* sharpen_filter = readTrainedWeights("../pipeline/filters/SharpenFilter.bin", void* sharpen_filter = readTrainedWeights("../model_params/pipeline/filters/SharpenFilter.bin",
float_type, 1, 1, 3, 3); float_type, 1, 1, 3, 3);
void* motionblur_filter = readTrainedWeights("../pipeline/filters/MotionblurFilter.bin", void* motionblur_filter = readTrainedWeights("../model_params/pipeline/filters/MotionblurFilter.bin",
float_type, 1, 1, 9, 9); float_type, 1, 1, 9, 9);
//void* conv1_bias = readTrainedWeights("../model_params/lenet_keras/conv1_bias.bin", //void* conv1_bias = readTrainedWeights("../model_params/lenet_keras/conv1_bias.bin",
//float_type, 1, 32, 1, 1); //float_type, 1, 32, 1, 1);
void* emboss_filter = readTrainedWeights("../pipeline/filters/EmbossFilter.bin", void* emboss_filter = readTrainedWeights("../model_params/pipeline/filters/EmbossFilter.bin",
float_type, 1, 1, 5, 5); float_type, 1, 1, 5, 5);
void* emboss_bias = readTrainedWeights("../pipeline/filters/EmbossBias.bin", void* emboss_bias = readTrainedWeights("../model_params/pipeline/filters/EmbossBias.bin",
float_type, 1, 1, 1, 1); float_type, 1, 1, 1, 1);
clearTensorMap(); clearTensorMap();
......
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