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: how to create custom node in sdk

Part Number: TDA4VM

Hi team,

The customer would like to know are there any guide to introduce of how to create a new kernel and then package to a new node, and if the node need some other input/output expect image?

For example:
This node's input and output are all char[]
the input date is "'1','2','3','4'"
the output date is "'2','4','6','8'"

Could you help check this case? Thanks.

Best Regards,

Cherry

  • Hi Cherry,

    You could use below link to understand how to add new kernel.

    https://software-dl.ti.com/jacinto7/esd/processor-sdk-rtos-jacinto7/latest/exports/docs/tiovx/docs/user_guide/TIOVX_TARGET_KERNEL.html

    For these kind input/output, you could use user data object.

    Regards,

    Brijesh

  • Hi Brijesh,

    The customer has tried to follow your advice, use https://software-dl.ti.com/jacinto7/esd/processor-sdk-rtos-jacinto7/latest/exports/docs/tiovx/docs/user_guide/PYTIOVX.html to create new kernels

    but when testing the example, the result is like this:

    xxx@xxxS:~/PycharmProjects/pythonProject$ export CUSTOM_APPLICATION_PATH=.
    xxx@xxxS:~/PycharmProjects/pythonProject$ python3 main.py 
    Generating C code for OpenVX kernel ...
    
    Creating new directories ...
    Creating new makefiles ...
    Creating new headers ...
    Creating new module-level sources ...
    Modifying ./concerto_inc.mak
    Modifying ./kernels/imaging/include/TI/tivx_imaging_kernels.h
    Modifying ./kernels/imaging/include/TI/tivx_imaging_nodes.h
    Modifying ./kernels/imaging/host/tivx_imaging_node_api.c
    Modifying ./kernels/imaging/host/tivx_imaging_kernels_priv.h
    Modifying ./kernels/imaging/host/vx_kernels_imaging_host.c
    Modifying ./kernels/imaging/c66/vx_kernels_imaging_target.c
    Modifying ./kernels/imaging/test/test_main.h
    Creating new kernel-specific files ...
    Creating ./kernels/imaging/host/tivx_kernel_channel_extract.h
    Creating ./kernels/imaging/host/vx_channel_extract_host.c
    Creating ./kernels/imaging/c66/vx_channel_extract_target.c
    Creating ./kernels/imaging/c66/bam/vx_bam_channel_extract_target.c
    
    Kernel: channel_extract CHANNEL_EXTRACT ChannelExtract
    Targets: TIVX_TARGET_DSP1(CPU: TIVX_CPU_ID_DSP1) TIVX_TARGET_DSP2(CPU: TIVX_CPU_ID_DSP2) 
    Param 0: IN VX_TYPE_IMAGE VX_INPUT VX_PARAMETER_STATE_REQUIRED
    Param 1: CHANNEL VX_TYPE_ENUM VX_INPUT VX_PARAMETER_STATE_REQUIRED
    Param 2: OUT VX_TYPE_IMAGE VX_OUTPUT VX_PARAMETER_STATE_REQUIRED
    
    Generating C code for OpenVX kernel ... DONE !!!
    Creating ./DEVELOPER_TODO.txt
    Traceback (most recent call last):
      File "main.py", line 12, in <module>
        code.export(kernel)
      File "/home/xxx/workspace/ti-processor-sdk-rtos-j721e-evm-07_03_00_07/tiovx/tools/PyTIOVX/tiovx/kernel_code.py", line 3082, in export
        self.todo()
      File "/home/xxx/workspace/ti-processor-sdk-rtos-j721e-evm-07_03_00_07/tiovx/tools/PyTIOVX/tiovx/kernel_code.py", line 3000, in todo
        with open(file, 'rb') as f:
    IsADirectoryError: [Errno 21] Is a directory: './venv/lib/python3.6'

    it seems not success

    And the customer writes a new code like this:

    from tiovx import *
    code = KernelExportCode(Module.TEST_KERNELS, Core.A72, "CUSTOM_APPLICATION_PATH")
    code.setCoreDirectory("A72")
    kernel = Kernel("test_job")
    kernel.setParameter(Type.OBJECT_ARRAY, Direction.INPUT, ParamState.REQUIRED, "IN")
    kernel.setParameter(Type.OBJECT_ARRAY, Direction.OUTPUT, ParamState.REQUIRED, "OUT")
    kernel.setParameterRelationship(["IN", "OUT"])
    kernel.setTarget(Target.A72_0)
    code.export(kernel)

    the result is this:

    Generating C code for OpenVX kernel ...
    
    Creating new directories ...
    Creating new makefiles ...
    Creating new headers ...
    Creating new module-level sources ...
    Modifying ./concerto_inc.mak
    Modifying ./kernels/test_kernels/include/TI/tivx_test_kernels_kernels.h
    Modifying ./kernels/test_kernels/include/TI/tivx_test_kernels_nodes.h
    Modifying ./kernels/test_kernels/host/tivx_test_kernels_node_api.c
    Modifying ./kernels/test_kernels/host/tivx_test_kernels_kernels_priv.h
    Modifying ./kernels/test_kernels/host/vx_kernels_test_kernels_host.c
    Modifying ./kernels/test_kernels/A72/vx_kernels_test_kernels_target.c
    Modifying ./kernels/test_kernels/test/test_main.h
    Creating new kernel-specific files ...
    Creating ./kernels/test_kernels/host/tivx_kernel_test_job.h
    Creating ./kernels/test_kernels/host/vx_test_job_host.c
    Traceback (most recent call last):
      File "main.py", line 9, in <module>
        code.export(kernel)
      File "/home/xxx/workspace/ti-processor-sdk-rtos-j721e-evm-07_03_00_07/tiovx/tools/PyTIOVX/tiovx/kernel_code.py", line 3076, in export
        self.generate_host_c_file_code()
      File "/home/xxx/workspace/ti-processor-sdk-rtos-j721e-evm-07_03_00_07/tiovx/tools/PyTIOVX/tiovx/kernel_code.py", line 882, in generate_host_c_file_code
        self.generate_host_c_validate_func_code()
      File "/home/xxx/workspace/ti-processor-sdk-rtos-j721e-evm-07_03_00_07/tiovx/tools/PyTIOVX/tiovx/kernel_code.py", line 568, in generate_host_c_validate_func_code
        if self.verify_parameter_relationship_items(self.kernel.relationship_list, prm, member, name) :
      File "/home/xxx/workspace/ti-processor-sdk-rtos-j721e-evm-07_03_00_07/tiovx/tools/PyTIOVX/tiovx/kernel_code.py", line 513, in verify_parameter_relationship_items
        if local_name.name == name :
    AttributeError: 'str' object has no attribute 'name'

    Could you help check is there anything wrong with the code?  and why the example in sdk is also can not success.

    Thanks and Best Regards,

    Cherry

  • Hi,

    May I know is there any updates about the info above?

    Thanks and Best Regards,

    Cherry

  • Hi Cherry,

    Which SDK version are you using?  This may have been fixed in later versions.

    Regards,

    Lucas

  • Hi Lucas,

    Which SDK version are you using? 

    The customer is using the version 7.3, and  due to specific reasons, they have to use this version.

    Thanks and Best Regards,

    Cherry

  • Hi,

    May I know is there any updates about the above question?

    Thanks and Best Regards,

    Cherry

  • Hi Cherry,

    It looks like there is a syntax error in the below line of the python file:

    kernel.setParameterRelationship(["IN", "OUT"])

    This needs to be something like the below, which specifically lists the attributes which need to be compared against each other:

    kernel.setParameterRelationship(["IN", "OUT"], [Attribute.Image.WIDTH, Attribute.Image.HEIGHT])

    Please see the below documentation for more details:

    https://software-dl.ti.com/jacinto7/esd/processor-sdk-rtos-jacinto7/latest/exports/docs/tiovx/docs/user_guide/classtiovx_1_1kernel_1_1Kernel.html#ad239edc626448754568bddc6ba7a6c83

    Regards,

    Lucas

  • Hi Lucas,

    Thanks for your update. 

    And the customer has follow your suggestion, it seems still cannot work.

    Please see the following code:

    (venv) xxx@xxx:~/PycharmProjects/pythonProject$ export CUSTOM_APPLICATION_PATH=.
    (venv) xxx@xxx:~/PycharmProjects/pythonProject$ python3 main.py 
    Generating C code for OpenVX kernel ...
    
    Creating new directories ...
    Creating new makefiles ...
    Creating new headers ...
    Creating new module-level sources ...
    Modifying ./concerto_inc.mak
    Modifying ./kernels/test_kernels/include/TI/tivx_test_kernels_kernels.h
    Modifying ./kernels/test_kernels/include/TI/tivx_test_kernels_nodes.h
    Modifying ./kernels/test_kernels/host/tivx_test_kernels_node_api.c
    Modifying ./kernels/test_kernels/host/tivx_test_kernels_kernels_priv.h
    Modifying ./kernels/test_kernels/host/vx_kernels_test_kernels_host.c
    Modifying ./kernels/test_kernels/A72/vx_kernels_test_kernels_target.c
    Modifying ./kernels/test_kernels/test/test_main.h
    Creating new kernel-specific files ...
    Creating ./kernels/test_kernels/host/tivx_kernel_test_job.h
    Creating ./kernels/test_kernels/host/vx_test_job_host.c
    Creating ./kernels/test_kernels/A72/vx_test_job_target.c
    
    Kernel: test_job TEST_JOB TestJob
    Targets: TIVX_TARGET_A72_0(CPU: TIVX_CPU_ID_A72_0) 
    Param 0: IN VX_TYPE_OBJECT_ARRAY VX_INPUT VX_PARAMETER_STATE_REQUIRED
    Param 1: OUT VX_TYPE_OBJECT_ARRAY VX_OUTPUT VX_PARAMETER_STATE_REQUIRED
    
    Generating C code for OpenVX kernel ... DONE !!!
    Creating ./DEVELOPER_TODO.txt
    Traceback (most recent call last):
      File "main.py", line 10, in <module>
        code.export(kernel)
      File "/home/yuwei/workspace/ti-processor-sdk-rtos-j721e-evm-07_03_00_07/tiovx/tools/PyTIOVX/tiovx/kernel_code.py", line 3082, in export
        self.todo()
      File "/home/yuwei/workspace/ti-processor-sdk-rtos-j721e-evm-07_03_00_07/tiovx/tools/PyTIOVX/tiovx/kernel_code.py", line 3000, in todo
        with open(file, 'rb') as f:
    IsADirectoryError: [Errno 21] Is a directory: './venv/lib/python3.6'

    with these log,  the error is as same as when running the example in sdk, so the customer would like to know how to fix this bug in 7.3

    and how to convert char[] or something else to vx_object_array

    Thanks and Best Regards,

    Cherry

  • Hello,

    Are you using the same python script or something different?  I am not seeing the issue using the one you sent in the original response.

    Also, I am not using a virtualenv, so perhaps that could be the issue.

    Regards,

    Lucas

  • Hello Lucas,

    It seems that the python script can not run in virtualenv, the python script is OK now. But the customer still don't know how to convert char[] or something else to vx_object_array, and didn't find any example in sdk.

    Could you help with this?

    Thanks and Best Regards,

    Cherry

  • Hello,

    Why are you trying to convert char[] into vx_object_array?  Can you please provide more details about the use case?  Is there a specific reason why this is needed and not a user data object?

    Regards,

    Lucas

  • Hi Lucas,

    The updates are as follows:

    Because they need to build a node. This node's input and output are all array, at first thet need make some test code, so need to set some date in vx_object_array for input, so they need to convert some default date like char[] or something else to vx_object_array to input.

    Thanks and Best Regards,

    Cherry

  • Hello,

    Can you please try using a vx_user_data_object?  I think this will be more appropriate for this situation.  There are several examples of this in the SDK as well.

    https://software-dl.ti.com/jacinto7/esd/processor-sdk-rtos-jacinto7/latest/exports/docs/tiovx/docs/user_guide/vx__khr__user__data__object_8h.html#a863903e2890171d914598216e0727d73

    Regards,

    Lucas

  • Hi Lucas,

    They have tried, just as follows:

    vx_char inputTest[5] = {'1','2','3','4','5'};
    vx_user_data_object inputUserData = vxCreateUserDataObject(vx_context_, "input", 5, (void*)inputTest);
    vx_object_array inputObjectArray = vxCreateObjectArray(context, (vx_reference)inputUserData, 1);

    and when set "inputObjectArray" to their node

    the error is like this:

    VX_ZONE_ERROR:[tivxMemBufferMap:309] tivxMemBufferMap failed (either pointer is NULL or size is 0)

    They checked the code, the error is in:

    tivxCheckStatus(&status, tivxMemBufferMap(in_target_ptr[i],
                   img_in_desc[i]->mem_size[0], (vx_enum)VX_MEMORY_TYPE_HOST,
                   (vx_enum)VX_READ_ONLY));

    and img_in_desc[i]->mem_size[0] I see is 0

    what they create python script is like this:

    from tiovx import *
    code = KernelExportCode(Module.READ_TXT, Core.A72, "CUSTOM_APPLICATION_PATH")
    code.setCoreDirectory("A72")
    kernel = Kernel("read_txt")
    kernel.setParameter(Type.OBJECT_ARRAY, Direction.INPUT, ParamState.REQUIRED, "IN")
    kernel.setParameter(Type.OBJECT_ARRAY, Direction.OUTPUT, ParamState.REQUIRED, "OUT")
    #kernel.setParameterRelationship(["IN", "OUT"])
    kernel.setParameterRelationship(["IN", "OUT"], [Attribute.ObjectArray.NUMITEMS, Attribute.ObjectArray.NUMITEMS])
    kernel.setTarget(Target.A72_0)
    code.export(kernel)

    and they have been used  vxGetStatus to check if the "inputUserData" and "inputObjectArray"

    vx_status statusUserData = vxGetStatus((vx_reference)inputUserData);
    statusUserData = vxGetStatus((vx_reference)inputObjectArray);

    the result is all VX_SUCCESS

    And the node code is from python script, they didn't write any code in.

    Thanks and Best Regards,

    Cherry

  • Hi Cherry,

    In this case, given that the processing on A72, the tivxMemBufferMap and tivxMemBufferUnmap are not needed.  Can these be commented out in the target kernel to see if there are any further issues seen.

    Regards,

    Lucas

  • Hi Lucas,

    Thanks for your support, but this may not so much helpful:

         because first, this is just a example, maybe they will run this node in DSP or some thing else;

         second, tivxMemBufferMap and tivxMemBufferUnmap is build by python script in sdk.

         their question is sample,  just need a example, which can tell how to create a vx_object_array by vx_user_data_object or how to create vx_user_data_object by vx_char[] or something else.

    Thanks and Best Regards,

    Cherry

  • Hello Cherry,

    If they want to create a vx_object_array by a vx_user_data_object then they are doing this correctly as per the sample code you have provided.  This does not need to involve a custom kernel.

    Regards,

    Lucas

  • Hello Lucas,

    Thanks for your reply. 

    Let's see this ticket:

    1. The customer would like to create I custom kernel, this kernel's input and output are vx_object_array

    2. creating kernel by sdk's python script, but when it's run, it will report error.

    3. checking the error and find the cause: the vx_object_array is not created correctly by vx_char[], but the customer still don't how to create vx_object_array by vx_char[].

    4. And for now the customer wants the sample about how to create vx_object_array by vx_char[], and make sure it will not report error in the kernel create by sdk.

    Thanks and Best Regards,

    Cherry

  • Hi,

    May I know is there any updates?

    Thanks and Best Regards,

    Cherry

  • Hi Cherry,

    Sorry, I am not following the current question. 

    You had mentioned that the customer does not need the sample kernel, but were instead just using this to know how to create a vx_object_array out of a vx_user_data_object which contains a character array. 

    As per your earlier response, they are doing this as shown below.  This looks to be correct. 

    vx_char inputTest[5] = {'1','2','3','4','5'};
    vx_user_data_object inputUserData = vxCreateUserDataObject(vx_context_, "input", 5, (void*)inputTest);
    vx_object_array inputObjectArray = vxCreateObjectArray(context, (vx_reference)inputUserData, 1);

    The error they were getting had to do with the custom kernel.  It looks like there is a bug in the custom kernel generation script in which the kernel outputs the tivxMemMap functions if it is running on the A72.  This should not be the case, as these are only needed if done on the remote cores.  If they would like to use this custom kernel still, they can comment out these functions in the custom kernel and can re-test.  If there are further issues with this, please let me know and we can work to resolve them.

    Are there other questions that you have that I have not answered?

    Regards,

    Lucas

  • Hello Lucas,

    Thanks for your response.

    The customer have a try but seems not correct:

    When creating  vx_object_array:

    vx_image nv12_image =vxCreateImage(context, inWidth, inHeight, VX_DF_IMAGE_NV12);
    vx_object_array disp_frames = vxCreateObjectArray(context, (vx_reference)nv12_image, num_channels);

    The error is as below:

    VX_ZONE_ERROR:[tivxMemBufferMap:309] tivxMemBufferMap failed (either pointer is NUL


    It won't output and all the custom kernel is the same.
    So they believe tivxMemMap functions run in A72 is ok.
    And they also would like to know why is vx_object_array created by vx_image is ok but by vx_char[] is wrong?
    Thanks and regards,
    Cherry
  • Hello,

    Is the custom node still running on A72?  If so, please try commenting out the tivxMemBufferMap and tivxMemBufferUnmap calls and re-running.

    Regards,

    Lucas

  • Hi Lucas,

    Here's the feedback from the customer:

    "It not just comment out can resolve, because this is just a example, when we run custom node in our project, the node's input not just vx_object_array, it will vx_image、vx_object_array, both of them we need to run in this node, so if I just comment out the tivxMemBufferMap and tivxMemBufferUnmap, the vx_image which I input will be ok? I don't think so"

    Thanks and regards,

    Cherry

  • Hi Cherry,

    I'm a bit confused by the use case.  As I understood this, the sample node was only being used to prove whether or not the object array can be made of a character array.  Is this the case or is there more needed by the sample node?  If the sample node is required for the use case, can you please provide answers to the following questions:

    What is the interface of the node that is being used?  Initially it looked like this was only object arrays but now it appears that images are required as well.

    What core or cores is this node needing to run on?  In the example, the A72 was used, but based on some responses, it looks like there may be a requirement of other cores as well.

    Regards,

    Lucas