-
Notifications
You must be signed in to change notification settings - Fork 24
Use Custom Layer
Takuya Takeuchi edited this page Dec 29, 2022
·
1 revision
NcnnDotNet supports to define custom layers on application side. It means that developer needs not to define and write them in C++ code.
class YourCustomLayer : CustomLayer
{
public YourCustomLayer()
{
}
protected override unsafe int OnForward(Mat bottomBlob, Mat topBlob, Option opt)
{
// Do NOT dispose bottomBlob, topBlob and opt!!!
return 0;
}
}
private static YourCustomLayer YourCustomLayerCreator(IntPtr userData)
{
return new YourCustomLayer();
}
using var net = new Net();
using var reg = new CustomLayerRegister("YourCustomLayer", YourCustomLayerCreator);
net.RegisterCustomLayer(reg);You can see the following examples uses custom layers.