Using NPU for self-created model using python

Which system do you use? Android, Ubuntu, OOWOW or others?

I am using Ubuntu

Which version of system do you use? Please provide the version of the system here:

I am using Ubuntu 22.04 LTS on VIM3L, and using WSL (Ubuntu 24.04) to convert the model.

Please describe your issue below:

  1. I am trying to use NPU on VIM3L. I am using self created tflite model. I first tried following NPU TFLite Delegate [Khadas Docs]. I tried using my own tflite model similar to example in the github in python.
    vx_delegate = tflite.load_delegate(
    library = DELEGATE_PATH,
    options={“logging-severity”:“debug”}
    )

interpreter = tflite.Interpreter(
model_path = MODEL_PATH,
experimental_delegates = [vx_delegate]
)
But it gives osError: libclc.so cannot open shared object file. No such file or directory.
Do I need to build libclc from source?

  1. Because above did not work, I tried converting my model using ksnn, following documents again. But it required me to input --source-files. My model takes array shape of 1,960,46. But the example used source files of image. What other formats can the source-file take?

Any help would be very much appreciated

Hello @andrewkim,

you shouldn’t need to compile any new libraries to make it work, there could be an issue of the library not being in the place it is expected to be.

Could you share the output of

$ ldd /usr/lib/libtim-vx.so

You can also provide .npy files as well for input, with a sample data of the input shape.

Hello,

Here is my output of ldd /usr/lib/libtim-vx.so

khadas@Khadas:~$ ldd /usr/lib/libtim-vx.so
linux-vdso.so.1 (0x0000007f9a689000)
libCLC.so => not found
libGAL.so => /lib/libGAL.so (0x0000007f99980000)
libOpenVX.so.1 => /lib/libOpenVX.so.1 (0x0000007f996f0000)
libOpenVXU.so => /lib/libOpenVXU.so (0x0000007f996d0000)
libVSC.so => not found
libArchModelSw.so => /lib/libArchModelSw.so (0x0000007f99660000)
libNNArchPerf.so => /lib/libNNArchPerf.so (0x0000007f995f0000)
libstdc++.so.6 => /lib/aarch64-linux-gnu/libstdc++.so.6 (0x0000007f993c0000)
libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000007f99320000)
libgcc_s.so.1 => /lib/aarch64-linux-gnu/libgcc_s.so.1 (0x0000007f992f0000)
libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000007f99140000)
libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000007f99120000)
libdl.so.2 => /lib/aarch64-linux-gnu/libdl.so.2 (0x0000007f99100000)
librt.so.1 => /lib/aarch64-linux-gnu/librt.so.1 (0x0000007f990e0000)
libVSC_Lite.so => /lib/libVSC_Lite.so (0x0000007f990a0000)
/lib/ld-linux-aarch64.so.1 (0x0000007f9a650000)

@andrewkim It seems certain necessary libraries are missing, have you setup openCL on your device ?
please share the outputs of:

$ uname -a
$ clinfo

