ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Backend.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 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_H__
18#define __ONERT_BACKEND_CPU_BACKEND_H__
19
20#include "BackendContext.h"
21#include "Config.h"
22#include "KernelGenerator.h"
24
25#include <backend/Backend.h>
26
27#include <memory>
28
30{
31
33{
34public:
35 Backend() : _config{std::make_shared<Config>()} {}
36
37 std::shared_ptr<IConfig> config() const override { return _config; }
38
39 std::unique_ptr<onert::backend::BackendContext> newContext(ContextData &&data) const override
40 {
41 auto custom_kernel_builder = data.custom_kernel_builder;
42 auto &graph = *data.graph;
43 auto context = std::make_unique<BackendContext>(this, std::move(data));
44 auto tr = std::make_shared<basic::TensorRegistry>();
45 auto tb = std::make_shared<TensorBuilder>(tr, findSharedMemoryOperandIndexes(graph));
46 context->tensor_registry = tr;
47 context->tensor_builder = tb;
48 context->kernel_gen = std::make_shared<KernelGenerator>(graph, tb, tr, custom_kernel_builder,
49 context->external_context());
50 return context;
51 }
52
53private:
54 std::shared_ptr<IConfig> _config;
55};
56
57} // namespace onert::backend::cpu
58
59#endif // __ONERT_BACKEND_CPU_BACKEND_H__
std::shared_ptr< IConfig > config() const override
Definition Backend.h:37
std::unique_ptr< onert::backend::BackendContext > newContext(ContextData &&data) const override
Definition Backend.h:39
ir::OperandIndexMap< ir::OperandIndex > findSharedMemoryOperandIndexes(const ir::IGraph &graph)