Template Partial Specialization - 2022.1 English

Vitis Model Composer User Guide (UG1483)

Document ID
Release Date
2022.1 English

For cases where you write a template that specializes one template parameter and still allows some parameterization, you can use the template partial specialization. Vitis Model Composer allows you to import the class kernels with partial specialization using the AIE Class Kernel block. Consider the following example where a class class_a is partially specialized with a non-type template parameter.


#include <adf.h>
template<typename T,int N>
class class_a
template<typename T>
class class_a<T,2> {
   int m_count;
   T var;
   class_a(T q_var1);
   void func_mem(input_stream<T>  *i1,
                      output_stream<T> *o1,
                      output_stream<int> *o2);
    static void registerKernelClass()

Notice that the function func_mem is registered in registerKernelClass() method. When you try to import the kernel function as a block into Model Composer using the AIE Class Kernel block, the Kernel Class tab in the Block Parameters dialog box looks as shown.

Figure 1. Block Parameters: AIE Class Kernel

Because the class is partially specialized with a non-type template parameter, you cannot edit the parameter 'N' from the Kernel Class Template Parameters. However, the value of the template type parameter can be a modified to any valid datatype.