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_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
31namespace onert
32{
33namespace backend
34{
35namespace acl_neon
36{
37
39{
40public:
41 Backend() : _config{std::make_shared<Config>()} {}
42
43 std::shared_ptr<IConfig> config() const override { return _config; }
44
45 std::unique_ptr<backend::BackendContext> newContext(ContextData &&data) const override
46 {
47 const auto &graph = *data.graph;
48 const auto &operands = data.graph->operands();
49 const auto is_linear_executor = data.is_linear_executor;
50
51 auto context = std::make_unique<acl_neon::BackendContext>(this, std::move(data));
52 auto tm = createTensorManager(is_linear_executor);
53 auto tr = std::make_shared<acl_common::AclTensorRegistry<TensorManager>>(tm);
54 auto tb = std::make_shared<TensorBuilder>(operands, tm);
55 context->tensor_registry = tr;
56 context->tensor_builder = tb;
57 context->constant_initializer = std::make_shared<ConstantInitializer>(operands, tr);
58 context->kernel_gen = std::make_shared<KernelGenerator>(graph, tb, tr);
59 context->optimizer = std::make_shared<Optimizer>(context.get());
60 return context;
61 }
62
63private:
64 std::shared_ptr<IConfig> _config;
65};
66
67} // namespace acl_neon
68} // namespace backend
69} // namespace onert
70
71#endif // __ONERT_BACKEND_ACL_NEON_BACKEND_H__
std::shared_ptr< IConfig > config() const override
Definition Backend.h:43
std::unique_ptr< backend::BackendContext > newContext(ContextData &&data) const override
Definition Backend.h:45
TensorManager * createTensorManager(bool is_linear_executor)