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_CPU_BACKEND_CONTEXT_H__
18#define __ONERT_BACKEND_CPU_BACKEND_CONTEXT_H__
19
21#include "TensorBuilder.h"
22#include "KernelGenerator.h"
23#include "ExternalContext.h"
24
25namespace onert
26{
27namespace backend
28{
29namespace cpu
30{
31
33{
34public:
36 std::shared_ptr<ITensorRegistry> tensor_registry = nullptr,
37 std::shared_ptr<TensorBuilder> tensor_builder = nullptr,
38 std::shared_ptr<KernelGenerator> kernel_gen = nullptr)
41 {
42 }
43
44 ITensorRegistry *genTensors() override;
45 FunctionMap genKernels() override;
46
47 std::shared_ptr<ExternalContext> external_context() { return _external_context; }
48
49public:
50 // TODO Make it private
51 std::shared_ptr<TensorBuilder> tensor_builder;
52 std::shared_ptr<KernelGenerator> kernel_gen;
53
54private:
55 // NOTE ruy context has a thread pool, and when multiple ruy contexts are created,
56 // the thread pool is also created in duplicate
57 // TODO Create one ruy context for session
58 std::shared_ptr<ExternalContext> _external_context;
59};
60
61} // namespace cpu
62} // namespace backend
63} // namespace onert
64
65#endif // __ONERT_BACKEND_CPU_BACKEND_CONTEXT_H__
std::shared_ptr< ITensorRegistry > tensor_registry
const ContextData & data() const
const Backend * backend() const
ITensorRegistry * genTensors() override
std::shared_ptr< KernelGenerator > kernel_gen
std::shared_ptr< ExternalContext > external_context()
std::shared_ptr< TensorBuilder > tensor_builder
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::unordered_map< ir::OperationIndex, std::unique_ptr< exec::FunctionSequence > > FunctionMap