## A Cute custom onnx plugin template
Want to implement a custom plugin for your onnx model and don't know where to start? here is a simple template, let's go!
### Step 1
copy this whole CuteSamplePlugin directory to your project's plugin directory, or, as I recommended, implement it with tiny-tensorrt, then port to your own project.
### Step 2
Now check the name of your node that need to be registered as a plugin, you can find its name via [Netron](https://netron.app/), after import your model, you should see your node name here
![image](https://user-images.githubusercontent.com/38289304/104086586-41f2ca00-5294-11eb-8bb6-af2f127908b2.png)
now I get the Plugin name(which is the type attribute of the node) is HSigmoid, open CuteSamplePlugin.cpp, find
```c++
static const char* CUTE_PLUGIN_VERSION{"1"};
static const char* CUTE_PLUGIN_NAME{"CuteSamplePlugin"};
```
edit the CUTE_PLUGIN_NAME to
```c++
static const char* CUTE_PLUGIN_NAME{"HSigmoid"};
```
### Step 3
Now if you run it with your own plugin that contains the custom plugin node, it should find your custom plugin(take a look at test/test.cpp). you should get a running output like this
```
root@f44d36162a5e:/tiny-tensorrt/build# ./unit_test --onnx_path ../demo.onnx
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][CuteSamplePluginCreator][Line 155] wow I run to here now
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][getPluginName][Line 162] wow I run to here now
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][getPluginName][Line 162] wow I run to here now
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][getPluginVersion][Line 168] wow I run to here now
[2021-01-09 07:50:56.784] [info] create plugin factory
[2021-01-09 07:50:56.784] [info] yolo3 params: class: 1, netSize: 416
[2021-01-09 07:50:56.784] [info] upsample params: scale: 2
[2021-01-09 07:50:56.827] [info] build onnx engine from ../demo.onnx...
----------------------------------------------------------------
Input filename: ../demo.onnx
ONNX IR version: 0.0.4
Opset version: 9
Producer name: pytorch
Producer version: 1.3
Domain:
Model version: 0
Doc string:
----------------------------------------------------------------
/workspace/TensorRT/parsers/onnx/ModelImporter.cpp:139: No importer registered for op: HSigmoid. Attempting to import as plugin.
/workspace/TensorRT/parsers/onnx/builtin_op_importers.cpp:3716: Searching for plugin: HSigmoid, plugin_version: 1, plugin_namespace:
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][getPluginVersion][Line 168] wow I run to here now
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][getFieldNames][Line 174] wow I run to here now
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][createPlugin][Line 180] wow I run to here now
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][CuteSamplePlugin][Line 32] wow I run to here now
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][setPluginNamespace][Line 143] wow I run to here now
/workspace/TensorRT/parsers/onnx/builtin_op_importers.cpp:3733: Successfully created plugin: HSigmoid
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][getNbOutputs][Line 43] wow I run to here now
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][getOutputDataType][Line 67] wow I run to here now
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][CuteSamplePlugin][Line 32] wow I run to here now
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][setPluginNamespace][Line 143] wow I run to here now
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][getNbOutputs][Line 43] wow I run to here now
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][getOutputDataType][Line 67] wow I run to here now
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][isOutputBroadcastAcrossBatch][Line 94] wow I run to here now
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][getOutputDimensions][Line 49] wow I run to here now
-------> (Unnamed Layer* 0) [Constant]_output
x (Unnamed Layer* 0) [Constant]_output -------> 2
[2021-01-09 07:50:56.828] [info] fp16 support: false
[2021-01-09 07:50:56.828] [info] int8 support: false
[2021-01-09 07:50:56.828] [info] Max batchsize: 4
[2021-01-09 07:50:56.828] [info] Max workspace size: 10485760
[2021-01-09 07:50:56.828] [info] Number of DLA core: 0
[2021-01-09 07:50:56.828] [info] Max DLA batchsize: 268435456
[2021-01-09 07:50:56.828] [info] Current use DLA core: 0
[2021-01-09 07:50:56.828] [info] build engine...
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][CuteSamplePlugin][Line 32] wow I run to here now
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][setPluginNamespace][Line 143] wow I run to here now
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][getPluginType][Line 119] wow I run to here now
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][getPluginType][Line 119] wow I run to here now
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][getPluginType][Line 119] wow I run to here now
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][supportsFormat][Line 113] wow I run to here now
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][supportsFormat][Line 113] wow I run to here now
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][supportsFormat][Line 113] wow I run to here now
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][supportsFormat][Line 113] wow I run to here now
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][supportsFormat][Line 113] wow I run to here now
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][getOutputDataType][Line 67] wow I run to here now
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][getOutputDataType][Line 67] wow I run to here now
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][getOutputDataType][Line 67] wow I run to here now
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][getOutputDataType][Line 67] wow I run to here now
Detected 1 inputs and 1 output network tensors.
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp][CuteSamplePlugin][Line 32] wow I run to here now
(๑¯◡¯๑) CUSTOM PLUGIN TRACE----> call [/tiny-tensorrt/plugin/CuteSamplePlugin/CuteSamplePlugin.cpp]
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
基于C++快速使用TensorRT来部署模型项目源码 (232个子文件)
setup.cfg 312B
pybind11Tools.cmake 9KB
FindPythonLibsNew.cmake 8KB
CUDA_utils.cmake 4KB
FindEigen3.cmake 3KB
FindCatch.cmake 2KB
test_methods_and_attributes.cpp 23KB
test_virtual_functions.cpp 17KB
test_class.cpp 17KB
test_eigen.cpp 16KB
test_smart_ptr.cpp 16KB
test_numpy_dtypes.cpp 16KB
test_factory_constructors.cpp 16KB
test_numpy_array.cpp 15KB
Trt.cpp 15KB
test_sequences_and_iterators.cpp 13KB
cnpy.cpp 11KB
test_stl.cpp 11KB
test_interpreter.cpp 10KB
test_pytypes.cpp 9KB
test_copy_move.cpp 9KB
test_builtin_casters.cpp 9KB
test_multiple_inheritance.cpp 9KB
tinyexec.cpp 8KB
test_exceptions.cpp 7KB
test_operator_overloading.cpp 6KB
test_callbacks.cpp 6KB
test_buffers.cpp 6KB
CuteSampleDynamicExtPlugin.cpp 6KB
CuteSamplePlugin.cpp 5KB
pybind11_cross_module_tests.cpp 5KB
Int8Calibrator.cpp 5KB
test_pickling.cpp 5KB
test_local_bindings.cpp 4KB
test_tagbased_polymorphic.cpp 4KB
test_kwargs_and_defaults.cpp 4KB
test_constants_and_functions.cpp 4KB
pybind11_tests.cpp 4KB
test_numpy_vectorize.cpp 4KB
test_call_policies.cpp 4KB
test_stl_binders.cpp 3KB
test_modules.cpp 3KB
test_opaque_types.cpp 3KB
sampleDynamicShape.cpp 2KB
test_enum.cpp 2KB
test_eval.cpp 2KB
test_docstring_options.cpp 2KB
plugin_utils.cpp 2KB
test_iostream.cpp 2KB
test_chrono.cpp 2KB
PyTrt.cpp 2KB
cross_module_gil_utils.cpp 2KB
test_gil_scoped.cpp 2KB
test_async.cpp 863B
embed.cpp 654B
sampleINT8.cpp 645B
catch.cpp 637B
test_union.cpp 603B
external_module.cpp 554B
main.cpp 152B
theme_overrides.css 254B
Doxyfile 564B
.gitignore 367B
.gitignore 35B
.gitignore 30B
.gitmodules 202B
.gitmodules 87B
pybind11.h 94KB
cast.h 87KB
numpy.h 66KB
pytypes.h 57KB
common.h 36KB
eigen.h 28KB
class.h 24KB
stl_bind.h 23KB
attr.h 19KB
init.h 16KB
internals.h 14KB
stl.h 14KB
constructor_stats.h 11KB
cnpy.h 11KB
operators.h 9KB
Trt.h 8KB
embed.h 8KB
chrono.h 8KB
iostream.h 6KB
object.h 5KB
buffer_info.h 4KB
eval.h 4KB
functional.h 4KB
descr.h 3KB
CuteSampleDynamicExtPlugin.h 3KB
CuteSamplePlugin.h 3KB
plugin_utils.h 3KB
pybind11_tests.h 2KB
local_bindings.h 2KB
options.h 2KB
complex.h 2KB
utils.h 2KB
typeid.h 1KB
共 232 条
- 1
- 2
- 3
资源评论
- Qinglu_2022-12-12#标题与内容不符 #毫无价值一点用都没有
- 张汉驰2022-06-10用户下载后在一定时间内未进行评价,系统默认好评。
- sichengwuya2022-05-02用户下载后在一定时间内未进行评价,系统默认好评。
- m0_748129882023-12-12资源内容详实,描述详尽,解决了我的问题,受益匪浅,学到了。
爱吃苹果的Jemmy
- 粉丝: 74
- 资源: 1148
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功