Move generic files to src/common

This commit is contained in:
augustin64 2023-05-12 16:16:34 +02:00
parent e44cecbe8d
commit fd36226600
46 changed files with 102 additions and 76 deletions

View File

@ -6,8 +6,9 @@ CUDA_INCLUDE := /opt/cuda/include # Default installation path for ArchLinux, may
NVCC_INSTALLED := $(shell command -v $(NVCC) 2> /dev/null)
DENSE_SRCDIR := $(SRCDIR)/dense
CNN_SRCDIR := $(SRCDIR)/cnn
COMMON_SRCDIR := $(SRCDIR)/common
DENSE_SRCDIR := $(SRCDIR)/dense
CNN_SRCDIR := $(SRCDIR)/cnn
DENSE_SRC := $(wildcard $(DENSE_SRCDIR)/*.c)
CNN_SRC := $(wildcard $(CNN_SRCDIR)/*.c)
@ -146,14 +147,14 @@ endif
#
# Build general files
#
$(BUILDDIR)/%.o: $(SRCDIR)/%.c $(SRCDIR)/include/%.h
$(BUILDDIR)/%.o: $(COMMON_SRCDIR)/%.c $(COMMON_SRCDIR)/include/%.h
$(CC) -c $< -o $@ $(CFLAGS)
$(BUILDDIR)/%.cuda.o: $(SRCDIR)/%.c $(SRCDIR)/include/%.h
$(BUILDDIR)/%.cuda.o: $(COMMON_SRCDIR)/%.c $(COMMON_SRCDIR)/include/%.h
$(CC) -c $< -o $@ $(CFLAGS) -DUSE_CUDA -lcuda -I$(CUDA_INCLUDE)
ifdef NVCC_INSTALLED
$(BUILDDIR)/cuda_%.o: $(SRCDIR)/%.cu $(SRCDIR)/include/%.h
$(BUILDDIR)/cuda_%.o: $(COMMON_SRCDIR)/%.cu $(COMMON_SRCDIR)/include/%.h
$(NVCC) $(NVCCFLAGS) -c -dc $< -o $@
else
@echo "$(NVCC) not found, skipping"
@ -182,7 +183,7 @@ $(BUILDDIR)/test-dense_%: $(TEST_SRCDIR)/dense_%.c $(DENSE_OBJ) $(BUILDDIR)/colo
$(BUILDDIR)/test-memory_management: $(TEST_SRCDIR)/memory_management.c $(BUILDDIR)/colors.o $(BUILDDIR)/utils.o $(BUILDDIR)/test_memory_management.o
$(CC) $^ -o $@ $(CFLAGS) $(LD_CFLAGS)
$(BUILDDIR)/test_memory_management.o: $(SRCDIR)/memory_management.c $(SRCDIR)/include/memory_management.h
$(BUILDDIR)/test_memory_management.o: $(COMMON_SRCDIR)/memory_management.c $(COMMON_SRCDIR)/include/memory_management.h
$(CC) -c $< -o $@ $(CFLAGS) -DTEST_MEMORY_MANAGEMENT
ifdef NVCC_INSTALLED

View File

@ -3,7 +3,7 @@
#include <math.h>
#include "include/backpropagation.h"
#include "../include/utils.h"
#include "../common/include/utils.h"
#include "include/struct.h"
#include "include/config.h"

View File

@ -3,7 +3,7 @@
#include <math.h>
#include "include/backpropagation.h"
#include "../include/utils.h"
#include "../common/include/utils.h"
#include "include/struct.h"
#include "include/config.h"

View File

@ -4,7 +4,9 @@
#include <float.h> // Is it used ?
#include <math.h>
#include "../include/memory_management.h"
#include "../common/include/memory_management.h"
#include "../common/include/colors.h"
#include "../common/include/utils.h"
#include "include/backpropagation.h"
#include "include/initialisation.h"
#include "include/function.h"
@ -12,8 +14,6 @@
#include "include/update.h"
#include "include/make.h"
#include "../include/colors.h"
#include "../include/utils.h"
#include "include/cnn.h"
// Augmente les dimensions de l'image d'entrée

View File

@ -3,7 +3,7 @@
#include <stdbool.h>
#include "include/struct.h"
#include "../include/utils.h"
#include "../common/include/utils.h"
#include "include/config.h"

View File

@ -3,7 +3,7 @@
#include <stdbool.h>
#include "include/struct.h"
#include "../include/utils.h"
#include "../common/include/utils.h"
#include "include/config.h"

View File

@ -1,11 +1,11 @@
#include <stdio.h>
#include <stdlib.h>
#include "../include/memory_management.h"
#include "../common/include/memory_management.h"
#include "../common/include/colors.h"
#include "../common/include/utils.h"
#include "include/initialisation.h"
#include "../include/colors.h"
#include "include/function.h"
#include "../include/utils.h"
#include "include/creation.h"
@ -38,7 +38,7 @@ Network* create_network(int max_size, float learning_rate, int dropout, int acti
return network;
}
Network* create_network_lenet5(float learning_rate, int dropout, int activation, int initialisation, int input_dim, int input_depth) {
/*Network* create_network_lenet5(float learning_rate, int dropout, int activation, int initialisation, int input_dim, int input_depth) {
Network* network = create_network(8, learning_rate, dropout, activation, initialisation, input_dim, input_depth);
add_convolution(network, 6, 28, activation);
add_average_pooling(network, 14);
@ -48,8 +48,32 @@ Network* create_network_lenet5(float learning_rate, int dropout, int activation,
add_dense(network, 84, activation);
add_dense(network, 10, SOFTMAX);
return network;
}*/
Network* create_network_lenet5(float learning_rate, int dropout, int activation, int initialisation, int input_dim, int input_depth) {
input_dim = 260;
input_depth = 3;
Network* network = create_network(16, learning_rate, dropout, activation, initialisation, input_dim, input_depth);
printf_warning("Creating large network");
printf(" %d %d\n", input_dim, input_depth);
add_convolution(network, 6, 258, activation);
add_convolution(network, 16, 256, activation);
add_average_pooling(network, 64);
add_convolution(network, 16, 60, activation);
add_average_pooling(network, 30);
add_convolution(network, 16, 26, activation);
add_convolution(network, 16, 22, activation);
add_convolution(network, 16, 18, activation);
add_dense_linearisation(network, 840, activation);
add_dense(network, 520, activation);
add_dense(network, 420, activation);
add_dense(network, 320, activation);
add_dense(network, 220, activation);
add_dense(network, 120, activation);
add_dense(network, 50, SOFTMAX);
return network;
}
Network* create_simple_one(float learning_rate, int dropout, int activation, int initialisation, int input_dim, int input_depth) {
Network* network = create_network(3, learning_rate, dropout, activation, initialisation, input_dim, input_depth);
add_dense_linearisation(network, 80, activation);

View File

@ -4,10 +4,11 @@
#include <stdio.h>
#include <math.h>
#include "../common/include/colors.h"
#include "include/backpropagation.h"
#include "../common/include/mnist.h"
#include "include/neuron_io.h"
#include "../include/colors.h"
#include "../include/mnist.h"
#include "include/struct.h"
#include "include/jpeg.h"
#include "include/free.h"

View File

@ -1,7 +1,7 @@
#include <stdlib.h>
#include <stdio.h>
#include "../include/memory_management.h"
#include "../common/include/memory_management.h"
#include "include/free.h"

View File

@ -2,8 +2,8 @@
#include <math.h>
#include <float.h>
#include "../include/colors.h"
#include "../include/utils.h"
#include "../common/include/colors.h"
#include "../common/include/utils.h"
#include "include/config.h"

View File

@ -2,8 +2,8 @@
#include <math.h>
#include <float.h>
#include "../include/colors.h"
#include "../include/utils.h"
#include "../common/include/colors.h"
#include "../common/include/utils.h"
#include "include/config.h"

View File

@ -1,7 +1,7 @@
#include <stdlib.h>
#include <math.h>
#include "../include/colors.h"
#include "../common/include/colors.h"
#include "include/initialisation.h"
// glorot (wavier initialisation) linear, tanh, softmax, logistic (1/(fan_in+fan_out/2))

View File

@ -5,9 +5,10 @@
#include <jerror.h>
#include <jpeglib.h>
#include "../common/include/utils.h"
#include "../common/include/colors.h"
#include "include/jpeg.h"
#include "../include/utils.h"
#include "../include/colors.h"
// How to load a JPEG using libjpeg: https://www.tspi.at/2020/03/20/libjpegexample.html
imgRawImage* loadJpegImageFile(char* lpFilename) {

View File

@ -5,9 +5,10 @@
#include <stdbool.h>
#include <float.h>
#include "../common/include/colors.h"
#include "include/initialisation.h"
#include "include/test_network.h"
#include "../include/colors.h"
#include "include/function.h"
#include "include/creation.h"
#include "include/train.h"

View File

@ -2,9 +2,9 @@
#include <float.h>
#include <math.h>
#include "../common/include/colors.h"
#include "../common/include/utils.h"
#include "include/convolution.h"
#include "../include/colors.h"
#include "../include/utils.h"
#include "include/make.h"

View File

@ -2,9 +2,9 @@
#include <float.h>
#include <math.h>
#include "../common/include/colors.h"
#include "../common/include/utils.h"
#include "include/convolution.h"
#include "../include/colors.h"
#include "../include/utils.h"
#include "include/make.h"

View File

@ -2,8 +2,8 @@
#include <stdio.h>
#include <stdbool.h>
#include "../include/colors.h"
#include "../include/utils.h"
#include "../common/include/colors.h"
#include "../common/include/utils.h"
#define BLOCKSIZE_x 16
#define BLOCKSIZE_y 16

View File

@ -3,8 +3,8 @@
#include <stdint.h>
#include <inttypes.h>
#include "../include/memory_management.h"
#include "../include/colors.h"
#include "../common/include/memory_management.h"
#include "../common/include/colors.h"
#include "include/function.h"
#include "include/struct.h"

View File

@ -3,7 +3,7 @@
#include <stdint.h>
#include <inttypes.h>
#include "../include/utils.h"
#include "../common/include/utils.h"
#include "include/jpeg.h"

View File

@ -3,8 +3,8 @@
#include <stdbool.h>
#include <string.h>
#include "../include/memory_management.h"
#include "../include/mnist.h"
#include "../common/include/memory_management.h"
#include "../common/include/mnist.h"
#include "include/neuron_io.h"
#include "include/struct.h"
#include "include/jpeg.h"

View File

@ -7,13 +7,13 @@
#include <time.h>
#include <omp.h>
#include "../include/memory_management.h"
#include "../include/mnist.h"
#include "../common/include/memory_management.h"
#include "../common/include/mnist.h"
#include "include/initialisation.h"
#include "include/test_network.h"
#include "include/neuron_io.h"
#include "../include/colors.h"
#include "../include/utils.h"
#include "../common/include/colors.h"
#include "../common/include/utils.h"
#include "include/function.h"
#include "include/creation.h"
#include "include/update.h"

View File

@ -4,8 +4,8 @@
#include <string.h>
#include <math.h>
#include "../include/memory_management.h"
#include "../include/colors.h"
#include "../common/include/memory_management.h"
#include "../common/include/colors.h"
#include "include/struct.h"
#define copyVar(var) network_cp->var = network->var

View File

@ -6,11 +6,12 @@
#include <pthread.h>
#include <sys/sysinfo.h>
#include "include/main.h"
#include "../include/mnist.h"
#include "../include/colors.h"
#include "include/neuron_io.h"
#include "include/neural_network.h"
#include "../common/include/colors.h"
#include "../common/include/mnist.h"
#include "include/neuron_io.h"
#include "include/main.h"
#define EPOCHS 10
#define BATCHES 100

View File

@ -3,7 +3,7 @@
#include <stdint.h>
#include <inttypes.h>
#include "../include/mnist.h"
#include "../common/include/mnist.h"
void print_image(unsigned int width, unsigned int height, int** image) {

View File

@ -3,9 +3,9 @@
#include <string.h>
#include <float.h>
#include "../common/include/mnist.h"
#include "include/neural_network.h"
#include "include/neuron_io.h"
#include "../include/mnist.h"
/*
Contient un ensemble de fonctions utiles pour le débogage

View File

@ -6,11 +6,11 @@
#include <time.h>
#include <omp.h>
#include "../src/include/memory_management.h"
#include "../src/common/include/memory_management.h"
#include "../src/cnn/include/convolution.h"
#include "../src/common/include/colors.h"
#include "../src/common/include/utils.h"
#include "../src/cnn/include/struct.h"
#include "../src/include/colors.h"
#include "../src/include/utils.h"
float random_float(float low, float high) {

View File

@ -2,10 +2,10 @@
#include <assert.h>
#include <stdio.h>
#include "../src/include/memory_management.h"
#include "../src/common/include/memory_management.h"
#include "../src/common/include/colors.h"
#include "../src/common/include/utils.h"
#include "../src/cnn/include/function.h"
#include "../src/include/colors.h"
#include "../src/include/utils.h"
#include "../src/cnn/include/config.h"

View File

@ -6,9 +6,9 @@
#include <omp.h>
#include "../src/cnn/include/matrix_multiplication.h"
#include "../src/include/memory_management.h"
#include "../src/include/colors.h"
#include "../src/include/utils.h"
#include "../src/common/include/memory_management.h"
#include "../src/common/include/colors.h"
#include "../src/common/include/utils.h"
float random_float(float low, float high) {

View File

@ -3,12 +3,11 @@
#include <stdint.h>
#include <inttypes.h>
#include "../src/include/colors.h"
#include "../src/common/include/colors.h"
#include "../src/cnn/include/neuron_io.h"
#include "../src/cnn/include/creation.h"
#include "../src/cnn/include/utils.h"
#include "../src/cnn/include/free.h"
#include "../src/include/colors.h"
int main() {

View File

@ -3,11 +3,10 @@
#include <stdint.h>
#include <inttypes.h>
#include "../src/include/colors.h"
#include "../src/common/include/colors.h"
#include "../src/cnn/include/creation.h"
#include "../src/cnn/include/utils.h"
#include "../src/cnn/include/free.h"
#include "../src/include/colors.h"
int main() {

View File

@ -1,11 +1,10 @@
#include <stdlib.h>
#include <stdio.h>
#include "../src/include/colors.h"
#include "../src/common/include/colors.h"
#include "../src/cnn/include/creation.h"
#include "../src/cnn/include/utils.h"
#include "../src/cnn/include/free.h"
#include "../src/include/colors.h"
int main() {
printf("Création du réseau\n");

View File

@ -2,8 +2,8 @@
#include <stdio.h>
#include <inttypes.h>
#include "../src/include/mnist.h"
#include "../src/include/colors.h"
#include "../src/common/include/colors.h"
#include "../src/common/include/mnist.h"
void read_test(int nb_images, int width, int height, int*** images, unsigned int* labels) {

View File

@ -5,7 +5,7 @@
#include "../src/dense/include/neural_network.h"
#include "../src/dense/include/neuron_io.h"
#include "../src/include/colors.h"
#include "../src/common/include/colors.h"
int main() {
printf("Création du réseau\n");

View File

@ -4,9 +4,9 @@
#include <stdint.h>
#include <inttypes.h>
#include "../src/dense/include/neuron_io.h"
#include "../src/dense/include/neural_network.h"
#include "../src/include/colors.h"
#include "../src/dense/include/neuron_io.h"
#include "../src/common/include/colors.h"
Neuron* creer_neuron(int nb_sortants) {

View File

@ -2,8 +2,8 @@
#include <stdio.h>
#include <assert.h>
#include "../src/include/memory_management.h"
#include "../src/include/colors.h"
#include "../src/common/include/memory_management.h"
#include "../src/common/include/colors.h"
#define N 350

View File

@ -2,9 +2,9 @@
#include <stdio.h>
#include <assert.h>
#include "../src/include/memory_management.h"
#include "../src/include/colors.h"
#include "../src/include/utils.h"
#include "../src/common/include/memory_management.h"
#include "../src/common/include/colors.h"
#include "../src/common/include/utils.h"
#define N 350