From ea42bc2931f9cf15c062109c027832123245d37b Mon Sep 17 00:00:00 2001 From: Vincent TEMPLIER <vincent.templier@cea.fr> Date: Mon, 22 Jan 2024 10:48:21 +0000 Subject: [PATCH] Add aidge kernels for export forward --- .../Activation/Atan/aidge_atan_float32.c | 10 +++++++++ .../Activation/Relu/aidge_relu_float32.c | 12 +++++++++++ .../kernels/Concat/aidge_concat_float32.c | 9 ++++++++ .../kernels/ElemWise/Add/aidge_add_float32.c | 11 ++++++++++ .../kernels/ElemWise/Div/aidge_div_float32.c | 11 ++++++++++ .../kernels/ElemWise/Mul/aidge_mul_float32.c | 11 ++++++++++ .../kernels/ElemWise/Sub/aidge_sub_float32.c | 11 ++++++++++ .../kernels/FullyConnected/aidge_fc_float32.c | 21 +++++++++++++++++++ .../kernels/Slice/aidge_slice_float32.c | 11 ++++++++++ 9 files changed, 107 insertions(+) create mode 100644 aidge_export_arm_cortexm/kernels/Activation/Atan/aidge_atan_float32.c create mode 100644 aidge_export_arm_cortexm/kernels/Activation/Relu/aidge_relu_float32.c create mode 100644 aidge_export_arm_cortexm/kernels/Concat/aidge_concat_float32.c create mode 100644 aidge_export_arm_cortexm/kernels/ElemWise/Add/aidge_add_float32.c create mode 100644 aidge_export_arm_cortexm/kernels/ElemWise/Div/aidge_div_float32.c create mode 100644 aidge_export_arm_cortexm/kernels/ElemWise/Mul/aidge_mul_float32.c create mode 100644 aidge_export_arm_cortexm/kernels/ElemWise/Sub/aidge_sub_float32.c create mode 100644 aidge_export_arm_cortexm/kernels/FullyConnected/aidge_fc_float32.c create mode 100644 aidge_export_arm_cortexm/kernels/Slice/aidge_slice_float32.c diff --git a/aidge_export_arm_cortexm/kernels/Activation/Atan/aidge_atan_float32.c b/aidge_export_arm_cortexm/kernels/Activation/Atan/aidge_atan_float32.c new file mode 100644 index 0000000..469f3ae --- /dev/null +++ b/aidge_export_arm_cortexm/kernels/Activation/Atan/aidge_atan_float32.c @@ -0,0 +1,10 @@ +#include <math.h> + +void aidge_atan_float32 (float* input, + float* output, + unsigned int size) +{ + for (unsigned int i = 0; i < size; ++i) { + output[i] = atanf(input[i]); + } +} diff --git a/aidge_export_arm_cortexm/kernels/Activation/Relu/aidge_relu_float32.c b/aidge_export_arm_cortexm/kernels/Activation/Relu/aidge_relu_float32.c new file mode 100644 index 0000000..d25e6c1 --- /dev/null +++ b/aidge_export_arm_cortexm/kernels/Activation/Relu/aidge_relu_float32.c @@ -0,0 +1,12 @@ + + + +void aidge_relu_float32 (float* inputs, + float* outputs, + unsigned int size) +{ + for (unsigned int i = 0; i < size; ++i) { + if (inputs[i] < 0.0f) + outputs[i] = 0.0f; + } +} \ No newline at end of file diff --git a/aidge_export_arm_cortexm/kernels/Concat/aidge_concat_float32.c b/aidge_export_arm_cortexm/kernels/Concat/aidge_concat_float32.c new file mode 100644 index 0000000..c07337c --- /dev/null +++ b/aidge_export_arm_cortexm/kernels/Concat/aidge_concat_float32.c @@ -0,0 +1,9 @@ +#include <stdarg.h> + +void aidge_concat_float32 (unsigned int axis, + float* output, + float* input1, + float* input2) +{ + // TODO +} diff --git a/aidge_export_arm_cortexm/kernels/ElemWise/Add/aidge_add_float32.c b/aidge_export_arm_cortexm/kernels/ElemWise/Add/aidge_add_float32.c new file mode 100644 index 0000000..4250e6e --- /dev/null +++ b/aidge_export_arm_cortexm/kernels/ElemWise/Add/aidge_add_float32.c @@ -0,0 +1,11 @@ + + +void aidge_mul_float32(float* input_a, + float* input_b, + float* output, + unsigned int size) +{ + for (unsigned int i = 0; i < size; ++i) { + output[i] = input_a[i] + input_b[i]; + } +} \ No newline at end of file diff --git a/aidge_export_arm_cortexm/kernels/ElemWise/Div/aidge_div_float32.c b/aidge_export_arm_cortexm/kernels/ElemWise/Div/aidge_div_float32.c new file mode 100644 index 0000000..fed39b0 --- /dev/null +++ b/aidge_export_arm_cortexm/kernels/ElemWise/Div/aidge_div_float32.c @@ -0,0 +1,11 @@ + + +void aidge_mul_float32(float* input_a, + float* input_b, + float* output, + unsigned int size) +{ + for (unsigned int i = 0; i < size; ++i) { + output[i] = input_a[i] / input_b[i]; + } +} \ No newline at end of file diff --git a/aidge_export_arm_cortexm/kernels/ElemWise/Mul/aidge_mul_float32.c b/aidge_export_arm_cortexm/kernels/ElemWise/Mul/aidge_mul_float32.c new file mode 100644 index 0000000..28c22ab --- /dev/null +++ b/aidge_export_arm_cortexm/kernels/ElemWise/Mul/aidge_mul_float32.c @@ -0,0 +1,11 @@ + + +void aidge_mul_float32(float* input_a, + float* input_b, + float* output, + unsigned int size) +{ + for (unsigned int i = 0; i < size; ++i) { + output[i] = input_a[i] * input_b[i]; + } +} \ No newline at end of file diff --git a/aidge_export_arm_cortexm/kernels/ElemWise/Sub/aidge_sub_float32.c b/aidge_export_arm_cortexm/kernels/ElemWise/Sub/aidge_sub_float32.c new file mode 100644 index 0000000..1f4f7d7 --- /dev/null +++ b/aidge_export_arm_cortexm/kernels/ElemWise/Sub/aidge_sub_float32.c @@ -0,0 +1,11 @@ + + +void aidge_sub_float32(float* input_a, + float* input_b, + float* output, + unsigned int size) +{ + for (unsigned int i = 0; i < size; ++i) { + output[i] = input_a[i] - input_b[i]; + } +} \ No newline at end of file diff --git a/aidge_export_arm_cortexm/kernels/FullyConnected/aidge_fc_float32.c b/aidge_export_arm_cortexm/kernels/FullyConnected/aidge_fc_float32.c new file mode 100644 index 0000000..a38efab --- /dev/null +++ b/aidge_export_arm_cortexm/kernels/FullyConnected/aidge_fc_float32.c @@ -0,0 +1,21 @@ + + +void aidge_fc_float32 (float* inputs, + float* weights, + float* biases, + float* outputs, + unsigned int nb_inputs, + unsigned int nb_outputs) +{ + for (unsigned int out = 0; out < nb_outputs; ++out) { + // Init with bias + float accum = biases[out]; + + for (unsigned int in = 0; in < nb_inputs; ++in) { + accum += inputs[in] * weights[out * nb_inputs + in]; + } + + // Store result + outputs[out] = accum; + } +} diff --git a/aidge_export_arm_cortexm/kernels/Slice/aidge_slice_float32.c b/aidge_export_arm_cortexm/kernels/Slice/aidge_slice_float32.c new file mode 100644 index 0000000..2be1346 --- /dev/null +++ b/aidge_export_arm_cortexm/kernels/Slice/aidge_slice_float32.c @@ -0,0 +1,11 @@ + + +void aidge_slice_float32 (float* inputs, + float* outputs, + int* axes, + int* starts, + int* ends, + unsigned int nb_axes) +{ + +} \ No newline at end of file -- GitLab