ONE - On-device Neural Engine
Loading...
Searching...
No Matches
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
26namespace onert
27{
28namespace backend
29{
30namespace builtin
31{
32namespace train
33{
34
36{
37public:
39 std::unique_ptr<backend::train::TrainableContextData> &&data,
40 std::shared_ptr<backend::train::ITensorRegistry> tensor_registry = nullptr,
41 std::shared_ptr<TensorBuilder> tensor_builder = nullptr,
42 std::shared_ptr<KernelGenerator> kernel_gen = nullptr)
44 kernel_gen{kernel_gen}, _external_context(new ExternalContext),
45 _tensor_builder{tensor_builder}
46 {
47 }
48
49public:
51
52 std::shared_ptr<ExternalContext> external_context() { return _external_context; }
53
54public:
55 // TODO Make it private
56 std::shared_ptr<KernelGenerator> kernel_gen;
57
58private:
59 // NOTE ruy context has a thread pool, and when multiple ruy contexts are created,
60 // the thread pool is also created in duplicate
61 // TODO Create one ruy context for session
62 std::shared_ptr<ExternalContext> _external_context;
63
64private:
65 std::shared_ptr<TensorBuilder> _tensor_builder;
66};
67
68} // namespace train
69} // namespace builtin
70} // namespace backend
71} // namespace onert
72
73#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