This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TDA4VM: TIDL output size question

Part Number: TDA4VM


Dear Support,

Like in the other topic (https://e2e.ti.com/support/processors/f/processors-forum/985590/tda4vm-preprocess-padding-question), I have the same question with the TIDL module's output sizes.
All the tensors should be 120x160xN. all ioBufDesc->outPadX[0] values are zero, while the tensor sizes in some cases differ from the expected.

    frame count:     8
    input width:     640
    input height:    480
    output width:    160
    output height:   120
    channel number:  16
Output padding: 0 0 0 0-- Number of output buffers: 4
-- Buffer [0] scale: 8.000000
-- Buffer [1] scale: 16.000000
-- Buffer [2] scale: 2.000000
-- Buffer [3] scale: 8.000000
--Pushing tensor 0
--Pushing channel 0
Tensor sizes: 120 160 8
--Pushing tensor 1
--Pushing channel 0
Tensor sizes: 124 226 3
--Pushing tensor 2
--Pushing channel 0
Tensor sizes: 124 226 4
--Pushing tensor 3
--Pushing channel 0
Tensor sizes: 124 226 1


Currently we are using the data from these tensors that has the fitting size of our network's output. Is this difference ok to have there?

BR,
Gergely

  • Hi Gergely,

       I don't expect the dimension of output tensors to change but the padding in the buffer can be different. In above example are you seeing that dimension itself is not N x 160 x120 ( instead you are seeing the tensor dimension as 124 226 )? If this understanding is correct then something does look wrong as tensor dimensions are not expected to change. Can you tell what values you are printing?


    Regards,

    Anshu

  • Hi Gregely,

        As we were expecting during the call, the first query gives the dimension of the tensors and the second query gives size of dimensions. I think you had the right documentation for this information. Following is the link : 

    https://www.khronos.org/registry/OpenVX/specs/1.2/html/d7/d0f/group__group__object__tensor.html

       So basically VX_TENSOR_DIMS attributes returns the size for jumping one dimension to the other. As I mentioned this need not be same as the dimension of the output tensors as there can be padding in the output buffer. Let me know if this is clear.


    Regards,
    Anshu

  • Hi Anshu,

    in the ioBufDesc, we have zero padding on the output. (7th line of the log in the top post.)

    printf(
        "Output padding: %d %d %d %d"
        , ioBufDesc->outPadT[0]
        , ioBufDesc->outPadR[0]
        , ioBufDesc->outPadB[0]
        , ioBufDesc->outPadL[0]
    );

  • Hi Gregely,

         Sorry I didn't follow your above comment. Are you saying that you are getting padding in ioBufDesc as zero for all the outputs?


    Regards,

    Anshu

  • Hi Anshu,

    Yes.

    BR,
    Gergely

  • Hi Gergely,

       The print message which you have shown above : 

    printf(
    "Output padding: %d %d %d %d"
    , ioBufDesc->outPadT[0]
    , ioBufDesc->outPadR[0]
    , ioBufDesc->outPadB[0]
    , ioBufDesc->outPadL[0]
    );

       This is printing the padding only for the zeroth output. Can you cross check this?

    Regards,

    Anshu

  • Hi Anshu,

    Here is the padding for all the output tensors.


    Output 0 padding: 0 0 0 0
    Output 1 padding: 2 0 64 4
    Output 2 padding: 2 0 64 4
    Output 3 padding: 2 0 64 4

  • Hi Gregely,

         As per the data which you have shared it is clear that padding is not all zero for all the output tensors. Except the first output rest of all the outputs have non-zero padding and I am guessing that this is order :

    outPadL= 2, outPadR=0, outPadT=4, outPadB=64

     So if I look at the buffer (assuming the print which you have matches above guess) the buffer should look like below in memory: 

    yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy

    yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy

    yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy

    yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy ( 4lines)

    xxaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

    xxaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

    xxaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

    xxaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

    zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz

    zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz

    zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz ( 64 lines)

      So here "y" is top padding ( 4 lines ), "x" is column padding on left side ( 2 columns) , "z" is bottom padding ( 64 lines) and "a" is valid data of tensor. Let me know if this is still not clear.


    Regards,
    Anshu

     

  • Dear Anshu,

    We found the solution. In the app_tidl_seg demo, tidl module source, writeTIDLOutput(...) the pOut pointer should be set this way:

    uint8_t *pOut =
        (uint8_t *)data_ptr
        + (tensor_sizes[0] * tensor_sizes[1] * k)
        + (ioBufDesc->outPadT[tensor_id] * tensor_sizes[0])
        + ioBufDesc->outPadL[tensor_id];
    

    It makes the output adaptive to the different outputs' padding instead of using the first one's.

    Is there any specific reason behind the different padding values on the different output tensors?

  • Hi Gregely,
        Its good to hear that now you are able to read the right output. The reason for different padding for different tensor is because the padding is decided by who is the producer or who is the consumer. There are certain kind of layers which can change the input and output padding whereas certain layers which cannot ( this is done mainly to get the best performance). So if a layer cannot change its padding then its padding is driven by which is the producer/consumer of that layer. This is the reason it can be different for different output tensors.

       Let me know if there is anything open in this thread? If not we will close this.

    Regards,

    Anshu