forked from LiuLeif/hello_tensorrt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin.h
89 lines (82 loc) · 4.52 KB
/
plugin.h
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
// 2022-06-27 18:32
#ifndef PLUGIN_H
#define PLUGIN_H
#include "kernel/batch_norm_plugin.h"
#include "kernel/bn_plugin.h"
#include "kernel/convolution_plugin.h"
#include "kernel/deconvolution_plugin.h"
#include "kernel/eltwise_plugin.h"
#include "kernel/inner_product_plugin.h"
#include "kernel/lrn_plugin.h"
#include "kernel/nms_plugin.h"
#include "kernel/normalize_plugin.h"
#include "kernel/permute_plugin.h"
#include "kernel/pooling_plugin.h"
#include "kernel/power_plugin.h"
#include "kernel/prelu_plugin.h"
#include "kernel/prior_box_plugin.h"
#include "kernel/relu_plugin.h"
#include "kernel/scale_plugin.h"
#include "kernel/softmax_plugin.h"
#include "kernel/upsample_plugin.h"
#define PLUGIN_LIST(ITEM) \
ITEM(Eltwise, ELTWISE); \
ITEM(BatchNorm, BATCH_NORM); \
ITEM(BN, BN); \
ITEM(Convolution, CONVOLUTION); \
ITEM(Deconvolution, DECONVOLUTION); \
ITEM(InnerProduct, INNER_PRODUCT); \
ITEM(LRN, LRN); \
ITEM(Pooling, POOLING); \
ITEM(Power, POWER); \
ITEM(Relu, RELU); \
ITEM(PReLU, PRELU); \
ITEM(Scale, SCALE); \
ITEM(Softmax, SOFTMAX); \
ITEM(Permute, PERMUTE); \
ITEM(NMS, NMS); \
ITEM(Normalize2, NORMALIZE); \
ITEM(PriorBox2, PRIOR_BOX); \
ITEM(Upsample, UPSAMPLE);
#define REGISTER_PLUGIN(plugin_type, plugin_name) \
REGISTER_TENSORRT_PLUGIN(plugin_type##PluginCreator);
#define DECLARE_PLUGIN_CREATOR(plugin_type, plugin_name) \
class plugin_type##PluginCreator : public IPluginCreator { \
public: \
const char* getPluginName() const noexcept override { \
return #plugin_name; \
} \
const char* getPluginVersion() const noexcept override { return "1"; } \
const PluginFieldCollection* getFieldNames() noexcept override { \
return &mFieldCollection; \
} \
IPluginV2* createPlugin( \
const char* name, \
const PluginFieldCollection* fc) noexcept override { \
auto* plugin = new plugin_type##Plugin(*fc); \
mFieldCollection = *fc; \
mPluginName = name; \
return plugin; \
} \
IPluginV2* deserializePlugin( \
const char* name, const void* serialData, \
size_t serialLength) noexcept override { \
auto* plugin = new plugin_type##Plugin(serialData, serialLength); \
mPluginName = name; \
return plugin; \
} \
void setPluginNamespace(const char* libNamespace) noexcept override { \
mNamespace = libNamespace; \
} \
const char* getPluginNamespace() const noexcept override { \
return mNamespace.c_str(); \
} \
\
private: \
std::string mNamespace; \
std::string mPluginName; \
PluginFieldCollection mFieldCollection{0, nullptr}; \
};
PLUGIN_LIST(DECLARE_PLUGIN_CREATOR);
#define REGISTER_ALL_PLUGINS PLUGIN_LIST(REGISTER_PLUGIN);
#endif // PLUGIN_H