-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Expand file tree
/
Copy pathpybind11_layer.h
More file actions
149 lines (137 loc) · 3.63 KB
/
Copy pathpybind11_layer.h
File metadata and controls
149 lines (137 loc) · 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
// Copyright 2020 Tencent
// SPDX-License-Identifier: BSD-3-Clause
#ifndef PYBIND11_NCNN_LAYER_H
#define PYBIND11_NCNN_LAYER_H
#include <layer.h>
#include "pybind11_bind.h"
class PyLayer : public ncnn::Layer
{
public:
virtual int load_param(const ncnn::ParamDict& pd)
{
PYBIND11_OVERRIDE_REFERENCE(
int,
ncnn::Layer,
load_param,
pd);
}
virtual int load_model(const ncnn::ModelBin& mb)
{
PYBIND11_OVERRIDE_REFERENCE(
int,
ncnn::Layer,
load_model,
mb);
}
virtual int create_pipeline(const ncnn::Option& opt)
{
PYBIND11_OVERRIDE_REFERENCE(
int,
ncnn::Layer,
create_pipeline,
opt);
}
virtual int destroy_pipeline(const ncnn::Option& opt)
{
PYBIND11_OVERRIDE_REFERENCE(
int,
ncnn::Layer,
destroy_pipeline,
opt);
}
public:
virtual int forward(const std::vector<ncnn::Mat>& bottom_blobs, std::vector<ncnn::Mat>& top_blobs, const ncnn::Option& opt) const
{
PYBIND11_OVERRIDE_REFERENCE(
int,
ncnn::Layer,
forward,
bottom_blobs,
top_blobs,
opt);
}
virtual int forward(const ncnn::Mat& bottom_blob, ncnn::Mat& top_blob, const ncnn::Option& opt) const
{
PYBIND11_OVERRIDE_REFERENCE(
int,
ncnn::Layer,
forward,
bottom_blob,
top_blob,
opt);
}
virtual int forward_inplace(std::vector<ncnn::Mat>& bottom_top_blobs, const ncnn::Option& opt) const
{
PYBIND11_OVERRIDE_REFERENCE(
int,
ncnn::Layer,
forward_inplace,
bottom_top_blobs,
opt);
}
virtual int forward_inplace(ncnn::Mat& bottom_top_blob, const ncnn::Option& opt) const
{
PYBIND11_OVERRIDE_REFERENCE(
int,
ncnn::Layer,
forward_inplace,
bottom_top_blob,
opt);
}
#if NCNN_VULKAN
public:
virtual int upload_model(ncnn::VkTransfer& cmd, const ncnn::Option& opt)
{
PYBIND11_OVERRIDE_REFERENCE(
int,
ncnn::Layer,
upload_model,
cmd,
opt);
}
public:
virtual int forward(const std::vector<ncnn::VkMat>& bottom_blobs, std::vector<ncnn::VkMat>& top_blobs, ncnn::VkCompute& cmd, const ncnn::Option& opt) const
{
PYBIND11_OVERRIDE_REFERENCE(
int,
ncnn::Layer,
forward,
bottom_blobs,
top_blobs,
cmd,
opt);
}
virtual int forward(const ncnn::VkMat& bottom_blob, ncnn::VkMat& top_blob, ncnn::VkCompute& cmd, const ncnn::Option& opt) const
{
PYBIND11_OVERRIDE_REFERENCE(
int,
ncnn::Layer,
forward,
bottom_blob,
top_blob,
cmd,
opt);
}
virtual int forward_inplace(std::vector<ncnn::VkMat>& bottom_top_blobs, ncnn::VkCompute& cmd, const ncnn::Option& opt) const
{
PYBIND11_OVERRIDE_REFERENCE(
int,
ncnn::Layer,
forward_inplace,
bottom_top_blobs,
cmd,
opt);
}
virtual int forward_inplace(ncnn::VkMat& bottom_top_blob, ncnn::VkCompute& cmd, const ncnn::Option& opt) const
{
PYBIND11_OVERRIDE_REFERENCE(
int,
ncnn::Layer,
forward_inplace,
bottom_top_blob,
cmd,
opt);
}
#endif // NCNN_VULKAN
};
#endif