khadas@Khadas:~$ uname -a
Linux Khadas 5.15.119 #1.6.9 SMP PREEMPT Tue Jun 18 20:47:11 HST 2024 aarch64 aarch64 aarch64 GNU/Linux
khadas@Khadas:~$ clinfo
Number of platforms 1
Platform Name ARM Platform
Platform Vendor ARM
Platform Version OpenCL 3.0 v1.r44p0-wayland-drm-g31-dmaheap-aarch64-f1df9978c-62.0fa1cf37607cffc6431e27529c54fffc
Platform Profile FULL_PROFILE
Platform Extensions cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_3d_image_writes cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_fp16 cl_khr_icd cl_khr_egl_image cl_khr_image2d_from_buffer cl_khr_depth_images cl_khr_il_program cl_khr_priority_hints cl_khr_create_command_queue cl_khr_spirv_no_integer_wrap_decoration cl_khr_extended_versioning cl_khr_device_uuid cl_khr_suggested_local_work_size cl_khr_extended_bit_ops cl_khr_semaphore cl_khr_external_semaphore cl_khr_external_semaphore_sync_fd cl_khr_external_memory cl_khr_external_memory_dmabuf cl_khr_command_buffer cl_arm_core_id cl_arm_printf cl_arm_non_uniform_work_group_size cl_arm_import_memory cl_arm_import_memory_dma_buf cl_arm_import_memory_host cl_arm_import_memory_protected cl_arm_job_slot_selection cl_arm_scheduling_controls cl_arm_controlled_kernel_termination cl_ext_cxx_for_opencl cl_ext_image_tiling_control cl_ext_image_requirements_info cl_ext_image_from_buffer cl_ext_yuv_images
Platform Extensions with Version cl_khr_global_int32_base_atomics 0x400000 (1.0.0)
cl_khr_global_int32_extended_atomics 0x400000 (1.0.0)
cl_khr_local_int32_base_atomics 0x400000 (1.0.0)
cl_khr_local_int32_extended_atomics 0x400000 (1.0.0)
cl_khr_byte_addressable_store 0x400000 (1.0.0)
cl_khr_3d_image_writes 0x400000 (1.0.0)
cl_khr_int64_base_atomics 0x400000 (1.0.0)
cl_khr_int64_extended_atomics 0x400000 (1.0.0)
cl_khr_fp16 0x400000 (1.0.0)
cl_khr_icd 0x400000 (1.0.0)
cl_khr_egl_image 0x400000 (1.0.0)
cl_khr_image2d_from_buffer 0x400000 (1.0.0)
cl_khr_depth_images 0x400000 (1.0.0)
cl_khr_il_program 0x400000 (1.0.0)
cl_khr_priority_hints 0x400000 (1.0.0)
cl_khr_create_command_queue 0x400000 (1.0.0)
cl_khr_spirv_no_integer_wrap_decoration 0x400000 (1.0.0)
cl_khr_extended_versioning 0x400000 (1.0.0)
cl_khr_device_uuid 0x400000 (1.0.0)
cl_khr_suggested_local_work_size 0x400000 (1.0.0)
cl_khr_extended_bit_ops 0x400000 (1.0.0)
cl_khr_semaphore 0x9000 (0.9.0)
cl_khr_external_semaphore 0x9000 (0.9.0)
cl_khr_external_semaphore_sync_fd 0x9000 (0.9.0)
cl_khr_external_memory 0x9000 (0.9.0)
cl_khr_external_memory_dmabuf 0x9000 (0.9.0)
cl_khr_command_buffer 0x9000 (0.9.0)
cl_arm_core_id 0x400000 (1.0.0)
cl_arm_printf 0x800000 (2.0.0)
cl_arm_non_uniform_work_group_size 0x400000 (1.0.0)
cl_arm_import_memory 0x401000 (1.1.0)
cl_arm_import_memory_dma_buf 0x400000 (1.0.0)
cl_arm_import_memory_host 0x400000 (1.0.0)
cl_arm_import_memory_protected 0x400000 (1.0.0)
cl_arm_job_slot_selection 0x400000 (1.0.0)
cl_arm_scheduling_controls 0x4000 (0.4.0)
cl_arm_controlled_kernel_termination 0x400000 (1.0.0)
cl_ext_cxx_for_opencl 0x400000 (1.0.0)
cl_ext_image_tiling_control 0x1000 (0.1.0)
cl_ext_image_requirements_info 0x5000 (0.5.0)
cl_ext_image_from_buffer 0x400000 (1.0.0)
cl_ext_yuv_images 0x1000 (0.1.0)
Platform Numeric Version 0xc00000 (3.0.0)
Platform Extensions function suffix ARM
Platform Host timer resolution 1ns

