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: Generating C code for OpenVX Kernel KeyError

Part Number: TDA4VM

Hello,

I get following error while generating my custom kernel:

python3 fill_pixel_kernel_wrapper.py
Generating C code for OpenVX kernel ...

Creating new directories ...
Creating new makefiles ...
Creating new headers ...
Creating new module-level sources ...
Modifying /home/daniel/Documents/PSDK/RTOS/vision_apps/apps/basic_demos/app_daniel_final//concerto_inc.mak
Modifying /home/daniel/Documents/PSDK/RTOS/vision_apps/apps/basic_demos/app_daniel_final//kernels/imaging/include/TI/tivx_imaging_kernels.h
Traceback (most recent call last):
  File "/usr/lib/python3.8/sre_parse.py", line 1039, in parse_template
    this = chr(ESCAPES[this][1])
KeyError: '\\s'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "fill_pixel_kernel_wrapper.py", line 21, in <module>
    code.export(kernel)
  File "/home/daniel/Documents/PSDK/RTOS/tiovx/tools/PyTIOVX/tiovx/kernel_code.py", line 3110, in export
    self.modify_files()
  File "/home/daniel/Documents/PSDK/RTOS/tiovx/tools/PyTIOVX/tiovx/kernel_code.py", line 2669, in modify_files
    self.modify_kernel_header_file()
  File "/home/daniel/Documents/PSDK/RTOS/tiovx/tools/PyTIOVX/tiovx/kernel_code.py", line 2798, in modify_kernel_header_file
    CodeModify().block_insert(self.include_customer_kernels_filename,
  File "/home/daniel/Documents/PSDK/RTOS/tiovx/tools/PyTIOVX/tiovx/code_modify.py", line 114, in block_insert
    self.multiline = re.sub(search,insert + searchNoEsc, self.multiline)
  File "/usr/lib/python3.8/re.py", line 210, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "/usr/lib/python3.8/re.py", line 327, in _subx
    template = _compile_repl(template, pattern)
  File "/usr/lib/python3.8/re.py", line 318, in _compile_repl
    return sre_parse.parse_template(repl, pattern)
  File "/usr/lib/python3.8/sre_parse.py", line 1042, in parse_template
    raise s.error('bad escape %s' % this, len(this))
re.error: bad escape \s at position 39 (line 2, column 5)

This is my kernel code:

from tiovx import *

code = KernelExportCode(Module.IMAGING, Core.A72, "CUSTOM_APPLICATION_PATH")

code.setCoreDirectory("a72")

kernel = Kernel("fill_pixel")

kernel.setParameter(Type.IMAGE, Direction.INPUT, ParamState.REQUIRED, "IN_IMAGE", ['VX_DF_IMAGE_U8'])
kernel.setParameter(Type.UINT8, Direction.INPUT, ParamState.REQUIRED, "IN_VALUE", ['VX_TYPE_UINT8'])
kernel.setParameter(Type.IMAGE, Direction.OUTPUT, ParamState.REQUIRED, "OUT_IMAGE", ['VX_DF_IMAGE_U8'])
kernel.setParameterRelationship(["IN_IMAGE", "OUT_IMAGE"], [Attribute.Image.WIDTH, Attribute.Image.HEIGHT])
kernel.allocateLocalMemory("img_scratch_mem", ["width*height"], "IN_IMAGE")

kernel.setTarget(Target.DSP1)
kernel.setTarget(Target.DSP2)
kernel.setTarget(Target.IPU1_0)
kernel.setTarget(Target.IPU1_1)
kernel.setTarget(Target.IPU2)

code.export(kernel)

What is wrong with it?

Looking forward to hear some ideas.

Thank you.

Daniel

  • Hi Daniel,

    May I know which SDK version are you facing this issue?

    Could I know where is the CUSTOM_APPLICATION_PATH pointed to?

    Regards,
    Nikhil

  • Hi Nikhil,

    thanks for the reply.

    1.SDK version: 08_02_00

    2. CUSTOM_APPLICATION_PATH=/home/daniel/Documents/PSDK/RTOS/vision_apps/apps/basic_demos/app_daniel_final

    Regards,

    Daniel

  • Hi Daniel,

    I had copied the above python code into SDK8.2 and was able to generate in the path RTOS/vision_apps/apps/basic_demos/app_daniel_final with python version 3.8.13.

    I kept the file.py file in app_daniel_final folder and ran the below command

    python3 file.py


    I'm able to run it successfully and generate the files.

    One suggestion, could you try the same with python 3.6 version?
    Are you using ubuntu18 or 20?

    Regards,
    Nikhil

  • Hi Nikhil,

    Thanks for your reply.

    I had another kernel.py file but it used the same module (also Module.Imaging). Somehow it created a conflict. Since I use now another module (Module.TEST_KERNELS) for the second file there is no error anymore.

    Is there a way to integrate both kernels in the same module and can I build custom modules?

    I am use KDE Plasma Version: 5.25.4

    Regards,

    Daniel

  • Hi Daniel,

    You could do something like below

    code = KernelExportCode("test_module", Core.C66, "VISION_APPS_PATH")

    kernel = Kernel("kernel1")

    kernel.setParameter(Type.ARRAY, Direction.INPUT, ParamState.REQUIRED, "INPUT")
    kernel.setParameter(Type.ARRAY, Direction.OUTPUT, ParamState.REQUIRED, "OUTPUT")

    kernel.setTarget(Target.DSP1)
    kernel.setTarget(Target.DSP2)

    code.export(kernel)
    code.exportDiagram(kernel)

    ## Next kernel

    code = KernelExportCode("test_module", Core.C66, "VISION_APPS_PATH")
    kernel = Kernel("kernel2")

    kernel.setParameter(Type.ARRAY, Direction.INPUT, ParamState.REQUIRED, "INPUT2")
    kernel.setParameter(Type.ARRAY, Direction.OUTPUT, ParamState.REQUIRED, "OUTPUT2")

    kernel.setTarget(Target.DSP1)
    kernel.setTarget(Target.DSP2)

    code.export(kernel)
    code.exportDiagram(kernel)

    Is this what you are looking for?

    Regards,
    Nikhil