From db92b367ad3f153052396dc661e34829d80f3ac8 Mon Sep 17 00:00:00 2001 From: augustin64 Date: Sun, 19 Feb 2023 10:22:22 +0100 Subject: [PATCH] Fix abusive unnecessary use of shared memory --- src/cnn/test_network.c | 28 ++++++++++++++-------------- src/cnn/train.c | 12 ++++++------ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/cnn/test_network.c b/src/cnn/test_network.c index 34e9960..1b65958 100644 --- a/src/cnn/test_network.c +++ b/src/cnn/test_network.c @@ -30,7 +30,7 @@ void test_network_mnist(Network* network, char* images_file, char* labels_file, width = mnist_parameters[1]; height = mnist_parameters[2]; - gree(mnist_parameters); + free(mnist_parameters); // Load image in the first layer of the Network for (int i=0; i < nb_elem; i++) { @@ -47,11 +47,11 @@ void test_network_mnist(Network* network, char* images_file, char* labels_file, } for (int j=0; j < height; j++) { - gree(images[i][j]); + free(images[i][j]); } - gree(images[i]); + free(images[i]); } - gree(images); + free(images); printf("%d Images. Taux de réussite: %.2f%%\n", nb_elem, 100*accuracy/(float)nb_elem); } @@ -76,13 +76,13 @@ void test_network_jpg(Network* network, char* data_dir, bool preview_fails) { accuracy++; } - gree(dataset->images[i]); + free(dataset->images[i]); } printf("%d Images. Taux de réussite: %.2f%%\n", dataset->numImages, 100*accuracy/(float)dataset->numImages); - gree(dataset->images); - gree(dataset->labels); - gree(dataset); + free(dataset->images); + free(dataset->labels); + free(dataset); } @@ -110,7 +110,7 @@ void recognize_mnist(Network* network, char* input_file, char* out) { width = mnist_parameters[1]; height = mnist_parameters[2]; - gree(mnist_parameters); + free(mnist_parameters); if (! strcmp(out, "json")) { printf("{\n"); @@ -148,15 +148,15 @@ void recognize_mnist(Network* network, char* input_file, char* out) { } for (int j=0; j < height; j++) { - gree(images[i][j]); + free(images[i][j]); } - gree(images[i]); + free(images[i]); } if (! strcmp(out, "json")) { printf("}\n"); } - gree(images); + free(images); } void recognize_jpg(Network* network, char* input_file, char* out) { @@ -195,8 +195,8 @@ void recognize_jpg(Network* network, char* input_file, char* out) { printf("}\n"); } - gree(image->lpData); - gree(image); + free(image->lpData); + free(image); } void recognize(int dataset_type, char* modele, char* input_file, char* out) { diff --git a/src/cnn/train.c b/src/cnn/train.c index a7a3e49..e39b391 100644 --- a/src/cnn/train.c +++ b/src/cnn/train.c @@ -72,7 +72,7 @@ void* train_thread(void* parameters) { if (!param->dataset->images[index[i]]) { image = loadJpegImageFile(param->dataset->fileNames[index[i]]); param->dataset->images[index[i]] = image->lpData; - gree(image); + free(image); } write_image_in_network_260(param->dataset->images[index[i]], height, width, network->input[0]); forward_propagation(network); @@ -83,7 +83,7 @@ void* train_thread(void* parameters) { accuracy += 1.; } - gree(param->dataset->images[index[i]]); + free(param->dataset->images[index[i]]); param->dataset->images[index[i]] = NULL; } } @@ -351,12 +351,12 @@ void train(int dataset_type, char* images_file, char* labels_file, char* data_di if (dataset_type == 0) { for (int i=0; i < nb_images_total; i++) { for (int j=0; j < 28; j++) { - gree(images[i][j]); + free(images[i][j]); } - gree(images[i]); + free(images[i]); } - gree(images); - gree(labels); + free(images); + free(labels); } else { free_dataset(dataset); }