ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Backend.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 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_XNNPACK_BACKEND_H__
18#define __ONERT_BACKEND_XNNPACK_BACKEND_H__
19
20#include "BackendContext.h"
21#include "Config.h"
22#include "KernelGenerator.h"
23
24#include <backend/Backend.h>
25
26#include <memory>
27
28namespace onert
29{
30namespace backend
31{
32namespace xnnpack
33{
34
36{
37public:
38 Backend() : _config{std::make_shared<Config>()} {}
39
40 std::shared_ptr<IConfig> config() const override { return _config; }
41
42 std::unique_ptr<onert::backend::BackendContext> newContext(ContextData &&data) const override
43 {
44 auto custom_kernel_builder = data.custom_kernel_builder;
45 auto &graph = *data.graph;
46 auto context = std::make_unique<BackendContext>(this, std::move(data));
47 auto tr = std::make_shared<basic::TensorRegistry>();
48 auto tb = std::make_shared<TensorBuilder>(tr);
49 context->tensor_registry = tr;
50 context->tensor_builder = tb;
51 context->kernel_gen = std::make_shared<KernelGenerator>(graph, tb, tr, custom_kernel_builder,
52 context->external_context());
53 return context;
54 }
55
56private:
57 std::shared_ptr<IConfig> _config;
58};
59
60} // namespace xnnpack
61} // namespace backend
62} // namespace onert
63
64#endif // __ONERT_BACKEND_XNNPACK_BACKEND_H__
std::shared_ptr< IConfig > config() const override
Definition Backend.h:40
std::unique_ptr< onert::backend::BackendContext > newContext(ContextData &&data) const override
Definition Backend.h:42