From 39ced589caf1b266532e85df2e11196badfa441e Mon Sep 17 00:00:00 2001 From: czgdp1807 Date: Sat, 27 Mar 2021 20:50:59 +0530 Subject: [PATCH 1/2] Layer Addition started --- bnn/nn/activations.hpp | 22 ++++++++++++++++++++++ bnn/nn/layers.hpp | 22 ++++++++++++++++++++++ bnn/nn/layers_impl.hpp | 0 bnn/operations/operators.hpp | 1 - bnn/templates/nn/activations.hpp | 0 bnn/templates/nn/layers.hpp | 0 6 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 bnn/nn/activations.hpp create mode 100644 bnn/nn/layers.hpp create mode 100644 bnn/nn/layers_impl.hpp create mode 100644 bnn/templates/nn/activations.hpp create mode 100644 bnn/templates/nn/layers.hpp diff --git a/bnn/nn/activations.hpp b/bnn/nn/activations.hpp new file mode 100644 index 0000000..1a175f2 --- /dev/null +++ b/bnn/nn/activations.hpp @@ -0,0 +1,22 @@ +#ifndef BNN_BNN_NN_ACTIVATIONS_HPP +#define BNN_BNN_NN_ACTIVATIONS_HPP + +#include + +namespace bnn +{ + namespace nn + { + + using namespace bnn::utils; + + template + class Layer: public BNNBase + { + + }; + + } +} + +#endif diff --git a/bnn/nn/layers.hpp b/bnn/nn/layers.hpp new file mode 100644 index 0000000..d1f03fb --- /dev/null +++ b/bnn/nn/layers.hpp @@ -0,0 +1,22 @@ +#ifndef BNN_BNN_NN_LAYERS_HPP +#define BNN_BNN_NN_LAYERS_HPP + +#include + +namespace bnn +{ + namespace nn + { + + using namespace bnn::utils; + + template + class Layer: public BNNBase + { + + }; + + } +} + +#endif diff --git a/bnn/nn/layers_impl.hpp b/bnn/nn/layers_impl.hpp new file mode 100644 index 0000000..e69de29 diff --git a/bnn/operations/operators.hpp b/bnn/operations/operators.hpp index 41a6365..00860fb 100644 --- a/bnn/operations/operators.hpp +++ b/bnn/operations/operators.hpp @@ -2,7 +2,6 @@ #define BNN_BNN_OPERATIONS_OPERATORS_HPP #include -#include #include #include diff --git a/bnn/templates/nn/activations.hpp b/bnn/templates/nn/activations.hpp new file mode 100644 index 0000000..e69de29 diff --git a/bnn/templates/nn/layers.hpp b/bnn/templates/nn/layers.hpp new file mode 100644 index 0000000..e69de29 From 0667dbfe303f7d0a1016acf70291fe9410626ac5 Mon Sep 17 00:00:00 2001 From: czgdp1807 Date: Sun, 28 Mar 2021 21:33:31 +0530 Subject: [PATCH 2/2] Added interface for layers and activations --- bnn/nn/activations.hpp | 36 +++++++++++++++++++++++++++++++- bnn/nn/layers.hpp | 47 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 1 deletion(-) diff --git a/bnn/nn/activations.hpp b/bnn/nn/activations.hpp index 1a175f2..32c05ec 100644 --- a/bnn/nn/activations.hpp +++ b/bnn/nn/activations.hpp @@ -2,6 +2,7 @@ #define BNN_BNN_NN_ACTIVATIONS_HPP #include +#include namespace bnn { @@ -9,11 +10,44 @@ namespace bnn { using namespace bnn::utils; + using namespace bnn::operators; template - class Layer: public BNNBase + class Activation: public BNNBase { + protected: + + std::string name; + + Operator* input; + + Operator* output; + + public: + + Activation + (std::string _name); + + virtual + void + implementation + (); + + virtual + TensorCPU* + get_input_value + (); + + virtual + TensorCPU* + get_output_value + (); + + virtual + ~Activation + (); + }; } diff --git a/bnn/nn/layers.hpp b/bnn/nn/layers.hpp index d1f03fb..6cb6ebf 100644 --- a/bnn/nn/layers.hpp +++ b/bnn/nn/layers.hpp @@ -2,6 +2,9 @@ #define BNN_BNN_NN_LAYERS_HPP #include +#include +#include +#include namespace bnn { @@ -9,11 +12,55 @@ namespace bnn { using namespace bnn::utils; + using namespace bnn::core; + using namespace bnn::operators; template class Layer: public BNNBase { + protected: + + std::string name; + + Operator* input; + + Operator* output; + + public: + + Layer + (std::string _name); + + virtual + void + initialize_parameters + (void (*initializer)(Operator* parameters)); + + virtual + void + implementation + (); + + virtual + Operator* + get_parameters + (); + + virtual + TensorCPU* + get_input_value + (); + + virtual + TensorCPU* + get_output_value + (); + + virtual + ~Layer + (); + }; }