Platform Name ARM Platform
Number of devices 1
Device Name Mali-G31 r0p0
Device Vendor ARM
Device Vendor ID 0x70930000
Device Version OpenCL 3.0 v1.r44p0-wayland-drm-g31-dmaheap-aarch64-f1df9978c-62.0fa1cf37607cffc6431e27529c54fffc
Device UUID 00009370-0100-0000-0000-000000000000
Driver UUID a666621c-eeb3-73e0-dddd-d8097172d438
Valid Device LUID No
Device LUID 0000-000000000000
Device Node Mask 0
Device Numeric Version 0xc00000 (3.0.0)
Driver Version 3.0
Device OpenCL C Version OpenCL C 3.0 v1.r44p0-wayland-drm-g31-dmaheap-aarch64-f1df9978c-62.0fa1cf37607cffc6431e27529c54fffc
Device OpenCL C all versions OpenCL C 0x400000 (1.0.0)
OpenCL C 0x401000 (1.1.0)
OpenCL C 0x402000 (1.2.0)
OpenCL C 0x800000 (2.0.0)
OpenCL C 0xc00000 (3.0.0)
Device OpenCL C features __opencl_c_images 0x400000 (1.0.0)
__opencl_c_int64 0x400000 (1.0.0)
__opencl_c_3d_image_writes 0x402000 (1.2.0)
__opencl_c_atomic_order_acq_rel 0x800000 (2.0.0)
__opencl_c_atomic_order_seq_cst 0x800000 (2.0.0)
__opencl_c_atomic_scope_device 0x800000 (2.0.0)
__opencl_c_atomic_scope_all_devices 0x800000 (2.0.0)
__opencl_c_device_enqueue 0x800000 (2.0.0)
__opencl_c_generic_address_space 0x800000 (2.0.0)
__opencl_c_pipes 0x800000 (2.0.0)
__opencl_c_program_scope_global_variables 0x800000 (2.0.0)
__opencl_c_read_write_images 0x800000 (2.0.0)
__opencl_c_work_group_collective_functions 0x800000 (2.0.0)
Device C++ for OpenCL Numeric Version 0x400000 (1.0.0)
Latest comfornace test passed v2021-03-05-00
Device Type GPU
Device Profile FULL_PROFILE
Device Available Yes
Compiler Available Yes
Linker Available Yes
Max compute units 1
Available core IDs 0
Available job slots (ARM) 1-2
Max clock frequency 5MHz
Device Partition (core)
Max number of sub-devices 0
Supported partition types None
Supported affinity domains (n/a)
Max work item dimensions 3
Max work item sizes 256x256x256
Max work group size 256
Preferred work group size multiple (device) 4
Preferred work group size multiple (kernel) 4
Max sub-groups per work group 0
Preferred / native vector sizes
char 16 / 4
short 8 / 2
int 4 / 1
long 2 / 1
half 8 / 2 (cl_khr_fp16)
float 4 / 1
double 0 / 0 (n/a)
Half-precision Floating-point support (cl_khr_fp16)
Denormals Yes
Infinity and NANs Yes
Round to nearest Yes
Round to zero Yes
Round to infinity Yes
IEEE754-2008 fused multiply-add Yes
Support is emulated in software No
Single-precision Floating-point support (core)
Denormals Yes
Infinity and NANs Yes
Round to nearest Yes
Round to zero Yes
Round to infinity Yes
IEEE754-2008 fused multiply-add Yes
Support is emulated in software No
Correctly-rounded divide and sqrt operations No
Double-precision Floating-point support (n/a)
Address bits 64, Little-Endian
Global memory size 509887488 (486.3MiB)
Error Correction support No
Max memory allocation 509887488 (486.3MiB)
Unified memory for Host and Device Yes
Shared Virtual Memory (SVM) capabilities (core)
Coarse-grained buffer sharing Yes
Fine-grained buffer sharing No
Fine-grained system sharing No
Atomics No
Minimum alignment for any data type 128 bytes
Alignment of base address 1024 bits (128 bytes)
Preferred alignment for atomics
SVM 0 bytes
Global 0 bytes
Local 0 bytes
Atomic memory capabilities relaxed, acquire/release, sequentially-consistent, work-item scope, work-group scope, device scope, all-devices scope
Atomic fence capabilities relaxed, acquire/release, sequentially-consistent, work-item scope, work-group scope, device scope, all-devices scope
Max size for global variable 65536 (64KiB)
Preferred total size of global vars 0
Global Memory cache type Read/Write
Global Memory cache size 65536 (64KiB)
Global Memory cache line size 64 bytes
Image support Yes
Max number of samplers per kernel 16
Max size for 1D images from buffer 65536 pixels
Max 1D or 2D image array size 2048 images
Base address alignment for 2D image buffers 32 bytes
Pitch alignment for 2D image buffers 64 pixels
Max 2D image size 16384x16384 pixels
Max 3D image size 2048x2048x2048 pixels
Max number of read image args 128
Max number of write image args 64
Max number of read/write image args 64
Pipe support Yes
Max number of pipe args 16
Max active pipe reservations 1
Max pipe packet size 1024
Local memory type Global
Local memory size 32768 (32KiB)
Max number of constant args 128
Max constant buffer size 509887488 (486.3MiB)
Generic address space support Yes
Max size of kernel argument 1024
Queue properties (on host)
Out-of-order execution Yes
Profiling Yes
Device enqueue capabilities supported, replaceable default queue
Queue properties (on device)
Out-of-order execution Yes
Profiling Yes
Preferred size 2097152 (2MiB)
Max size 16777216 (16MiB)
Max queues on device 1
Max events on device 1024
Prefer user sync for interop No
Profiling timer resolution 1000ns
Execution capabilities
Run OpenCL kernels Yes
Run native kernels No
Non-uniform work-groups Yes
Work-group collective functions Yes
Sub-group independent forward progress No
IL version SPIR-V_1.0
ILs with version SPIR-V 0x400000 (1.0.0)
printf() buffer size 1048576 (1024KiB)
Built-in kernels (n/a)
Built-in kernels with version (n/a)
Device Extensions cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_3d_image_writes cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_fp16 cl_khr_icd cl_khr_egl_image cl_khr_image2d_from_buffer cl_khr_depth_images cl_khr_il_program cl_khr_priority_hints cl_khr_create_command_queue cl_khr_spirv_no_integer_wrap_decoration cl_khr_extended_versioning cl_khr_device_uuid cl_khr_suggested_local_work_size cl_khr_extended_bit_ops cl_khr_semaphore cl_khr_external_semaphore cl_khr_external_semaphore_sync_fd cl_khr_external_memory cl_khr_external_memory_dmabuf cl_khr_command_buffer cl_arm_core_id cl_arm_printf cl_arm_non_uniform_work_group_size cl_arm_import_memory cl_arm_import_memory_dma_buf cl_arm_import_memory_host cl_arm_import_memory_protected cl_arm_job_slot_selection cl_arm_scheduling_controls cl_arm_controlled_kernel_termination cl_ext_cxx_for_opencl cl_ext_image_tiling_control cl_ext_image_requirements_info cl_ext_image_from_buffer cl_ext_yuv_images
Device Extensions with Version cl_khr_global_int32_base_atomics 0x400000 (1.0.0)
cl_khr_global_int32_extended_atomics 0x400000 (1.0.0)
cl_khr_local_int32_base_atomics 0x400000 (1.0.0)
cl_khr_local_int32_extended_atomics 0x400000 (1.0.0)
cl_khr_byte_addressable_store 0x400000 (1.0.0)
cl_khr_3d_image_writes 0x400000 (1.0.0)
cl_khr_int64_base_atomics 0x400000 (1.0.0)
cl_khr_int64_extended_atomics 0x400000 (1.0.0)
cl_khr_fp16 0x400000 (1.0.0)
cl_khr_icd 0x400000 (1.0.0)
cl_khr_egl_image 0x400000 (1.0.0)
cl_khr_image2d_from_buffer 0x400000 (1.0.0)
cl_khr_depth_images 0x400000 (1.0.0)
cl_khr_il_program 0x400000 (1.0.0)
cl_khr_priority_hints 0x400000 (1.0.0)
cl_khr_create_command_queue 0x400000 (1.0.0)
cl_khr_spirv_no_integer_wrap_decoration 0x400000 (1.0.0)
cl_khr_extended_versioning 0x400000 (1.0.0)
cl_khr_device_uuid 0x400000 (1.0.0)
cl_khr_suggested_local_work_size 0x400000 (1.0.0)
cl_khr_extended_bit_ops 0x400000 (1.0.0)
cl_khr_semaphore 0x9000 (0.9.0)
cl_khr_external_semaphore 0x9000 (0.9.0)
cl_khr_external_semaphore_sync_fd 0x9000 (0.9.0)
cl_khr_external_memory 0x9000 (0.9.0)
cl_khr_external_memory_dmabuf 0x9000 (0.9.0)
cl_khr_command_buffer 0x9000 (0.9.0)
cl_arm_core_id 0x400000 (1.0.0)
cl_arm_printf 0x800000 (2.0.0)
cl_arm_non_uniform_work_group_size 0x400000 (1.0.0)
cl_arm_import_memory 0x401000 (1.1.0)
cl_arm_import_memory_dma_buf 0x400000 (1.0.0)
cl_arm_import_memory_host 0x400000 (1.0.0)
cl_arm_import_memory_protected 0x400000 (1.0.0)
cl_arm_job_slot_selection 0x400000 (1.0.0)
cl_arm_scheduling_controls 0x4000 (0.4.0)
cl_arm_controlled_kernel_termination 0x400000 (1.0.0)
cl_ext_cxx_for_opencl 0x400000 (1.0.0)
cl_ext_image_tiling_control 0x1000 (0.1.0)
cl_ext_image_requirements_info 0x5000 (0.5.0)
cl_ext_image_from_buffer 0x400000 (1.0.0)
cl_ext_yuv_images 0x1000 (0.1.0)

