b9053914d08d0cdb892f0091816fdb2a664e7eed
[platform/core/ml/nnfw.git] / runtime / onert / core / include / ir / Padding.h
1 /*
2  * Copyright (c) 2020 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 #ifndef __ONERT_IR_PADDIGN_H__
18 #define __ONERT_IR_PADDIGN_H__
19
20 #include "Shape.h"
21 #include "InternalType.h"
22
23 #include <cstdint>
24 #include <string>
25
26 namespace onert
27 {
28 namespace ir
29 {
30
31 enum class PaddingType
32 {
33   EXPLICIT = 0,
34   SAME = 1,
35   VALID = 2
36 };
37
38 /**
39  * @brief     Converts a internal padding type to const char*
40  * @param[in] type  Padding type to be converted
41  * @return    A string holding the converted value
42  */
43 inline std::string to_string(const PaddingType type);
44
45 struct ExplicitPadding
46 {
47   uint32_t left;
48   uint32_t right;
49   uint32_t top;
50   uint32_t bottom;
51 };
52
53 // TODO Resolve explicit padding param at frontend and save in value field
54 struct Padding
55 {
56   Padding(void);
57   Padding(PaddingType paddingType);
58   Padding(uint32_t left, uint32_t right, uint32_t top, uint32_t bottom);
59
60   // TODO Change to private field
61   PaddingType type;
62   ExplicitPadding param;
63 };
64
65 // TODO Change to Padding struct's method
66 const ExplicitPadding calculatePadding(const Padding &padding, const FeatureShape &ifm_shape,
67                                        const FeatureShape &ofm_shape, const Stride &stride,
68                                        uint32_t kw, uint32_t kh);
69
70 } // namespace ir
71 } // namespace onert
72
73 #endif