Imported Upstream version 1.9.0
[platform/core/ml/nnfw.git] / compiler / luci / lang / include / luci / IR / Nodes / CircleTransposeConv.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 __LUCI_IR_CIRCLETRANSPOSECONV_H__
18 #define __LUCI_IR_CIRCLETRANSPOSECONV_H__
19
20 #include "luci/IR/CircleNodeDecl.h"
21 #include "luci/IR/CircleOpcode.h"
22
23 #include "luci/IR/AttrPadding.h"
24 #include "luci/IR/AttrStride.h"
25 #include "luci/IR/LuciNodeMixins.h"
26
27 namespace luci
28 {
29
30 /**
31  * @brief TRANSPOSE_CONV in Circle
32  *
33  * @note  Argument node function names are from TensorFlow. So referring 'in' and
34  *        'out' acutally means 'out' and 'in' of the this node.
35  */
36 class CircleTransposeConv final
37     : public FixedArityNode<4, CircleNodeImpl<CircleOpcode::TRANSPOSE_CONV>>,
38       public LuciNodeMixin<LuciNodeTrait::Bias>
39 {
40 public:
41   loco::Node *inputSizes(void) const { return at(0)->node(); }
42   void inputSizes(Node *node) { at(0)->node(node); }
43
44   loco::Node *filter(void) const { return at(1)->node(); }
45   void filter(Node *node) { at(1)->node(node); }
46
47   loco::Node *outBackprop(void) const { return at(2)->node(); }
48   void outBackprop(Node *node) { at(2)->node(node); }
49
50   /**
51    * @note  "bias" is optional. When this node has no conceptual bias, "bias()"
52    *        expected to be `luci::CircleOutputExclude` type.
53    *
54    * <Comment on tflite TRANSPOSE_CONV>
55    *
56    * (Circle node has no dependency on tflite, but just for information on converting)
57    * Before TF v2.3.0, tflite TRANSPOSE_CONV didn't support fused bias as argument.
58    * From TF v2.3.0, tflite TRANSPOSE_CONV supports bias as optional 4th argument.
59    *
60    * Ref: https://github.com/tensorflow/tensorflow/commit/43b8f6e710
61    */
62   loco::Node *bias(void) const override { return at(3)->node(); }
63   void bias(loco::Node *node) override { at(3)->node(node); }
64
65 public:
66   const Padding &padding(void) const { return _padding; }
67   void padding(const Padding &padding) { _padding = padding; }
68
69   const Stride *stride(void) const { return &_stride; }
70   Stride *stride(void) { return &_stride; }
71
72 private:
73   Padding _padding{Padding::UNDEFINED};
74   Stride _stride;
75 };
76
77 } // namespace luci
78
79 #endif // __LUCI_IR_CIRCLETRANSPOSECONV_H__