Skip to content
Snippets Groups Projects
Commit 670fb293 authored by Olivier BICHLER's avatar Olivier BICHLER
Browse files

Use macro helper for registrar

parent dcbeb57f
No related branches found
No related tags found
2 merge requests!93Release v0.3.0,!79Refactor OperatorImpl for backend/export
Pipeline #53596 failed
...@@ -23,19 +23,17 @@ ...@@ -23,19 +23,17 @@
#include "aidge/utils/Types.h" #include "aidge/utils/Types.h"
namespace Aidge { namespace Aidge {
// Operator implementation entry point for the backend
using ReLUImpl_cpu = OperatorImpl_cpu<ReLU_Op, using ReLUImpl_cpu = OperatorImpl_cpu<ReLU_Op,
void(const std::size_t, const void*, void*), void(const std::size_t, const void*, void*),
void(const std::size_t, const void*, const void*, void*)>; void(const std::size_t, const void*, const void*, void*)>;
// class ReLUImpl_cpu : public OperatorImpl_cpu<ReLU_Op, // Implementation entry point registration to Operator
// void(const std::size_t, const void*, void*), REGISTRAR(ReLU_Op, "cpu", Aidge::ReLUImpl_cpu::create);
// void(const std::size_t, const void*, const void*, void*)>
// {
// public:
// void forward() override;
// void backward() override;
// };
////////////////////////////////////////////////////////////////////////////////
// Kernels
template <class I, class O> template <class I, class O>
void ReLUImpl_cpu_forward_kernel(std::size_t inputLenght, void ReLUImpl_cpu_forward_kernel(std::size_t inputLenght,
const void* input_, const void* input_,
...@@ -62,19 +60,16 @@ void ReLUImpl_cpu_backward_kernel(const std::size_t inputLenght, ...@@ -62,19 +60,16 @@ void ReLUImpl_cpu_backward_kernel(const std::size_t inputLenght,
} }
} }
namespace { // Kernels registration to implementation entry point
static Registrar<ReLU_Op> registrarReLUImpl_cpu("cpu", Aidge::ReLUImpl_cpu::create); REGISTRAR(ReLUImpl_cpu,
static Registrar<ReLUImpl_cpu> registrarReLUImpl_cpu_float(
{DataType::Float32}, {DataType::Float32},
{ProdConso::inPlaceModel, Aidge::ReLUImpl_cpu_forward_kernel<float, float>, Aidge::ReLUImpl_cpu_backward_kernel<float, float, float>}); {ProdConso::inPlaceModel, Aidge::ReLUImpl_cpu_forward_kernel<float, float>, Aidge::ReLUImpl_cpu_backward_kernel<float, float, float>});
static Registrar<ReLUImpl_cpu> registrarReLUImpl_cpu_double( REGISTRAR(ReLUImpl_cpu,
{DataType::Float64}, {DataType::Float64},
{ProdConso::inPlaceModel, Aidge::ReLUImpl_cpu_forward_kernel<double, double>, Aidge::ReLUImpl_cpu_backward_kernel<double, double, double>}); {ProdConso::inPlaceModel, Aidge::ReLUImpl_cpu_forward_kernel<double, double>, Aidge::ReLUImpl_cpu_backward_kernel<double, double, double>});
static Registrar<ReLUImpl_cpu> registrarReLUImpl_cpu_int( REGISTRAR(ReLUImpl_cpu,
{DataType::Int32}, {DataType::Int32},
{ProdConso::inPlaceModel, Aidge::ReLUImpl_cpu_forward_kernel<int, int>, Aidge::ReLUImpl_cpu_backward_kernel<int, int, int>}); {ProdConso::inPlaceModel, Aidge::ReLUImpl_cpu_forward_kernel<int, int>, Aidge::ReLUImpl_cpu_backward_kernel<int, int, int>});
}
} // namespace Aidge } // namespace Aidge
#endif /* AIDGE_CPU_OPERATOR_RELUIMPL_H_ */ #endif /* AIDGE_CPU_OPERATOR_RELUIMPL_H_ */
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