PROCESSOR-SDK-J784S4: vxlib convolution

Part Number: PROCESSOR-SDK-J784S4

Tool/software:

Hi,

In the ..\ti-processor-sdk-rtos-j784s4-evm-10_00_00_05\vxlib_10_00_00_02\test\VXLIB_convolve\test_data, there are cases for convolution test. 

Is the reference output correct? How is it calculated?

#ifdef WIN32
uint8_t staticRefInCase1[] =
#else
__attribute__((section (".staticData")))
     static uint8_t staticRefInCase1[] =
#endif
     {
        138, 142, 53, 184, 100, 166,
        121, 163, 136, 201, 220, 110,
        165, 24, 95, 180, 137, 221,
        37, 134, 74, 36, 82, 126,
        5, 41, 105, 228, 245, 127,
        148, 29, 157, 230, 145, 60,

     };

#ifdef WIN32
int16_t staticRefFilterCase1[] =
#else
__attribute__((section (".staticData")))
     static int16_t staticRefFilterCase1[] =
#endif
     {
        -1, 0, 2,
        2, 2, -1,
        2, 1, -1,

     };

#ifdef WIN32
uint8_t staticRefOutCase1[] =
#else
__attribute__((section (".staticData")))
     static uint8_t staticRefOutCase1[] =
#endif
     {
        51, 41, 68, 52,
        24, 70, 69, 45,
        20, 23, 30, 69,
        41, 29, 71, 75,

     };

  • Hi Teknik,

    Yes, the reference output (the array staticRefOutCase1) is the correct output for this particular test cases. This is generated using a python script that is run on PC to generate random input values and the correct output based on the algorithm.

    The generation scripts are in test/VXLIB_idat_gen. We can walk through VXLIB_convolve as an example:

    In test/VXLIB_idat_gen/VXLIB_convolve there are a few files. file_io.py and test_param_function.txt actually create the test data files in the directory you mention. The ones you would be interested in are test_cases_list.csv and gen_data.py. 

    test_cases_list.csv are the defined parameters for each test case. For example, this could be image width and height, the filter width and height (3x3 convolution, 5x5 convolution etc.)

    This gets read by gen_data.py to read in these parameters, create a random input, and use a python implementation of the algorithm to create the correct output. For the VXLIB_convolve case this uses scipy library to create the reference correct output - including a snippet of that below: 

    # use scipy library
    
    # use in mode=valid for non padded implementation
    out = signal.convolve2d(inp, convFilter, mode='valid')
    out = out >> scale;
    
    # saturate datatype
    out[out > maxValOut] = maxValOut
    out[out < minValOut] = minValOut

    Later, if running the test cases as described in the Build and Run instructions, the test cases will Pass/Fail based on comparing the optimized C7x code (in the src folder) to this python generated reference output. 

    Best,

    Asha