NULL platform behavior
clGetPlatformInfo(NULL, CL_PLATFORM_NAME, …) ARM Platform
clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, …) Success [ARM]
clCreateContext(NULL, …) [default] Success [ARM]
clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT) Success (1)
Platform Name ARM Platform
Device Name Mali-G31 r0p0
clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU) No devices found in platform
clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU) Success (1)
Platform Name ARM Platform
Device Name Mali-G31 r0p0
clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR) No devices found in platform
clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM) No devices found in platform
clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL) Success (1)
Platform Name ARM Platform
Device Name Mali-G31 r0p0

ICD loader properties
ICD loader Name OpenCL ICD Loader
ICD loader Vendor OCL Icd free software
ICD loader Version 2.2.14
ICD loader Profile OpenCL 3.0
khadas@Khadas:~$

This is my output of

$ uname -a
$ clinfo

@andrewkim can you try downloading these libraries files and placing them inside /usr/lib and seeing if you are able to run the examples again ?

$ wget https://github.com/sravansenthiln1/testdev/releases/download/v0.3/libCLC.so
$ wget https://github.com/sravansenthiln1/testdev/releases/download/v0.3/libVSC.so
$ sudo mv libCLC.so /usr/lib/libCLC.so
$ sudo mv libVSC.so /usr/lib/libVSC.so

