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

Fixing Integer overflow bug in Input reading routine

parent 8e49a375
No related branches found
No related tags found
No related merge requests found
......@@ -318,13 +318,13 @@ struct Tensor* readInputBatch(const char* file_name, int data_type,
int start, int end,
int dim2_size, int dim3_size, int dim4_size){
int dim1_size = end - start;
long int dim1_size = end - start;
// FIXIT: Don't assume floating point types
int type_size = 4; // NOTE: Assuming floating point tensors
long int type_size = 4; // NOTE: Assuming floating point tensors
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;
float* tensor_data = (float*) malloc(sizeof(float) * num_elems);
int file_header_size = type_size * start * dim2_size * dim3_size * dim4_size;
long int file_header_size = type_size * start * dim2_size * dim3_size * dim4_size;
FILE* file = fopen(file_name, "rb");
if(file == NULL){
......@@ -335,9 +335,9 @@ struct Tensor* readInputBatch(const char* file_name, int data_type,
fseek(file, file_header_size, SEEK_SET); // Skipping the file header
size_t bytes_read = fread(tensor_data, 1, size_in_bytes, file);
fclose(file);
//printf ("FIXED input BATCH read \n");
struct Tensor* weights = (struct Tensor*) create4DTensor(data_type, nchw, dim1_size, dim2_size,
dim3_size, dim4_size);
......
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