TexasInstruments / edgeai-tidl-tools

Edgeai TIDL Tools and Examples - This repository contains Tools and example developed for Deep learning runtime (DLRT) offering provided by TI’s edge AI solutions.
Other
121 stars 27 forks source link

[Model Optimizer] Add conv even -> larger odd kernel #78

Open reesegrimsley opened 2 weeks ago

reesegrimsley commented 2 weeks ago

Adding to model optimizer/conv.py to allow even-sized convolutions to be implemented with larger odd-size. For example, Conv4x4 is replaced with conv5x5. Only square spatial kernels are supported. Padding is added along the top and left sides of the kernel and input.

Regarding padding, TIDL does not support asymmetric padding on the inputs to Conv layers. Replacing even with next size up odd kernel does require asym padding, so padding is all moved to a preceding, standalone layer, and Conv implements zero-pad 'same' configuration

There is a performance penalty, but this is less drastic than offloading conv operations to CPU as even-sized kernels are not implemented.

I have checked on a model with 4x4 conv that the conv5x5 gives identical output results