ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
BackendContext.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 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_TRAIN_BACKEND_CONTEXT_H__
18#define __ONERT_BACKEND_BUILTIN_TRAIN_BACKEND_CONTEXT_H__
19
21
22#include "KernelGenerator.h"
23#include "../ExternalContext.h"
24#include "../TensorBuilder.h"
25
27{
28
30{
31public:
33 std::unique_ptr<backend::train::TrainableContextData> &&data,
34 std::shared_ptr<backend::train::ITensorRegistry> tensor_registry = nullptr,
35 std::shared_ptr<TensorBuilder> tensor_builder = nullptr,
36 std::shared_ptr<KernelGenerator> kernel_gen = nullptr)
38 kernel_gen{kernel_gen}, _external_context(new ExternalContext),
39 _tensor_builder{tensor_builder}
40 {
41 }
42
43public:
45
46 std::shared_ptr<ExternalContext> external_context() { return _external_context; }
47
48public:
49 // TODO Make it private
50 std::shared_ptr<KernelGenerator> kernel_gen;
51
52private:
53 // NOTE ruy context has a thread pool, and when multiple ruy contexts are created,
54 // the thread pool is also created in duplicate
55 // TODO Create one ruy context for session
56 std::shared_ptr<ExternalContext> _external_context;
57
58private:
59 std::shared_ptr<TensorBuilder> _tensor_builder;
60};
61
62} // namespace onert::backend::builtin::train
63
64#endif // __ONERT_BACKEND_BUILTIN_TRAIN_BACKEND_CONTEXT_H__
std::shared_ptr< ExternalContext > external_context()
BackendContext(const backend::train::ITrainableBackend *backend, std::unique_ptr< backend::train::TrainableContextData > &&data, std::shared_ptr< backend::train::ITensorRegistry > tensor_registry=nullptr, std::shared_ptr< TensorBuilder > tensor_builder=nullptr, std::shared_ptr< KernelGenerator > kernel_gen=nullptr)
backend::train::FunctionMap gen() override
std::shared_ptr< KernelGenerator > kernel_gen
TrainableBackendContext(const ITrainableBackend *backend, std::unique_ptr< TrainableContextData > &&tdata, std::shared_ptr< ITensorRegistry > tensor_registry=nullptr)
std::shared_ptr< ITensorRegistry > tensor_registry()
std::unordered_map< ir::OperationIndex, std::unique_ptr< exec::train::TrainableFnSequence > > FunctionMap