From da0c39da054c7b015864667adc0d63ee19ed7754 Mon Sep 17 00:00:00 2001 From: "jijoong.moon" Date: Tue, 16 Jun 2020 13:08:05 +0900 Subject: [PATCH] [ Layer copy ] copy function for conv2d & pooling This PR fixs the copy member function of covn2d and pooling layer. . include copy of layer varaibles for conv2d . implemnet copy of pooling2d layer **Self evaluation:** 1. Build test: [X]Passed [ ]Failed [ ]Skipped 2. Run test: [X]Passed [ ]Failed [ ]Skipped Signed-off-by: jijoong.moon --- nntrainer/include/pooling2d_layer.h | 9 --------- nntrainer/src/conv2d_layer.cpp | 6 ++++++ nntrainer/src/pooling2d_layer.cpp | 23 ++++++++++++++++------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/nntrainer/include/pooling2d_layer.h b/nntrainer/include/pooling2d_layer.h index e8525dc..47ec23d 100644 --- a/nntrainer/include/pooling2d_layer.h +++ b/nntrainer/include/pooling2d_layer.h @@ -127,15 +127,6 @@ public: void copy(std::shared_ptr l); /** - * @brief set Parameter Size - * @param[in] * size : size arrary - * @param[in] type : Property type - * @retval #ML_ERROR_NONE Successful. - * @retval #ML_ERROR_INVALID_PARAMETER invalid parameter. - */ - int setSize(int *size, PropertyType type); - - /** * @brief set Property of layer * @param[in] values values of property * @retval #ML_ERROR_NONE Successful. diff --git a/nntrainer/src/conv2d_layer.cpp b/nntrainer/src/conv2d_layer.cpp index 81aee9a..0618218 100644 --- a/nntrainer/src/conv2d_layer.cpp +++ b/nntrainer/src/conv2d_layer.cpp @@ -127,6 +127,12 @@ void Conv2DLayer::copy(std::shared_ptr l) { this->filters.push_back(from->filters[i]); this->bias.push_back(from->bias[i]); } + this->input.copy(from->input); + this->hidden.copy(from->hidden); + this->dim = from->dim; + this->input_dim = from->input_dim; + this->output_dim = from->output_dim; + this->last_layer = from->last_layer; } int Conv2DLayer::setSize(int *size, nntrainer::Conv2DLayer::PropertyType type) { diff --git a/nntrainer/src/pooling2d_layer.cpp b/nntrainer/src/pooling2d_layer.cpp index 56d6143..237f706 100644 --- a/nntrainer/src/pooling2d_layer.cpp +++ b/nntrainer/src/pooling2d_layer.cpp @@ -65,14 +65,23 @@ Tensor Pooling2DLayer::backwarding(Tensor in, int iteration) { } void Pooling2DLayer::copy(std::shared_ptr l) { - // NYI -} + std::shared_ptr from = + std::static_pointer_cast(l); -int Pooling2DLayer::setSize(int *size, - nntrainer::Pooling2DLayer::PropertyType type) { - int status = ML_ERROR_NONE; - // NYI - return status; + this->pooling_type = from->pooling_type; + + for (unsigned int i = 0; i < POOLING2D_DIM; ++i) { + this->pooling_size[i] = from->pooling_size[i]; + this->stride[i] = from->stride[i]; + this->padding[i] = from->padding[i]; + } + + this->input.copy(from->input); + this->hidden.copy(from->hidden); + this->dim = from->dim; + this->input_dim = from->input_dim; + this->output_dim = from->output_dim; + this->last_layer = from->last_layer; } int Pooling2DLayer::setProperty(std::vector values) { -- 2.7.4