Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.
6427 Discussions

Method to create a custom kernel for a layer.

Deepak_C_R
Beginner
1,079 Views

Hi,

I have a prototxt file. I have generated .graphml file using ModelOptimizer by giving prototxt file as the input parameter.

Now using VAD I have loaded the generated .graphml file and clicked on the first convolution layer node in the VAD tool for which I need to create a custom kernel. After that I clicked on the button which will generate openvx user kernel stub code (Ctrl+Shift+U). This operation generated some .c and .h files.

In user_kernel_name_module.c (generated file using Ctrl+Shift+U, in my example) there is a function UserKernelNameKernel(), I have added my custome kernel code inside that. I have compiled the code to generate libuser_kernel_stubs.so. I ran the ModelOptimizer again by giving this path as one of the parameters (-k /path/to/lib/kernel/stub/).

Also in CustomLayersMapping.xml which is inside ModelOptimizer directory, I have written the name of the convolution layer for which I have generated custom kernel.

Is this the right way to create custom kernel and use it ?

Thank You.

 

 

0 Kudos
4 Replies
Stav_S_Intel
Employee
1,079 Views

Hi Deepak,

No, in general we would recommend not to use VAD and MO together when starting to use these tools- when genrating the code from VAD you lose the pre and post work. it is recommended to use MO to generate DL related code, you can use VAD to see the graph and explore it but it is not the correct way to add user kernel. 

Please refer to the MO user guide and VAD user guide for the instructions on how to add custom kernel. 

Please let me know if something is not clear.

Regards,

Stav

0 Kudos
Deepak_C_R
Beginner
1,079 Views

Hi,

I have used this documentation to generated custom kernel. And I have added my custom kernel  function code for the first activation layer inside the code generated by VAD. The documentation specifies the method as in my question. What I need do do differently to achieve this ?

0 Kudos
Deepak_C_R
Beginner
1,079 Views

Hi Stav,

To create a CNN binary (which does prediction) I have done following things.

1. Created Custom library using VAD.

2. Ran ModelOptimizer by giving custom kernel libray, model file, prototxt file as input parameters.

3. Created a test application which uses generated openvx code and optimized model files (by referring cnn_custom_kernel sample code).

Is it correct method ?. If not what is the right method ?.

 

0 Kudos
Stav_S_Intel
Employee
1,079 Views

Hi Deepak, 

I Think this is the same question as answered here

It is the process if you use MO for custom layer-and differentiate between VAD and MO custom kernel as in the thread linked above. 

 

Regards,

Stav 

0 Kudos
Reply