ONE - On-device Neural Engine
Loading...
Searching...
No Matches
BackendContext.h
Go to the documentation of this file.
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 __ONERT_BACKEND_BUILTIN_BACKEND_CONTEXT_H__
18#define __ONERT_BACKEND_BUILTIN_BACKEND_CONTEXT_H__
19
20#include "ExternalContext.h"
21#include "KernelGenerator.h"
22#include "TensorBuilder.h"
25
26namespace onert
27{
28namespace backend
29{
30namespace builtin
31{
32
34{
35public:
37 std::shared_ptr<ITensorRegistry> tensor_registry = nullptr,
38 std::shared_ptr<TensorBuilder> tensor_builder = nullptr,
39 std::shared_ptr<KernelGenerator> kernel_gen = nullptr)
42 _external_context(std::make_shared<ExternalContext>())
43 {
44 }
45
46 ITensorRegistry *genTensors() override;
47
48 FunctionMap genKernels() override;
49
50 std::shared_ptr<ExternalContext> external_context() { return _external_context; }
51
52private:
53 void planTensors(const std::vector<onert::ir::OperationIndex> &order,
54 const compiler::GraphLowerInfo &lower_info);
55
56public:
57 // TODO Make it private
58 std::shared_ptr<TensorBuilder> tensor_builder;
59 std::shared_ptr<KernelGenerator> kernel_gen;
60
61private:
62 // NOTE ruy context has a thread pool, and when multiple ruy contexts are created,
63 // the thread pool is also created in duplicate
64 // TODO Create one ruy context for session
65 std::shared_ptr<ExternalContext> _external_context;
66};
67
68} // namespace builtin
69} // namespace backend
70} // namespace onert
71
72#endif // __ONERT_BACKEND_BUILTIN_BACKEND_CONTEXT_H__
std::shared_ptr< ITensorRegistry > tensor_registry
const ContextData & data() const
const Backend * backend() const
std::shared_ptr< KernelGenerator > kernel_gen
std::shared_ptr< TensorBuilder > tensor_builder
ITensorRegistry * genTensors() override
BackendContext(const Backend *backend, ContextData &&data, std::shared_ptr< ITensorRegistry > tensor_registry=nullptr, std::shared_ptr< TensorBuilder > tensor_builder=nullptr, std::shared_ptr< KernelGenerator > kernel_gen=nullptr)
std::shared_ptr< ExternalContext > external_context()
std::unordered_map< ir::OperationIndex, std::unique_ptr< exec::FunctionSequence > > FunctionMap