ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Backend.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2018 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 __NNKIT_SUPPORT_CAFFE_BACKEND_H__
18
#define __NNKIT_SUPPORT_CAFFE_BACKEND_H__
19
20
#include "
nnkit/support/caffe/InputBlobContext.h
"
21
#include "
nnkit/support/caffe/OutputBlobContext.h
"
22
#include "
nnkit/support/caffe/TensorContext.h
"
23
24
#include <
nnkit/Backend.h
>
25
26
#include <caffe/net.hpp>
27
28
#include <memory>
29
#include <functional>
30
31
namespace
nnkit
32
{
33
namespace
support
34
{
35
namespace
caffe
36
{
37
38
template
<
typename
DType>
class
Backend
final :
public
nnkit::Backend
39
{
40
public
:
41
Backend
(std::unique_ptr<::caffe::Net<DType>> &&net) : _net{
std
::move(net)}
42
{
43
// DO NOTHING
44
}
45
46
public
:
47
void
prepare
(
const
std::function<
void
(
nnkit::TensorContext
&)> &f)
override
48
{
49
InputBlobContext<DType>
blobs(*_net);
50
TensorContext<DType>
tensors(blobs);
51
f(tensors);
52
}
53
54
public
:
55
void
run
(
void
)
override
{ _net->Forward(); }
56
57
public
:
58
void
teardown
(
const
std::function<
void
(
nnkit::TensorContext
&)> &f)
override
59
{
60
OutputBlobContext<DType>
blobs(*_net);
61
TensorContext<DType>
tensors(blobs);
62
f(tensors);
63
}
64
65
private
:
66
std::unique_ptr<::caffe::Net<DType>> _net;
67
};
68
69
}
// namespace caffe
70
}
// namespace support
71
}
// namespace nnkit
72
73
#endif
// __NNKIT_SUPPORT_CAFFE_BACKEND_H__
InputBlobContext.h
OutputBlobContext.h
nnkit::support::caffe::Backend
Definition
Backend.h:39
nnkit::support::caffe::Backend::teardown
void teardown(const std::function< void(nnkit::TensorContext &)> &f) override
Definition
Backend.h:58
nnkit::support::caffe::Backend::run
void run(void) override
Definition
Backend.h:55
nnkit::support::caffe::Backend::prepare
void prepare(const std::function< void(nnkit::TensorContext &)> &f) override
Definition
Backend.h:47
nnkit::support::caffe::Backend::Backend
Backend(std::unique_ptr<::caffe::Net< DType > > &&net)
Definition
Backend.h:41
nnkit::support::caffe::InputBlobContext
Definition
InputBlobContext.h:32
nnkit::support::caffe::OutputBlobContext
Definition
OutputBlobContext.h:32
nnkit::support::caffe::TensorContext
Definition
TensorContext.h:38
Backend.h
nnkit
Definition
Backend.h:32
std
Definition
CircleExporterUtils.h:53
TensorContext.h
nnkit::Backend
Definition
Backend.h:28
nnkit::TensorContext
Definition
TensorContext.h:34
compiler
nnkit-caffe
support
include
nnkit
support
caffe
Backend.h
Generated by
1.9.8