Imported Upstream version 1.12.0
[platform/core/ml/nnfw.git] / compiler / luci / lang / include / luci / IR / CircleShapeSignature.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_SHAPE_SIGNATURE_H__
18 #define __LUCI_IR_SHAPE_SIGNATURE_H__
19
20 #include <stdint.h>
21 #include <vector>
22
23 namespace luci
24 {
25
26 class ShapeSignature
27 {
28 public:
29   ShapeSignature() = default;
30
31   ShapeSignature(const std::vector<int32_t> &shape_signature)
32   {
33     _shape_signature = shape_signature;
34   }
35
36 public:
37   const std::vector<int32_t> &as_vector() const { return _shape_signature; }
38
39   int32_t dim(uint32_t d) const { return _shape_signature.at(d); }
40   int32_t &dim(uint32_t d) { return _shape_signature.at(d); }
41
42   uint32_t rank(void) const { return _shape_signature.size(); }
43   void rank(uint32_t rank) { _shape_signature.resize(rank); }
44
45 private:
46   std::vector<int32_t> _shape_signature{};
47 };
48
49 bool operator==(const ShapeSignature &lhs, const ShapeSignature &rhs);
50
51 } // namespace luci
52
53 #endif // __LUCI_IR_SHAPE_SIGNATURE_H__