Imported Upstream version 1.25.0
[platform/core/ml/nnfw.git] / runtime / onert / core / include / backend / IConfig.h
1 /*
2  * Copyright (c) 2018 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_BACKEND_ICONFIG_H__
18 #define __ONERT_BACKEND_ICONFIG_H__
19
20 #include "ir/Layout.h"
21 #include "ir/IOperation.h"
22 #include "util/ITimer.h"
23
24 #include <memory>
25 #include <string>
26
27 namespace onert
28 {
29 namespace backend
30 {
31
32 struct IConfig
33 {
34   virtual ~IConfig() = default;
35   /**
36    * @brief Returns ID of the backend
37    *
38    * @return std::string ID of this backend
39    */
40   virtual std::string id() = 0;
41   /**
42    * @brief Initialize the backend. This is called as soon as the backend is loaded.
43    *
44    * @return true  Initialization succeeded
45    * @return false Initialization failed, so it cannot use this backend
46    */
47   virtual bool initialize() = 0;
48   /**
49    * @brief Returns supported layout for the given \p node and \p frontend_layout
50    *
51    * @param node IOperation
52    * @param frontend_layout The layout defined in the model
53    * @return ir::Layout The layout that the backend kernel actually uses
54    */
55   virtual ir::Layout supportLayout(const ir::IOperation &node, ir::Layout frontend_layout) = 0;
56   /**
57    * @brief The function that is called after each Operation run on profiling mode.
58    *        This may be useful for profiling GPU-based or special computing units.
59    */
60   virtual void sync() const {}
61   /**
62    * @brief Returns Timer object for this backend. For some computing units, it may need its own
63    * Timer implementation.
64    *
65    * @return std::unique_ptr<util::ITimer> Timer object for this backend
66    */
67   virtual std::unique_ptr<util::ITimer> timer() { return nullptr; }
68
69   virtual bool supportPermutation() = 0;
70   virtual bool supportDynamicTensor() = 0;
71   virtual bool supportFP16() = 0;
72 };
73
74 } // namespace backend
75 } // namespace onert
76
77 #endif // __ONERT_BACKEND_ICONFIG_H__