Template Specialization - 2024.1 English

Vitis Model Composer User Guide (UG1483)

Document ID
Release Date
2024.1 English

For cases where you want to override the default template implementation to handle a particular type in a different way, Vitis Model Composer supports template specialization. Consider the following example where a function myFunc has one specialized version declared to implement an int16 datatype along with a generic template function.


#include <adf.h>
template<typename T, int N>
void myFunc(input_buffer<T>  &i1,
            output_buffer<T> &o1
void myFunc<int16,8>(input_buffer<int16>  &i1,
       output_buffer<int16> &o1);

When you try to import the kernel myFunc as a block into Vitis Model Composer using the AIE Template Kernel block, the Function tab in the block GUI parameter looks as shown. If you select the function variant corresponding to the base template, the Function Template Parameters table shows the values corresponding to that. If you select the specialization variant instead, the table shows the values of the template parameters of that specialization. You cannot change these values.

Figure 1. AIE Template Kernel: Functional declaration Options