Skip to content

Commit

Permalink
[GPU/OpenCL] Initial version of Concat Layer with OpenCL ops
Browse files Browse the repository at this point in the history
Added naive version of OpenCL implementation for Concat Layer.
Incorporated kernel for ops used.
Added unit test for Concat_cl.

Signed-off-by: Niket Agarwal <[email protected]>
  • Loading branch information
niket-agarwal committed Jul 3, 2024
1 parent 6f98e73 commit 904849a
Show file tree
Hide file tree
Showing 9 changed files with 798 additions and 18 deletions.
11 changes: 6 additions & 5 deletions api/ccapi/include/layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,18 +366,19 @@ Reshape(const std::vector<std::string> &properties = {}) {
/**
* @brief Helper function to create addition layer
*/
inline std::unique_ptr<Layer> Addition(
const std::vector<std::string> &properties = {},
const LayerComputeEngine &compute_engine = LayerComputeEngine::CPU) {
inline std::unique_ptr<Layer>
Addition(const std::vector<std::string> &properties = {},
const LayerComputeEngine &compute_engine = LayerComputeEngine::CPU) {
return createLayer(LayerType::LAYER_ADDITION, properties, compute_engine);
}

/**
* @brief Helper function to create concat layer
*/
inline std::unique_ptr<Layer>
Concat(const std::vector<std::string> &properties = {}) {
return createLayer(LayerType::LAYER_CONCAT, properties);
Concat(const std::vector<std::string> &properties = {},
const LayerComputeEngine &compute_engine = LayerComputeEngine::CPU) {
return createLayer(LayerType::LAYER_CONCAT, properties, compute_engine);
}

/**
Expand Down
6 changes: 5 additions & 1 deletion nntrainer/cl_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @date 23 Feb 2024
* @see https://github.com/nnstreamer/nntrainer
* @author Debadri Samaddar <[email protected]>
* @author Niket Agarwal <[email protected]>
* @author Niket Agarwal <[email protected]>
* @bug No known bugs except for NYI items
* @brief This file contains app context related functions and classes that
* manages the global configuration of the current OpenCL environment. It also
Expand All @@ -15,6 +15,7 @@

#include <addition_layer_cl.h>
#include <cl_context.h>
#include <concat_cl.h>
#include <fc_layer_cl.h>
#include <swiglu_cl.h>

Expand All @@ -36,6 +37,9 @@ static void add_default_object(ClContext &cc) {

cc.registerFactory(nntrainer::createLayer<SwiGLULayerCl>, SwiGLULayerCl::type,
ml::train::LayerType::LAYER_SWIGLU);

cc.registerFactory(nntrainer::createLayer<ConcatLayerCl>, ConcatLayerCl::type,
ml::train::LayerType::LAYER_CONCAT);
}

static void registerer(ClContext &cc) noexcept {
Expand Down
Loading

0 comments on commit 904849a

Please sign in to comment.