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_ACL_NEON_BACKEND_H__
18#define __ONERT_BACKEND_ACL_NEON_BACKEND_H__
19
20#include <memory>
21#include <backend/Backend.h>
22#include <ir/Operands.h>
23
24#include "BackendContext.h"
25#include "Config.h"
26#include "ConstantInitializer.h"
27#include "KernelGenerator.h"
28#include "TensorManager.h"
29#include "Optimizer.h"
30
32{
33
35{
36public:
37 Backend() : _config{std::make_shared<Config>()} {}
38
39 std::shared_ptr<IConfig> config() const override { return _config; }
40
41 std::unique_ptr<backend::BackendContext> newContext(ContextData &&data) const override
42 {
43 const auto &graph = *data.graph;
44 const auto &operands = data.graph->operands();
45 const auto is_linear_executor = data.is_linear_executor;
46
47 auto context = std::make_unique<acl_neon::BackendContext>(this, std::move(data));
48 auto tm = createTensorManager(is_linear_executor);
49 auto tr = std::make_shared<acl_common::AclTensorRegistry<TensorManager>>(tm);
50 auto tb = std::make_shared<TensorBuilder>(operands, tm);
51 context->tensor_registry = tr;
52 context->tensor_builder = tb;
53 context->constant_initializer = std::make_shared<ConstantInitializer>(operands, tr);
54 context->kernel_gen = std::make_shared<KernelGenerator>(graph, tb, tr);
55 context->optimizer = std::make_shared<Optimizer>(context.get());
56 return context;
57 }
58
59private:
60 std::shared_ptr<IConfig> _config;
61};
62
63} // namespace onert::backend::acl_neon
64
65#endif // __ONERT_BACKEND_ACL_NEON_BACKEND_H__
std::shared_ptr< IConfig > config() const override
Definition Backend.h:39
std::unique_ptr< backend::BackendContext > newContext(ContextData &&data) const override
Definition Backend.h:41
TensorManager * createTensorManager(bool is_linear_executor)