Imported Upstream version 1.25.0
[platform/core/ml/nnfw.git] / runtime / onert / backend / train / ops / PoolLayer.cc
1 /*
2  * Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "PoolLayer.h"
18
19 namespace onert
20 {
21 namespace backend
22 {
23 namespace train
24 {
25 namespace ops
26 {
27
28 PoolLayer::PoolLayer() : cpu::ops::PoolLayer()
29 {
30   // DO NOTHING
31 }
32
33 void PoolLayer::configure(const IPortableTensor *input, const uint32_t paddingLeft,
34                           const uint32_t paddingRight, const uint32_t paddingTop,
35                           const uint32_t paddingBottom, const uint32_t strideWidth,
36                           const uint32_t strideHeight, const uint32_t kernelWidth,
37                           const uint32_t kernelHeight, const ir::Activation activation,
38                           IPortableTensor *output, const PoolType op_type)
39 {
40   switch (op_type)
41   {
42     case PoolType::kMax:
43       cpu::ops::PoolLayer::configure(input, paddingLeft, paddingRight, paddingTop, paddingBottom,
44                                      strideWidth, strideHeight, kernelWidth, kernelHeight,
45                                      activation, output, cpu::ops::PoolType::kMax);
46       break;
47     default:
48       throw std::runtime_error("PoolLayer: Unsupported pool type");
49   }
50 }
51
52 void PoolLayer::forward(bool training)
53 {
54   if (training)
55   {
56     // TODO Implement training pool layer
57   }
58   else
59   {
60     cpu::ops::PoolLayer::run();
61   }
62 }
63
64 void PoolLayer::backward()
65 {
66   // TODO Implement detail
67 }
68
69 } // namespace ops
70 } // namespace train
71 } // namespace backend
72 } // namespace onert