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#include "Validator.h"
25
26#include <backend/Backend.h>
27
28#include <memory>
29
31{
32
34{
35public:
36 Backend() : _config{std::make_shared<Config>()} {}
37
38 std::shared_ptr<IConfig> config() const override { return _config; }
39
40 std::unique_ptr<onert::backend::BackendContext> newContext(ContextData &&data) const override
41 {
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 =
49 std::make_shared<KernelGenerator>(graph, tb, tr, context->external_context());
50 return context;
51 }
52
53 std::unique_ptr<ValidatorBase> validator(const ir::Graph &graph) const override
54 {
55 return std::make_unique<Validator>(graph);
56 }
57
58private:
59 std::shared_ptr<IConfig> _config;
60};
61
62} // namespace onert::backend::cpu
63
64#endif // __ONERT_BACKEND_CPU_BACKEND_H__
std::unique_ptr< ValidatorBase > validator(const ir::Graph &graph) const override
Definition Backend.h:53
std::shared_ptr< IConfig > config() const override
Definition Backend.h:38
std::unique_ptr< onert::backend::BackendContext > newContext(ContextData &&data) const override
Definition Backend.h:40
ir::OperandIndexMap< ir::OperandIndex > findSharedMemoryOperandIndexes(const ir::IGraph &graph)