Hi @ Electr1,

I downloaded the libraries and tried running again.

Vx delegate: allowed_cache_mode set to 0.
Vx delegate: device num set to 0.
Vx delegate: allowed_builtin_code set to 0.
Vx delegate: error_during_init set to 0.
Vx delegate: error_during_prepare set to 0.
Vx delegate: error_during_invoke set to 0.
./mmwave/epoch=19-step=800-per-epoch-kappa=0.5447_float32.tflite
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 56: default layout inference pass.
W [HandleLayoutInfer:291]Op 56: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 56: default layout inference pass.
W [HandleLayoutInfer:291]Op 56: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
E [/home/zephyr/Documents/npu/wksp/tim-vx/src/tim/vx/internal/src/kernel/vsi_nn_kernel.c:_gpu_register:617]Build program fail.
E [/home/zephyr/Documents/npu/wksp/tim-vx/src/tim/vx/internal/src/kernel/vsi_nn_kernel.c:vsi_nn_kernel_create_node:892]Register client kernel com.vivantecorp.extension.evis.gemm_F32F32toF32 fail with -3.
E [/home/zephyr/Documents/npu/wksp/tim-vx/src/tim/vx/internal/src/kernel/vsi_nn_kernel.c:_gpu_register:617]Build program fail.
E [/home/zephyr/Documents/npu/wksp/tim-vx/src/tim/vx/internal/src/kernel/vsi_nn_kernel.c:vsi_nn_kernel_create_node:892]Register client kernel com.vivantecorp.extension.cl.gemm_F32F32toF32_3D fail with -3.
W [vsi_nn_kernel_selector:1288]No valid kernel for matrixmul
E [/home/zephyr/Documents/npu/wksp/tim-vx/src/tim/vx/internal/src/vsi_nn_graph.c:compute_node:387]Create node[295] MATRIXMUL fail
Segmentation fault

