Imported Upstream version 1.8.0
[platform/core/ml/nnfw.git] / compiler / luci / lang / include / luci / IR / Nodes / CircleConst.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_CIRCLECONST_H__
18 #define __LUCI_IR_CIRCLECONST_H__
19
20 #include "luci/IR/CircleNodeDecl.h"
21 #include "luci/IR/CircleOpcode.h"
22
23 #include "luci/IR/LuciNodeMixins.h"
24
25 #include <loco/IR/DataTypeTraits.h>
26
27 namespace luci
28 {
29
30 /**
31  * @brief Class to build tensor data
32  * @note  This will not be exported as a specific op
33  */
34 class CircleConst final : public FixedArityNode<0, CircleNodeImpl<CircleOpcode::CIRCLECONST>>
35 {
36 public:
37   CircleConst() = default;
38
39 public:
40   template <loco::DataType DT> uint32_t size(void) const;
41   template <loco::DataType DT> void size(uint32_t size);
42   template <loco::DataType DT> const typename loco::DataTypeImpl<DT>::Type &at(uint32_t n) const;
43   template <loco::DataType DT> typename loco::DataTypeImpl<DT>::Type &at(uint32_t n);
44
45   template <loco::DataType DT> const typename loco::DataTypeImpl<DT>::Type &scalar(void) const;
46   template <loco::DataType DT> typename loco::DataTypeImpl<DT>::Type &scalar(void);
47
48 private:
49   std::vector<uint8_t> _data;
50 };
51
52 } // namespace luci
53
54 #endif // __LUCI_IR_CIRCLECONST_H__