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 guys,

I'm new to openvx, in TDA4, 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'"

Thanks a lot.

best regard,



  • Hi we have got your question and feedback to the engineer. Please expect the response. Thanks!

  • Hi dear,

    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,

    Cherry

  • Hello dear,

    I 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 I test your 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 I write 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'

    I don't know what's the problem of my code, and why the example in sdk is also can not success

    Please help

    Thanks a lot

    best regard,

    yuwei

  • Hi,

    Sorry for the delay response.

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

    Thanks and Best Regards,

    Cherry

  • the 7.3 and for company reasons, I have to use this version

  • Noted and I will feedback to the engineer, please expect the response.

  • Hi Dear,

    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

  • when I follow your suggestion, it seems still not working yet.

    the result is like this

    (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, I don't know if it's ok or not, the error as same as when I run the example in sdk, so I think I need to know how to fix this bug in 7.3

    and I still need to know how to convert char[] or something else to vx_object_array

  • Hi,

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

    Also, we are not using a virtualenv, so perhaps that could be the issue.

    Best Regards,

    Cherry

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

  • Hi dear,

    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?

    Thanks and Best Regards,

    Cherry

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

  • Hi dear,

    Can you please try using a vx_user_data_object?  We 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

    Thanks and Best Regards,

    Cherry

  • I have been try to use vx_user_data_object like this

    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 I set "inputObjectArray" to myself node

    the error is like this

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

    I 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 I 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 I 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, I didn't write any code in them

  • The problem is seems that the vx_object_array is not create right, so I think I need to know 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

  • Hi dear,

    We have forwarded your updates to the engineer. Please be noted that due to the Christmas and New Year's Holidays, responses may be delayed from 12/20/21 - 1/3/22. Sorry for the inconvenience!

    Thanks and Best Regards,

    Cherry

  • Hi,

    Sorry for the delay in response.

    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.

    Thanks and regards,

    Cherry

  • Hello,

         I don't think this is tell me how to resolve my problem.

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

         second, tivxMemBufferMap and tivxMemBufferUnmap is build by python script in sdk, I don't think remove these code is the way to resolve problem.

         my question is sample, I just need a example, which can tell me 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, because I do not know which part of my code is wrong.

    Thanks a lot

  • Hi,

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

    Thanks and regards,

    Cherry

  • Hello,

         I think we should see what happen in this ticket

         First, I want to create I custom kernel, this kernel's input and output are vx_object_array

         Then, I create kernel by sdk's python script, but when it's run, it will report error.

          So, I check this error and find it's my problem, the vx_object_array not create right by vx_char[], but I didn't find how to create vx_object_array by vx_char[].

          At last, I ask my question, and the question is sample, just tell how to create vx_object_array by vx_char[], and make sure it will not report error in the kernel create by sdk.

    Thanks a lot

  • Hello,

    You had mentioned that the you don't  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. 

    You 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 you 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 you would like to use this custom kernel still, you can comment out these functions in the custom kernel and can re-test.  If there are further issues with this, please let us know and we can work to resolve them.

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

  • ok, I will try to re-test them

  • Hello,

    I find it seems not right, because when I create vx_object_array like this

    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
    VX_ZONE_ERROR:[tivxMemBufferMap:309] tivxMemBufferMap failed (either pointer is NUL

    will not output
    and all the custom kernel is same
    so, I think tivxMemMap functions run in A72 is ok.
    And I think I need to know why is vx_object_array created by vx_image is ok but by vx_char[] is wrong
  • Hello,

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

  • Hello,

    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

  • Hi,

    Below is the update from engineer:

    "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."