ONE - On-device Neural Engine
Loading...
Searching...
No Matches
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
29namespace onert
30{
31namespace backend
32{
33namespace cpu
34{
35
37{
38public:
39 Backend() : _config{std::make_shared<Config>()} {}
40
41 std::shared_ptr<IConfig> config() const override { return _config; }
42
43 std::unique_ptr<onert::backend::BackendContext> newContext(ContextData &&data) const override
44 {
45 auto custom_kernel_builder = data.custom_kernel_builder;
46 auto &graph = *data.graph;
47 auto context = std::make_unique<BackendContext>(this, std::move(data));
48 auto tr = std::make_shared<basic::TensorRegistry>();
49 auto tb = std::make_shared<TensorBuilder>(tr, findSharedMemoryOperandIndexes(graph));
50 context->tensor_registry = tr;
51 context->tensor_builder = tb;
52 context->kernel_gen = std::make_shared<KernelGenerator>(graph, tb, tr, custom_kernel_builder,
53 context->external_context());
54 return context;
55 }
56
57private:
58 std::shared_ptr<IConfig> _config;
59};
60
61} // namespace cpu
62} // namespace backend
63} // namespace onert
64
65#endif // __ONERT_BACKEND_CPU_BACKEND_H__
std::shared_ptr< IConfig > config() const override
Definition Backend.h:41
std::unique_ptr< onert::backend::BackendContext > newContext(ContextData &&data) const override
Definition Backend.h:43
ir::OperandIndexMap< ir::OperandIndex > findSharedMemoryOperandIndexes(const ir::IGraph &graph)