From 2ef9a6b7c42adbc40faf817ef986fe49f2ac9aa9 Mon Sep 17 00:00:00 2001 From: fanasina Date: Tue, 16 Apr 2024 21:14:30 +0200 Subject: [PATCH] setup neurons library and some script to test this lib --- neuron_t/Makefile | 7 +- .../include/dimension_t/dimension_t.h | 70 ++++++++++ .../include/neuron_t/neuron_t.h | 127 ++++++++++++++++++ .../include/permutation_t/permutation_t.h | 54 ++++++++ .../include/set_theoric_t/set_theoric_t.h | 24 ++++ .../include/tensor_t/cl_tensor_t.h | 28 ++++ .../include/tensor_t/tensor_t.h | 85 ++++++++++++ neuron_t/test/c_launch | Bin 0 -> 31504 bytes neuron_t/test/compile_with_libneurons.sh | 3 + neuron_t/test/run_c.sh | 3 + 10 files changed, 397 insertions(+), 4 deletions(-) create mode 100644 neuron_t/include_neurons/include/dimension_t/dimension_t.h create mode 100644 neuron_t/include_neurons/include/neuron_t/neuron_t.h create mode 100644 neuron_t/include_neurons/include/permutation_t/permutation_t.h create mode 100644 neuron_t/include_neurons/include/set_theoric_t/set_theoric_t.h create mode 100644 neuron_t/include_neurons/include/tensor_t/cl_tensor_t.h create mode 100644 neuron_t/include_neurons/include/tensor_t/tensor_t.h create mode 100644 neuron_t/test/c_launch create mode 100644 neuron_t/test/compile_with_libneurons.sh create mode 100644 neuron_t/test/run_c.sh diff --git a/neuron_t/Makefile b/neuron_t/Makefile index 4ef7dff..7a3aad0 100644 --- a/neuron_t/Makefile +++ b/neuron_t/Makefile @@ -70,10 +70,9 @@ $(DEPS): $(MAKE) -C $@ $(MAKECMDGOALS) update_headers: $(PROJECT_LIB) - for file_h in $(DEPS); do - cd ${file_h}/src - #cp --parents "$$file_h/include/" include_neurons/; done - cp --parents "*/*.h" "$(INCLUDE_HEADERS_NEURONS)/" ; + for file_h in $(DEPS); do \ + cd "$$file_h/src" ; \ + cp --parents */*.h $(INCLUDE_HEADERS_NEURONS)/ ; \ done diff --git a/neuron_t/include_neurons/include/dimension_t/dimension_t.h b/neuron_t/include_neurons/include/dimension_t/dimension_t.h new file mode 100644 index 0000000..14f18a8 --- /dev/null +++ b/neuron_t/include_neurons/include/dimension_t/dimension_t.h @@ -0,0 +1,70 @@ +#ifndef __DIMENSION_T__H__ +#define __DIMENSION_T__H__ + +#include "permutation_t/permutation_t.h" + +extern bool endian; + +bool isLessEqThan(long int a, long int b) ; +bool isLessThan(long int a, long int b) ; +bool isGreatEqThan(long int a, long int b) ; +bool isGreatThan(long int a, long int b) ; +long int incr(long int i) ; +long int decr(long int i) ; + + +typedef struct PERMUTATION_TYPE_SIZE_T dimension ; + +dimension * create_dim(size_t size); +dimension * create_reverse_dim(size_t size); +dimension* init_dim(size_t *t, size_t sz); +dimension* init_copy_dim(size_t *t, size_t sz); +dimension* clone_dim(dimension *dim); +void free_dimension(dimension *d); + +bool is_equal_dim(dimension *d0, dimension *d1); + +dimension* sub_minus_dim_head(dimension *t, size_t minusSubdim); +dimension* sub_minus_dim_tail(dimension *t, size_t minusSubdim); +dimension* sub_dim_head(dimension *t, size_t subdim); +dimension* sub_dim_tail(dimension *t, size_t subdim); + +dimension* sub_copy_minus_dim_head(dimension *t, size_t minusSubdim); +dimension* sub_copy_minus_dim_tail(dimension *t, size_t minusSubdim); +dimension* sub_copy_dim_head(dimension *t, size_t sub_copydim); +dimension* sub_copy_dim_tail(dimension *t, size_t sub_copydim); + +void split_dim_part(dimension *root, dimension **part_1, dimension **part_2, size_t pivotSplit, size_t rangeInPivot ); + +void add_copy_dimension(dimension **d, dimension *d0, dimension *d1); +void min_copy_dimension(dimension **d, dimension *d0, dimension *d1); + +void add_dimension(dimension **d, dimension *d0, dimension *d1); +void min_dimension(dimension **d, dimension *d0, dimension *d1); + +void printDebug_dimension(dimension *d, char *msg); +size_t sprint_dimension(char **dimContent, dimension *d); + +void updateRankDim(dimension *dim); +size_t LineFromCoord(size_t *coo, dimension *dim); +size_t* CoordFromLin(size_t line, dimension *dim); +void vCoordFromLin(size_t *ret, size_t line, dimension *dim ); + +void increment_dim_var(dimension *d); +void decrement_dim_var(dimension *d); + +struct list_perm_in_dim{ + size_t index; + size_t perm; + struct list_perm_in_dim *next; +}; + +typedef struct list_perm_in_dim list_perm_in_dim; + +void append_in_list_perm(list_perm_in_dim **list_p, size_t perm); +dimension * create_dim_from_list_perm( list_perm_in_dim *l_p); + +void free_list_perm_in_dim(list_perm_in_dim *l_p); + +#endif /* __DIMENSION_T__H__ */ +//int compare_dimension(dimension *d1, dimension *d2); diff --git a/neuron_t/include_neurons/include/neuron_t/neuron_t.h b/neuron_t/include_neurons/include/neuron_t/neuron_t.h new file mode 100644 index 0000000..020f05c --- /dev/null +++ b/neuron_t/include_neurons/include/neuron_t/neuron_t.h @@ -0,0 +1,127 @@ +#ifndef __NEURON_T_C__H +#define __NEURON_T_C__H + +#include +#include +#include + +//#include "tools_t/tools_t.h" +#include "tensor_t/tensor_t.h" + +extern bool randomizeInitWeight; + +struct config_layers{ + size_t nb_layers; + size_t *sz_layers; + size_t **array_dim_in_layers; +}; +typedef struct config_layers config_layers; +config_layers *create_config_layers(size_t nb_layers, size_t *sz_layers, size_t **array_dim_in_layers); +config_layers *create_config_layers_from_OneD(size_t nb_layers, size_t *array_dim_in_layers); +void free_config_layers(config_layers *pconf); + + +#define GEN_NEURON_(type)\ +\ +struct neurons_##type {/* layer */\ + size_t id_layer;\ + size_t iteration_step;\ + size_t nb_prod_thread;\ + size_t nb_calc_thread;\ + type initial_learning_rate;\ + type learning_rate;\ + type decay_rate;\ + size_t drop_rate;\ + void (*update_learning_rate)(struct neurons_##type *N); \ + tensor_##type *input; \ + tensor_##type *net; /* output tensor_prodContract */\ + tensor_##type *output; \ + tensor_##type *target; \ + tensor_##type *weight_in; /* weight link in */\ + tensor_##type *bias; /* bias */\ + tensor_##type *weight_out; /* weight link out */\ + tensor_##type *delta_out; /* delta */\ + struct neurons_##type *prev_layer;\ + struct neurons_##type *next_layer;\ + void (*TensorContraction)(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1, size_t contractionNumber, size_t nbthread);/* nbthread is ignored if not required ! */\ + void (*TensorProduct)(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1, size_t nbthread);/* nbthread is ignored if not required ! */\ + type (*dL)(type t, type o);\ + type (*L)(type t, type o);\ + type (*f_act)(type x);\ + type (*d_f_act)(type x);\ +};\ +typedef struct neurons_##type neurons_##type;\ +\ +struct func_act_##type {\ + type (*func_act)(type x); /* function activation */\ + type (*deriv_func_act)(type x); /* derivate func act */\ +};\ +\ +void do_not_update_learnig_rate_##type(neurons_##type *N);\ +void time_based_update_learning_rate_##type(neurons_##type *nr);\ +void step_based_update_learning_rate_##type(neurons_##type *nr);\ +void setup_learning_rate_params_neurons_##type(neurons_##type *base,type initial_learning_rate, type decay_rate, size_t drop_rate, void (*update_learning_rate)(neurons_##type *));\ +/*void calc_net_neurons_##type(neurons_##type *nr);*/\ +void calc_out_neurons_##type(neurons_##type *nr);\ +void calc_delta_neurons_##type(neurons_##type *nr);\ +void update_weight_neurons_##type(neurons_##type *nr);\ +/*void setup_networks_##type(neurons_##type **base_nr, size_t **array_dim_in_layers, size_t *tab_sz_layers, size_t nb_layers);*/\ +void init_copy_in_out_networks_from_tensors_##type(neurons_##type *nr, tensor_##type *input, tensor_##type *target);\ +void init_in_out_networks_from_tensors_##type(neurons_##type *nr, tensor_##type *input, tensor_##type *target, neurons_##type *base);\ +void init_in_out_all_networks_##type(neurons_##type *nr, tensor_##type *in, tensor_##type *out);\ +void setup_networks_alloutputs_GLOBAL_rdm01_##type(neurons_##type **base_nr, size_t **array_dim_in_layers, size_t *sz_layers, size_t nb_layers);\ +void setup_networks_alloutputs_##type(neurons_##type **base_nr, size_t **array_dim_in_layers, size_t *sz_layers, size_t nb_layers, bool randomize, type minR, type maxR, int randomRange);\ +void setup_networks_alloutputs_config_##type(neurons_##type **base_nr, config_layers *lconf, bool randomize, type minR, type maxR, int randomRange);\ +void setup_networks_layers_without_weights_##type(neurons_##type **base_nr, size_t **array_dim_in_layers, size_t *sz_layers, size_t nb_layers);\ +void setup_networks_layers_without_weights_from_config_##type(neurons_##type **base, config_layers *pconf);\ +void setup_networks_OneD_##type(neurons_##type **base_nr, size_t *array_dim_in_layers, size_t nb_layers, bool randomize, type minR, type maxR, int randomRange);\ +void init_in_out_all_networks_OneD_##type(neurons_##type *nr, type *in, size_t sz_in, type *out, size_t sz_out);\ +void print_neurons_msg_##type(neurons_##type *nr, char * msg);\ +\ +void free_neurons_##type(neurons_##type *base);\ +\ +void setup_all_layers_functions_##type(neurons_##type *base, \ + void (*TensorContraction)(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1, size_t contractionNumber, size_t nbthread),/* nbthread is ignored if not required ! */\ + void (*TensorProduct)(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1, size_t nbthread),/* nbthread is ignored if not required ! */\ + type (*dL)(type t, type o),\ + type (*L)(type t, type o),\ + type (*f_act)(type x),\ + type (*d_f_act)(type x)\ +);\ +void setup_all_layers_params_##type(neurons_##type *base,\ + size_t nb_prod_thread,\ + size_t nb_calc_thread,\ + type learning_rate);\ +type error_out_##type(neurons_##type *base);\ +struct data_set_##type{\ + size_t size;\ + tensor_##type **input;\ + tensor_##type **target;\ +};\ +typedef struct data_set_##type data_set_##type;\ +void free_data_set_##type(data_set_##type *ds);\ +data_set_##type* fill_data_set_from_file_##type(char * file_input, size_t pivotSplit);\ +void print_data_set_msg_##type(data_set_##type *ds, char *msg);\ +\ +size_t learning_online_neurons_##type(neurons_##type *base, data_set_##type *dataset, bool (*condition)(type, size_t));\ +size_t learning_online2_neurons_##type(neurons_##type *base, data_set_##type *dataset, bool (*condition)(type, size_t));\ +\ +void print_predict_by_network_neurons_##type(neurons_##type *base, tensor_##type *input);\ +void print_predict_by_network_with_error_neurons_##type(neurons_##type *base, tensor_##type *input, tensor_##type *target);\ +\ +struct cloneuronset_##type{\ + size_t nb_clone;\ + config_layers *conf;\ + neurons_##type *base;\ + neurons_##type **cloneurons;\ +};\ +typedef struct cloneuronset_##type cloneuronset_##type;\ +void free_cloneuronset_##type(cloneuronset_##type *clnrnst);\ +cloneuronset_##type * create_cloneuronset_from_base_conf_##type(neurons_##type *base, config_layers *conf, size_t nb_clone);\ +size_t learning_cloneuronset_##type(cloneuronset_##type *clnrnst, data_set_##type *dataset, bool (*condition)(type, size_t));\ + +GEN_NEURON_(TYPE_FLOAT) +GEN_NEURON_(TYPE_DOUBLE) + + +#endif /*__NEURON_T_C__H*/ diff --git a/neuron_t/include_neurons/include/permutation_t/permutation_t.h b/neuron_t/include_neurons/include/permutation_t/permutation_t.h new file mode 100644 index 0000000..ba6f6e7 --- /dev/null +++ b/neuron_t/include_neurons/include/permutation_t/permutation_t.h @@ -0,0 +1,54 @@ +#ifndef __PERMUTATION_T_C_H__ +#define __PERMUTATION_T_C_H__ + +#include "tools_t/tools_t.h" +#include "set_theoric_t/set_theoric_t.h" + +/* struct of permutation, not necessarly set_theoric + * + * */ + + + +#define GENERATE_PERMUTATION(type)\ + struct PERMUTATION_##type{\ + size_t size;\ + size_t rank;\ + type * perm; \ + };\ +\ + typedef struct PERMUTATION_##type PERMUTATION_##type;\ + PERMUTATION_##type * CREATE_PERMUTATION_##type(size_t size);\ + PERMUTATION_##type * INIT_PERMUTATION_##type(type *perm, size_t size);\ + PERMUTATION_##type * INIT_COPY_PERMUTATION_##type(type *perm, size_t size);\ + void free_permut_##type(PERMUTATION_##type * permut);\ + PERMUTATION_TYPE_SIZE_T * TRANSLATE_TO_SET_THEORIC_SIZE_T_##type(const PERMUTATION_##type *p );\ + bool IS_PERMUTATION_##type(const PERMUTATION_##type *p );\ +size_t TabToPlaceAlgo_##type(const PERMUTATION_##type *p);\ +size_t TabToPlaceOpt1_##type(const PERMUTATION_##type *p);\ +size_t TabToPlaceNotab_##type(const PERMUTATION_##type *p);\ +PERMUTATION_TYPE_SIZE_T * PlaceToTab_##type(PERMUTATION_##type *p, size_t pl);\ + +GENERATE_PERMUTATION(TYPE_SIZE_T) +GENERATE_PERMUTATION(TYPE_CHAR) +GENERATE_PERMUTATION(TYPE_U_CHAR) +GENERATE_PERMUTATION(TYPE_INT) +GENERATE_PERMUTATION(TYPE_U_INT) +GENERATE_PERMUTATION(TYPE_L_INT) +GENERATE_PERMUTATION(TYPE_U_L_INT) +GENERATE_PERMUTATION(TYPE_FLOAT) +GENERATE_PERMUTATION(TYPE_DOUBLE) +GENERATE_PERMUTATION(TYPE_L_DOUBLE) +GENERATE_PERMUTATION(TYPE_STRING) + +#define GENERATE_FUNCTIONS_UNSIGNED(type)\ + bool IS_PERMUTATION_SET_THEORIC_##type(const PERMUTATION_##type *p);\ + +GENERATE_FUNCTIONS_UNSIGNED(TYPE_U_CHAR) +GENERATE_FUNCTIONS_UNSIGNED(TYPE_U_INT) +GENERATE_FUNCTIONS_UNSIGNED(TYPE_U_L_INT) +GENERATE_FUNCTIONS_UNSIGNED(TYPE_SIZE_T) + + + +#endif /*__PERMUTATION_T_C_H__*/ diff --git a/neuron_t/include_neurons/include/set_theoric_t/set_theoric_t.h b/neuron_t/include_neurons/include/set_theoric_t/set_theoric_t.h new file mode 100644 index 0000000..a13122c --- /dev/null +++ b/neuron_t/include_neurons/include/set_theoric_t/set_theoric_t.h @@ -0,0 +1,24 @@ +#ifndef __SET_THEORIC_T_C__H +#define __SET_THEORIC_T_C__H + +#include + +#include "tools_t/tools_t.h" + +#define GENERATE_UNSIGNED_SET_THEORIC(type) \ + struct SET_THEORIC_##type{ \ + type id; \ + type *set; \ + }; \ + typedef struct SET_THEORIC_##type SET_THEORIC_##type; \ + SET_THEORIC_##type * CREATE_SET_THEORIC_##type(size_t id/*TYPE_##type*/); \ + bool IS_SET_THEORIC_##type(SET_THEORIC_##type *st); \ + +GENERATE_UNSIGNED_SET_THEORIC(TYPE_U_CHAR) +GENERATE_UNSIGNED_SET_THEORIC(TYPE_U_INT) +GENERATE_UNSIGNED_SET_THEORIC(TYPE_U_L_INT) +GENERATE_UNSIGNED_SET_THEORIC(TYPE_SIZE_T) + + + +#endif /*__SET_THEORIC_T_C__H*/ diff --git a/neuron_t/include_neurons/include/tensor_t/cl_tensor_t.h b/neuron_t/include_neurons/include/tensor_t/cl_tensor_t.h new file mode 100644 index 0000000..71f18e0 --- /dev/null +++ b/neuron_t/include_neurons/include/tensor_t/cl_tensor_t.h @@ -0,0 +1,28 @@ +#ifndef __CL_TENSOR_T__H__ +#define __CL_TENSOR_T__H__ + +#include +#include + +#define CL_TARGET_OPENCL_VERSION 300 + +#ifdef __APPLE__ +#include +#else +#include +#endif + +#include "tensor_t/tensor_t.h" + + +#define CL_GENERATE_TENSOR_TYPE(type) \ +void cl_tensorProd_##type(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1); \ +void cl_tensorContractnProd_##type(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1, size_t contractionNumber); \ +void cl2d_tensorProd_##type(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1, size_t div0Wsz, size_t div1Wsz); \ +void cl2d_tensorContractnProd_##type(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1, size_t contractionNumber, size_t div0Wsz, size_t div1Wsz); \ + +CL_GENERATE_TENSOR_TYPE(TYPE_FLOAT); +CL_GENERATE_TENSOR_TYPE(TYPE_DOUBLE); + + +#endif /* __CL_TENSOR_T__H__ */ diff --git a/neuron_t/include_neurons/include/tensor_t/tensor_t.h b/neuron_t/include_neurons/include/tensor_t/tensor_t.h new file mode 100644 index 0000000..38694c1 --- /dev/null +++ b/neuron_t/include_neurons/include/tensor_t/tensor_t.h @@ -0,0 +1,85 @@ +#ifndef __TENSOR_T__H__ +#define __TENSOR_T__H__ + +#include +#include +#include + +#include "dimension_t/dimension_t.h" + +void subArray(size_t* dst, size_t* src, size_t debDst, size_t finDst, size_t debSrc); + +#define GENERATE_TENSOR_TYPE(type) \ +struct tensor_##type{\ + dimension *dim;\ + type *x;\ +};\ +typedef struct tensor_##type tensor_##type;\ +tensor_##type * CREATE_TENSOR_##type(dimension *dim); \ +tensor_##type* CREATE_TENSOR_FROM_CPY_DIM_##type(dimension *dim);\ +void _RECREATE_TENSOR_IF_NOT_THE_SAME_DIM_OR_NULL_##type(tensor_##type **M, dimension *dd);\ +tensor_##type* CLONE_TENSOR_##type(tensor_##type *tens);\ +void free_tensor_##type(tensor_##type * tens); \ +tensor_##type * sub_minus_tensor_head_##type(tensor_##type *rootens, size_t minuSubdim, size_t rankInDim); \ +tensor_##type * sub_minus_tensor_tail_##type(tensor_##type *rootens, size_t minuSubdim, size_t rankInDim); \ +tensor_##type * sub_tensor_head_##type(tensor_##type *rootens, size_t subdim, size_t rankInDim); \ +tensor_##type * sub_tensor_tail_##type(tensor_##type *rootens, size_t subdim, size_t rankInDim); \ +tensor_##type * sub_copy_minus_tensor_head_##type(tensor_##type *rootens, size_t minuSubdim, size_t rankInDim); \ +tensor_##type * sub_copy_minus_tensor_tail_##type(tensor_##type *rootens, size_t minuSubdim, size_t rankInDim); \ +tensor_##type * sub_copy_tensor_head_##type(tensor_##type *rootens, size_t sub_copydim, size_t rankInDim); \ +tensor_##type * sub_copy_tensor_tail_##type(tensor_##type *rootens, size_t sub_copydim, size_t rankInDim); \ +void print_tensor_msg_##type(tensor_##type *T, char *msg);\ +void fprint_tensor_##type(char *file_name, tensor_##type *T);\ +size_t sprint_tensor_##type(char **tensorContent,tensor_##type *T, bool withIndex);\ +void split_tensor_##type(tensor_##type *Troot, tensor_##type **Tpart1, tensor_##type **Tpart2, size_t pivotSplit, size_t rangeInPivot);\ +void split_copy_tensor_##type(tensor_##type *Troot, tensor_##type **Tpart1, tensor_##type **Tpart2, size_t pivotSplit, size_t rangeInPivot);\ +void tensorProdNotOpt_##type(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1); \ +void tensorProd_##type(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1); \ +void tensorContractnProd_##type(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1, size_t contractionNumber); \ +void tensorProdThread_##type(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1,size_t nbthread); \ +void tensorProdThrea2d_##type(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1,size_t nbthread); \ +void tensorContractnProdThread_##type(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1, size_t contractionNumber, size_t nbthread); \ +void tensorContractnPro2dThread_##type(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1, size_t contractionNumber, size_t nbthread); \ +void tensorContractnProdNotOpt_##type(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1, size_t contractionNumber); \ +void init_random_x_##type(tensor_##type *M, type minR, type maxR, int randomRange);\ +tensor_##type * parseInput_withDim_to_tensor_##type(char *input);\ +void parseInputOutput_withDim_to_tensors_##type(tensor_##type **Tpart1, tensor_##type **Tpart2, char *input, size_t pivotSplit);\ +void parse_file_InputOutput_withDim_to_tensors_##type(tensor_##type **Tpart1, tensor_##type **Tpart2, char *file_name_input, size_t pivotSplit);\ +tensor_##type ** fromInput_to_array_tensor_##type(tensor_##type *tens);\ +struct array_chainlist_##type{\ + size_t index;\ + type x;\ + struct array_chainlist_##type *next;\ +};\ +typedef struct array_chainlist_##type array_chainlist_##type;\ +void append_array_chainlist_##type(array_chainlist_##type **list_a, type x);\ +tensor_##type * create_tensor_from_list_array_##type( array_chainlist_##type *l_a, dimension *part_dim);\ +void free_array_chainlist_##type(array_chainlist_##type *l_a);\ +tensor_##type * transpose_notOpt_tensor_##type(tensor_##type *org);\ +tensor_##type * permute_notOpt_tensor_##type(tensor_##type *org, dimension *dperm);\ +void update_1tensor_func_##type(tensor_##type *M0, \ + type (*func)(type), size_t nbthread);\ +void update_2tensor_func_##type(tensor_##type *M0, tensor_##type *M1, \ + type (*func)(type), size_t nbthread);\ +void update_3tensor_func_##type(tensor_##type *M0, tensor_##type *M1, tensor_##type *M2, \ + type (*func)(type, type), size_t nbthread);\ +void update_4tensor_func_##type(tensor_##type *M0, tensor_##type *M1, tensor_##type *M2, \ + type (*func)(type, type, type(*f1)(type)),\ + type(*f1)(type),\ + size_t nbthread);\ +void update_5tensor_func_##type(tensor_##type *M0, tensor_##type *M1, tensor_##type *M2, tensor_##type *M3 , \ + type (*func) (type, type, type, type(*f1)(type), type (*f2)(type,type)), \ + type(*f1)(type), \ + type (*f2)(type,type), \ + size_t nbthread);\ +void update_6tensor_func_##type(tensor_##type *M0, tensor_##type *M1, \ + type (*func)(type, type, type),\ + type scalar,\ + size_t nbthread);\ + + +GENERATE_TENSOR_TYPE(TYPE_FLOAT); +GENERATE_TENSOR_TYPE(TYPE_DOUBLE); + + +#endif /* __TENSOR_T__H__ */ diff --git a/neuron_t/test/c_launch b/neuron_t/test/c_launch new file mode 100644 index 0000000000000000000000000000000000000000..c1e610d726069cd69e7ee6c9c80b432d04f6d0d3 GIT binary patch literal 31504 zcmeHQdwkT@mA?r@sG25Nrz?mss8OsELwGDuksu5X-5}w$MT-nWW`?9DlXNn{;Hr(% zv`MG4OIxYfbyw_5K7DQ4+7?_N!3T-;h1R;X>KbXS$)W{=?$V0Re!uten>)YEFMVwP z+E4E1Gjr}a_ndRjJ@?-8``zDf=H5>Ss+ScO6bO^Xh|2}B-RCPxl`g1h(HVd$F;5iZ zd#acsP60kv(o}hs0w`7KP+=|{ujyj|DR&k#dEjJ476uv%2`T55#-FK53>2jbr(6-U zetseO<+lTOPE)vnww$c5M)SL14IO}Fpe@IuiVd<@R5awme%_h-9@=(E!V8& z4D@S%8fg4UHT=xedfl)BWlRRTNn4weQ85vMniqPwQWY*yty;x&Mt3h zDzB8~w9AhV$JCWqtrO^$9@4ZrQP{3~xJByy)f5C&N zR)6;UGN-b#WRIr#2I-?`(Q{u`V0^L&wJ2mw?B{m%RKZ)(fEAz zKH))M<54f;Og=q7g)RB$+dT9vLj&^h-{GO>N)J81_ptx>9{MME@Q?M-zsQ4r4(#;f z<4)Il_-C_+J&$!CQGe_|f?Ec4($#Y6vP9)9Tb;Qyuv{X7r)cRlof*@J$_L(iax zKUaA8;WiKcqzC^c@S7hWcls3w`TRf0Lr(|zCx}U6TC>uG=E!sn_(`9x>E?RzD(ob^ z%0-_7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eq~#06QSiR;q?d(@@U1W zAH%yU?|CJ84;`r;;fxn`1jGo9%pGcI>}=P|Rr}>EB4fnN_uQBueKk}32`ADhcbW4y zT!+4dLYrG!)JYdYzFz)Q&N*?N$svc4(=3cR`;-&uE6+1s6Pz<5jjqBUw@nE z;&Dof=jkd=ZC(~Ht8n4P&YD4!sJm^xUn9}lsG1uD93G4Bkp$0-PT_W`MjF<{8&!Q z#B=MI3^dQH6;<(?JR$EVaf|85&(rb-R*=a`&i$dL%>}gO`5Of$1J75e^KI69hQQ}+ zw!C@HXQ1COYUq~#IOzDpev@gxc@A&jQZ0vNhD>hz!=UmRypcbl?KiMbS4bP_XCrT( zm)C?Q($m&?&Th_c)sK4&yEFcb zp0`j^V#%B5`gI$Wh~YB|3~u0iDB##N^_%D0<~&}%wx9El$;g?0{0?aJpOH83`F3n1 zxBC5&%BgQ7Zy-1Bv*n%Vf14D)smJIrat1#g!laq{{moi#lY)8}CPhCp{t8!dDSKf#2&r?Lc;zndE*C*jqT(!X@G$l=_*%)O}(m=&pz_Y O&rK+fNiG2wD*hK_EZ-FX literal 0 HcmV?d00001 diff --git a/neuron_t/test/compile_with_libneurons.sh b/neuron_t/test/compile_with_libneurons.sh new file mode 100644 index 0000000..755136a --- /dev/null +++ b/neuron_t/test/compile_with_libneurons.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +gcc -o c_launch is_good.c -I../include_neurons/include/ -L.. -L../../ytest_t/ -lneurons -lytest -lpthread -lm diff --git a/neuron_t/test/run_c.sh b/neuron_t/test/run_c.sh new file mode 100644 index 0000000..ebd46c8 --- /dev/null +++ b/neuron_t/test/run_c.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +LD_LIBRARY_PATH=..:../../ytest_t/ ./c_launch