Imported Upstream version 1.7.0
[platform/core/ml/nnfw.git] / runtime / onert / core / include / exec / IODescription.h
1 /*
2  * Copyright (c) 2019 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_EXEC_IO_DESCRIPTION_H__
18 #define __ONERT_EXEC_IO_DESCRIPTION_H__
19
20 #include <vector>
21 #include <unordered_map>
22
23 #include "ir/OperandInfo.h"
24 #include "ir/Index.h"
25
26 namespace onert
27 {
28 namespace exec
29 {
30
31 struct InputDesc
32 {
33   const ir::OperandInfo info;
34   const void *buffer;
35   const size_t size;
36   const ir::Layout layout;
37
38   InputDesc(void) = delete;
39   InputDesc(const ir::OperandInfo &info, const void *buffer, const size_t size, ir::Layout layout)
40       : info(info), buffer(buffer), size(size), layout(layout)
41   {
42   }
43 };
44
45 struct OutputDesc
46 {
47   // not `const` because shape should be modified after execution in case when output is
48   // a dynamic tensor
49   ir::OperandInfo info;
50   void *buffer;
51   const size_t size;
52   const ir::Layout layout;
53
54   OutputDesc(void) = delete;
55   OutputDesc(const ir::OperandInfo &info, void *buffer, const size_t size, ir::Layout layout)
56       : info(info), buffer(buffer), size(size), layout(layout)
57   {
58   }
59 };
60
61 struct IODescription
62 {
63   std::vector<std::unique_ptr<InputDesc>> inputs;
64   std::vector<std::unique_ptr<OutputDesc>> outputs;
65   // Contains shape of input set by set_input_tensorinfo
66   std::unordered_map<ir::IOIndex, ir::Shape> input_shape_signature;
67 };
68
69 } // namespace exec
70 } // namespace onert
71
72 #endif // __ONERT_EXEC_IO_DESCRIPTION_H__