I am getting segmentation fault on this machine (Linux Khadas 5.15.119 #1.6.9 SMP PREEMPT Tue Jun 18 20:47:11 HST 2024 aarch64 aarch64 aarch64 GNU/Linux).

I used another VIM3L and flashed with new image: vim3l-ubuntu-20.04-gnome-linux-4.9-fenix-1.5-230425-emmc.img.xz
uname -a for this machine is Linux Khadas 4.9.241 #12 SMP PREEMPT Tue Apr 25 09:16:06 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux

The libclc.so was present by following the doc, but I still see similar issue.
I load my own tflite model with this and run inference.

# Set path to the  VX_delegate Libraries
#
# Delegate path:
DELEGATE_PATH = "./libvx_delegate.so"

vx_delegate = tflite.load_delegate(
    library = DELEGATE_PATH,
    options={"logging-severity":"debug"}
)

interpreter = tflite.Interpreter(model_path=tflite_path, experimental_delegates = [vx_delegate])

I am still seeing similar error messages while running.

Vx delegate: allowed_cache_mode set to 0.
Vx delegate: device num set to 0.
Vx delegate: allowed_builtin_code set to 0.
Vx delegate: error_during_init set to 0.
Vx delegate: error_during_prepare set to 0.
Vx delegate: error_during_invoke set to 0.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 56: default layout inference pass.
W [HandleLayoutInfer:291]Op 56: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
W [HandleLayoutInfer:291]Op 162: default layout inference pass.
E [/home/zephyr/Documents/npu/wksp/tim-vx/src/tim/vx/internal/src/kernel/vsi_nn_kernel.c:_gpu_register:617]Build program fail.
E [/home/zephyr/Documents/npu/wksp/tim-vx/src/tim/vx/internal/src/kernel/vsi_nn_kernel.c:vsi_nn_kernel_create_node:892]Register client kernel com.vivantecorp.extension.evis.gemm_F32F32toF32 fail with -3.
E [/home/zephyr/Documents/npu/wksp/tim-vx/src/tim/vx/internal/src/kernel/vsi_nn_kernel.c:_gpu_register:617]Build program fail.
E [/home/zephyr/Documents/npu/wksp/tim-vx/src/tim/vx/internal/src/kernel/vsi_nn_kernel.c:vsi_nn_kernel_create_node:892]Register client kernel com.vivantecorp.extension.cl.gemm_F32F32toF32_3D fail with -3.
W [vsi_nn_kernel_selector:1288]No valid kernel for matrixmul
E [/home/zephyr/Documents/npu/wksp/tim-vx/src/tim/vx/internal/src/vsi_nn_graph.c:compute_node:387]Create node[316] MATRIXMUL fail

When I check the results, it seems like model do not function as expected meaning all the inference is wrong.

@andrewkim it seems like maybe the NPU runtime doesn’t support a particular layer present in your model, can you try running your model without using the vx-delegate, i.e by normal tflite interpreter or maybe KSNN?

@ Electr1
When I run without delegate with normal tflite interpreter, it runs well. I am trying to use NPU so I can reduce CPU usage. Where can I find lists of supported layers?

Also, if this is not supported, would converting the model with KSNN make NPU available for this model?

@andrewkim the layers are specified here under the tim-vx backend:

However, here it does seem that FP32 matmul should be supported, so I believe there could be some other error involved, I will take a look.

Here are also some tips for aiding you:

  • Models on the NPU perform best with INT8 quantization
  • if you need full precision FP32 models I would like to recommend trying out the GPU TfLite instance, it has better floating point performance VIM3/3L TFLite Delegate [Khadas Docs]
1 Like

Thank you @Electr1,

It does seem like all operations including FP32 matmul should be supported. I will try different images as well, as image of 22.04 didn’t work and 20.04 worked.

I would greatly appreciate if you could take a look at the reason why it shows error when it should be supported.

In the meantime, I will take your tips and try using GPU TFlite instance for better precision.

1 Like