From 91f9e1b4d3865d0a5726c3edcbc821e11e117950 Mon Sep 17 00:00:00 2001 From: Andy Huang Date: Tue, 8 Jul 2025 14:28:59 +0800 Subject: [PATCH 1/2] Add PLUS V3.1.2 Document --- docs/index.md | 4 +- .../appendix/hardware_image_preprocessing.md | 79 + docs/plus_c/appendix/index.md | 1 + .../supported_npu_data_layout_format_kl730.md | 43 + ...odel_with_sw_npu_format_convert_example.md | 834 ++++++ .../feature_guide/customized_api/index.md | 1 + .../plus_c/feature_guide/generic_inference.md | 15 +- docs/plus_c/introduction/run_examples.md | 77 +- .../introduction/upgrade_ai_device_to_kdp2.md | 2 +- .../introduction/write_model_to_flash.md | 2 +- docs/plus_c/release_note/index.md | 4 +- docs/plus_c/release_note/v3/v3_1_1.md | 92 + docs/plus_c/release_note/v3/v3_1_2.md | 110 + .../kp_core.h.md | 0 .../kp_inference.h.md | 0 .../kp_inference_v1.h.md | 0 .../kp_struct.h.md | 0 .../kp_struct_v1.h.md | 0 .../kp_version.h.md | 0 .../api_reference_3.1.2/kp_core.h.md | 543 ++++ .../api_reference_3.1.2/kp_inference.h.md | 506 ++++ .../api_reference_3.1.2/kp_inference_v1.h.md | 151 + .../api_reference_3.1.2/kp_struct.h.md | 1235 ++++++++ .../api_reference_3.1.2/kp_struct_v1.h.md | 83 + .../api_reference_3.1.2/kp_version.h.md | 30 + docs/plus_python/api_document/V3.1.2/index.md | 347 +++ .../api_document/V3.1.2/kp/const.md | 58 + .../api_document/V3.1.2/kp/core.md | 699 +++++ .../api_document/V3.1.2/kp/enum.md | 788 +++++ .../api_document/V3.1.2/kp/exception.md | 16 + .../api_document/V3.1.2/kp/inference.md | 345 +++ .../api_document/V3.1.2/kp/v1/inference.md | 189 ++ .../api_document/V3.1.2/kp/v1/value.md | 413 +++ .../api_document/V3.1.2/kp/value.md | 2610 +++++++++++++++++ docs/plus_python/api_document/index.md | 3 +- .../chapter/generic_inference.md | 15 +- .../introduction/install_dependency.md | 5 + docs/plus_python/introduction/run_examples.md | 179 ++ .../introduction/upgrade_ai_device_to_kdp2.md | 2 +- .../introduction/write_model_to_flash.md | 2 +- .../model_inference_with_data_inference.md | 1 - mkdocs.yml | 49 +- 42 files changed, 9503 insertions(+), 30 deletions(-) create mode 100644 docs/plus_c/appendix/hardware_image_preprocessing.md create mode 100644 docs/plus_c/feature_guide/customized_api/create_kl730_single_model_with_sw_npu_format_convert_example.md create mode 100644 docs/plus_c/release_note/v3/v3_1_1.md create mode 100644 docs/plus_c/release_note/v3/v3_1_2.md rename docs/plus_c_api/{api_reference_3.1.x => api_reference_3.1.0}/kp_core.h.md (100%) rename docs/plus_c_api/{api_reference_3.1.x => api_reference_3.1.0}/kp_inference.h.md (100%) rename docs/plus_c_api/{api_reference_3.1.x => api_reference_3.1.0}/kp_inference_v1.h.md (100%) rename docs/plus_c_api/{api_reference_3.1.x => api_reference_3.1.0}/kp_struct.h.md (100%) rename docs/plus_c_api/{api_reference_3.1.x => api_reference_3.1.0}/kp_struct_v1.h.md (100%) rename docs/plus_c_api/{api_reference_3.1.x => api_reference_3.1.0}/kp_version.h.md (100%) create mode 100644 docs/plus_c_api/api_reference_3.1.2/kp_core.h.md create mode 100644 docs/plus_c_api/api_reference_3.1.2/kp_inference.h.md create mode 100644 docs/plus_c_api/api_reference_3.1.2/kp_inference_v1.h.md create mode 100644 docs/plus_c_api/api_reference_3.1.2/kp_struct.h.md create mode 100644 docs/plus_c_api/api_reference_3.1.2/kp_struct_v1.h.md create mode 100644 docs/plus_c_api/api_reference_3.1.2/kp_version.h.md create mode 100644 docs/plus_python/api_document/V3.1.2/index.md create mode 100644 docs/plus_python/api_document/V3.1.2/kp/const.md create mode 100644 docs/plus_python/api_document/V3.1.2/kp/core.md create mode 100644 docs/plus_python/api_document/V3.1.2/kp/enum.md create mode 100644 docs/plus_python/api_document/V3.1.2/kp/exception.md create mode 100644 docs/plus_python/api_document/V3.1.2/kp/inference.md create mode 100644 docs/plus_python/api_document/V3.1.2/kp/v1/inference.md create mode 100644 docs/plus_python/api_document/V3.1.2/kp/v1/value.md create mode 100644 docs/plus_python/api_document/V3.1.2/kp/value.md diff --git a/docs/index.md b/docs/index.md index 9ed3982..685925f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -42,6 +42,8 @@ Kneron AI consists the following components: Versions | KL520 SDK version | KL720 SDK version | KL630 SDK version (NNM version) | KL730 SDK version :------------------------|:------------------|:------------------|:------------------------------- | :---------------- +Kneron PLUS v3.1.2 | 2.2.x | 2.2.x | 2.5.7 (1.3.x) | 1.3.0 +Kneron PLUS v3.1.1 | 2.2.x | 2.2.x | 2.5.7 (1.3.x) | 1.2.1 Kneron PLUS v3.1.0 | 2.2.x | 2.2.x | 2.5.6 (1.3.x) | 1.2.0 Kneron PLUS v3.0.0 | 2.2.x | 2.2.x | 2.5.5 (1.2.x) | 1.0.0 Kneron PLUS v2.3.x-alpha | 2.2.x | 2.2.x | 2.5.5 (1.2.x) | 1.0.0-alpha @@ -61,7 +63,7 @@ host_lib v0.9.x | 1.4.0.x | Not supported | Not supported **Kneron PLUS** provides low barrier AI inference experience to touch AI. -Please see [Kneron PLUS-C - Getting Started](./plus_c/getting_started.md) \(or [Python - Getting Started](./plus_python/getting_start.md)\) as a start +Please see [Kneron PLUS-C - Getting Started](./plus_c/getting_started.md) (or [Python - Getting Started](./plus_python/getting_start.md)) as a start --- ## References diff --git a/docs/plus_c/appendix/hardware_image_preprocessing.md b/docs/plus_c/appendix/hardware_image_preprocessing.md new file mode 100644 index 0000000..a8fc059 --- /dev/null +++ b/docs/plus_c/appendix/hardware_image_preprocessing.md @@ -0,0 +1,79 @@ +## Hardware Image Preprocessing + +Most vision-related inference flows necessitate general image preprocessing to align with the model's input requirement. In Kneron devices, we've not only recognized this necessity but also integrated high-efficiency image preprocessing hardware. This hardware significantly speeds up the vision model inference flow, ensuring a smooth and efficient process. + +The significant features include: + +- Resize + - Specify whether to do or not to do the resize. +- Cropping + - Setting the cropping areas. (At most five cropping areas) +- Padding + - Specify whether to do or not to do the padding. + - Setting the padding mechanism: + - Corner padding: content placed at left/top corner and padding right/bottom. + - Symmetric padding: content placed at the center and padding right/left/top/bottom. +- Color space conversion + - Convert the platform-supported color space to an RGBA8888 or Grayscale image. + +The Kneron's unique features: + +- Normalization + - Hardware normalization is a crucial aspect of Kneron's hardware. It is intricately linked to the NPU model quantization factor, and we have carefully integrated the normalization formula and the quantization factor to design the hardware operations. + - Hardware operations: + - SUB128: + $$ + x - 128,\quad \text{where } x \in [-128, 127] + $$ + - DIV2: + $$ + \left\lfloor \frac{x}{2} \right\rfloor,\quad \text{where } x \in [-128, 127] + $$ + - SUB128_DIV2: + $$ + \left\lfloor \frac{x - 128}{2} \right\rfloor,\quad \text{where } x \in [-128, 127] + $$ + - We support the following normalization formula template: + - $RGB/256 - 0.5,\quad \text{where } RGB \in [0, 255]$ + - Quantization facetor: Radix=8, Scale=1.0 + - Hardware operation: SUB128 + - $RGB/128 - 1.0,\quad \text{where } RGB \in [0, 255]$ + - Quantization facetor: Radix=7, Scale=1.0 + - Hardware operation: SUB128 + - $RGB/256,\quad \text{where } RGB \in [0, 255]$ + - Quantization facetor: Radix=9, Scale=1.0 + - Hardware operation: DIV2 +- Limited NPU format conversion + - The Kneron NPU is a hardware accelerator designed specifically for neural networks, enabling efficient data processing that aligns with the hardware's preferred data layout and bit width. In Kneron devices, we offer limited conversions for NPU data layouts to optimize the speed of inference for vision models. + +### **Limitation** + +For the KL520/KL630/KL720, the hardware image preprocessing supports image models with either 3 or 4-channel input in a `4W4C8B` NPU format. It also supports a single-channel input in a `16W1C8B` format (The [C - Model Information](../introduction/run_examples.md#18-get-model-information-example)/[Python - Model Information](../../plus_python/introduction/run_examples.md#10-get-model-information-example) tool can quickly probe the NEF metadata for you). This allows users to leverage the image inference API for easy image pre-processing and NPU data conversion. + +In the case of KL730, we provide a more comprehensive list of supported NPU formats in the following table: + +| NPU Format | 16W1C8B | 4W4C8B | 1W16C8B | HW1C8B | HW4C8B_DROP_A | HW4C8B_KEEP_A | +|-------------------------------|---------|--------|---------|--------|---------------|---------------| +| Channel Number of Image Model | | | | | | | +| 1 | V | V | V | V | | | +| 3 | | V | V | | V | V | +| 4 | | V | V | | | V | + +--- + +### **Note** + +For any non-image or unsupported model input formats, please refer to following sections +for guidance on converting the input data within the software. + +- For KneronPLUS + - [Generic Data Inference API - C Language](./../feature_guide/generic_inference.md#3-generic-data-inference-api) + - [Generic Data Inference API - Python Language](./../../plus_python/feature_guide/chapter/generic_inference.md#3-generic-data-inference-api) + +- For Firmware SDK + - KL520/KL630/KL720 + - [Supported NPU Data Layout Format](./supported_npu_data_layout_format.md) + - KL730 + - [Supported NPU Data Layout Format (KL730)](./supported_npu_data_layout_format_kl730.md) + - [Convert ONNX & NPU Data on the KL730 Platform](./convert_onnx_data_to_npu_data_on_kl730.md) + - [Create KL730 Single Model with Software NPU Format Convert Example](../feature_guide/customized_api/create_kl730_single_model_with_sw_npu_format_convert_example.md) diff --git a/docs/plus_c/appendix/index.md b/docs/plus_c/appendix/index.md index 69d02d0..fe63a97 100644 --- a/docs/plus_c/appendix/index.md +++ b/docs/plus_c/appendix/index.md @@ -4,6 +4,7 @@ - [Supported NPU Data Layout Format (KL520, KL720 and KL630)](./supported_npu_data_layout_format.md) - [Supported NPU Data Layout Format (KL730)](./supported_npu_data_layout_format_kl730.md) - [Convert ONNX & NPU Data on the KL730 Platform](./convert_onnx_data_to_npu_data_on_kl730.md) +- [Hardware Image Preprocessing](./hardware_image_preprocessing.md) - [Supported Image Format](./supported_image_format.md) - [NPU Raw Output Memory Layout](./npu_raw_output_memory_layout.md) - [Yolo Object Name Mapping](./yolo_object_name_mapping.md) diff --git a/docs/plus_c/appendix/supported_npu_data_layout_format_kl730.md b/docs/plus_c/appendix/supported_npu_data_layout_format_kl730.md index 4858a25..4d5a8e0 100644 --- a/docs/plus_c/appendix/supported_npu_data_layout_format_kl730.md +++ b/docs/plus_c/appendix/supported_npu_data_layout_format_kl730.md @@ -53,6 +53,33 @@ To infer by Kneron NPU, the input/output data must be re-layout by the following | Entry #1 | P15CH1 | P14CH1 | P13CH1 | P12CH1 | P11CH1 | P10CH1 | P9CH1 | P8CH1 | P7CH1 | P6CH1 | P5CH1 | P4CH1 | P3CH1 | P2CH1 | P1CH1 | P0CH1 | | Entry #2 | P15CH2 | P14CH2 | P13CH2 | P12CH2 | P11CH2 | P10CH2 | P9CH2 | P8CH2 | P7CH2 | P6CH2 | P5CH2 | P4CH2 | P3CH2 | P2CH2 | P1CH2 | P0CH2 | + - **HW4C8B_KEEP_A** - Flexible Column 4 Channel 8-Bits Feature Map Format + This format utilizes a 4-channel structure to store RGBA input images, optimizing memory usage. Note that this format is intended solely for input and cannot be used as an output format. + + | Bits | \[127:120\] | \[119:112\] | \[111:104\] | \[103:96\] | \[95:88\] | \[87:80\] | \[79:72\] | \[71:64\] | \[63:56\] | \[55:48\] | \[47:40\] | \[39:32\] | \[31:24\] | \[23:16\] | \[15:8\] | \[7:0\] | + | -------- | ----------- | ----------- | ----------- | ---------- | --------- | --------- | --------- | --------- | --------- | --------- | --------- | --------- | --------- | --------- | -------- | ------- | + | Entry #0 | P3CH3 | P3CH2 | P3CH1 | P3CH0 | P2CH3 | P2CH2 | P2CH1 | P2CH0 | P1CH3 | P1CH2 | P1CH1 | P1CH0 | P0CH3 | P0CH2 | P0CH1 | P0CH0 | + | Entry #1 | P7CH3 | P7CH2 | P7CH1 | P7CH0 | P6CH3 | P6CH2 | P6CH1 | P6CH0 | P5CH3 | P5CH2 | P5CH1 | P5CH0 | P4CH3 | P4CH2 | P4CH1 | P4CH0 | + | Entry #2 | P11CH3 | P11CH2 | P11CH1 | P11CH0 | P10CH3 | P10CH2 | P10CH1 | P10CH0 | P9CH3 | P9CH2 | P9CH1 | P9CH0 | P8CH3 | P8CH2 | P8CH1 | P8CH0 | + + - **HW4C8B_DROP_A** - Flexible Column 4-Channel 8-Bit Feature Map Format + This format utilizes four channels to store RGB input images without an alpha channel, thereby optimizing memory usage. Please note that this format is intended solely for input and cannot be used for output. + + | Bits | \[127:120\] | \[119:112\] | \[111:104\] | \[103:96\] | \[95:88\] | \[87:80\] | \[79:72\] | \[71:64\] | \[63:56\] | \[55:48\] | \[47:40\] | \[39:32\] | \[31:24\] | \[23:16\] | \[15:8\] | \[7:0\] | + |----------|-------------|-------------|-------------|------------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|----------|---------| + | Entry #0 | 0 | P3CH2 | P3CH1 | P3CH0 | 0 | P2CH2 | P2CH1 | P2CH0 | 0 | P1CH2 | P1CH1 | P1CH0 | 0 | P0CH2 | P0CH1 | P0CH0 | + | Entry #1 | 0 | P7CH2 | P7CH1 | P7CH0 | 0 | P6CH2 | P6CH1 | P6CH0 | 0 | P5CH2 | P5CH1 | P5CH0 | 0 | P4CH2 | P4CH1 | P4CH0 | + | Entry #2 | 0 | P11CH2 | P11CH1 | P11CH0 | 0 | P10CH2 | P10CH1 | P10CH0 | 0 | P9CH2 | P9CH1 | P9CH0 | 0 | P8CH2 | P8CH1 | P8CH0 | + + - **HW1C8B** - Flexible Column 1 Channel 8-Bits Feature Map Format + Using 1-channel format to store grayscale input image to save memory space. This format cannot be an output format. Only use as input format. + + | Bits | \[127:120\] | \[119:112\] | \[111:104\] | \[103:96\] | \[95:88\] | \[87:80\] | \[79:72\] | \[71:64\] | \[63:56\] | \[55:48\] | \[47:40\] | \[39:32\] | \[31:24\] | \[23:16\] | \[15:8\] | \[7:0\] | + | -------- | ----------- | ----------- | ----------- | ---------- | --------- | --------- | --------- | --------- | --------- | --------- | --------- | --------- | --------- | --------- | -------- | ------- | + | Entry #0 | P15CH0 | P14CH0 | P13CH0 | P12CH0 | P11CH0 | P10CH0 | P9CH0 | P8CH0 | P7CH0 | P6CH0 | P5CH0 | P4CH0 | P3CH0 | P2CH0 | P1CH0 | P0CH0 | + | Entry #1 | P31CH0 | P30CH0 | P29CH0 | P28CH0 | P27CH0 | P26CH0 | P25CH0 | P24CH0 | P23CH0 | P22CH0 | P21CH0 | P20CH0 | P19CH0 | P18CH0 | P17CH0 | P16CH0 | + | Entry #2 | P47CH0 | P46CH0 | P45CH0 | P44CH0 | P43CH0 | P42CH0 | P41CH0 | P40CH0 | P39CH0 | P38CH0 | P37CH0 | P36CH0 | P35CH0 | P34CH0 | P33CH0 | P32CH0 | + - 16-Bits Data - **8W1C16B** - 8 Column 1 Channel 16-Bits Feature Map Format @@ -120,6 +147,22 @@ To infer by Kneron NPU, the input/output data must be re-layout by the following | Entry #1 | P15CH1 | P14CH1 | P13CH1 | P12CH1 | P11CH1 | P10CH1 | P9CH1 | P8CH1 | | Entry #2 | P23CH2 | P22CH2 | P21CH2 | P20CH2 | P19CH2 | P18CH2 | P17CH2 | P16CH2 | + - **HW1C16B_LE** - Flexible Column 1 Channel 16-Bits Feature Map Format (Store in Little-Endian) + + | Bits | \[127:120\] | \[119:112\] | \[111:104\] | \[103:96\] | \[95:88\] | \[87:80\] | \[79:72\] | \[71:64\] | \[63:56\] | \[55:48\] | \[47:40\] | \[39:32\] | \[31:24\] | \[23:16\] | \[15:8\] | \[7:0\] | + |----------|-------------|-------------|-------------|------------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|----------|---------| + | Entry #0 | P7CH0H | P7CH0L | P6CH0H | P6CH0L | P5CH0H | P5CH0L | P4CH0H | P4CH0L | P3CH0H | P3CH0L | P2CH0H | P2CH0L | P1CH0H | P1CH0L | P0CH0H | P0CH0L | + | Entry #1 | P15CH0H | P15CH0L | P14CH0H | P14CH0L | P13CH0H | P13CH0L | P12CH0H | P12CH0L | P11CH0H | P11CH0L | P10CH0H | P10CH0L | P9CH0H | P9CH0L | P8CH0H | P8CH0L | + | Entry #2 | P23CH0H | P23CH0L | P22CH0H | P22CH0L | P21CH0H | P21CH0L | P20CH0H | P20CH0L | P19CH0H | P19CH0L | P18CH0H | P18CH0L | P17CH0H | P17CH0L | P16CH0H | P16CH0L | + + - **HW1C16B_BE** - Flexible Column 1 Channel 16-Bits Feature Map Format (Store in Big-Endian) + + | Bits | \[127:120\] | \[119:112\] | \[111:104\] | \[103:96\] | \[95:88\] | \[87:80\] | \[79:72\] | \[71:64\] | \[63:56\] | \[55:48\] | \[47:40\] | \[39:32\] | \[31:24\] | \[23:16\] | \[15:8\] | \[7:0\] | + |----------|-------------|-------------|-------------|------------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|----------|---------| + | Entry #0 | P7CH0L | P7CH0H | P6CH0L | P6CH0H | P5CH0L | P5CH0H | P4CH0L | P4CH0H | P3CH0L | P3CH0H | P2CH0L | P2CH0H | P1CH0L | P1CH0H | P0CH0L | P0CH0H | + | Entry #1 | P15CH0L | P15CH0H | P14CH0L | P14CH0H | P13CH0L | P13CH0H | P12CH0L | P12CH0H | P11CH0L | P11CH0H | P10CH0L | P10CH0H | P9CH0L | P9CH0H | P8CH0L | P8CH0H | + | Entry #2 | P23CH0L | P23CH0H | P22CH0L | P22CH0H | P21CH0L | P21CH0H | P20CH0L | P20CH0H | P19CH0L | P19CH0H | P18CH0L | P18CH0H | P17CH0L | P17CH0H | P16CH0L | P16CH0H | + - Output Data Layout - 8-Bits Data - **1W16C8B_CH_COMPACT** - 1 Column 16 Channel 8-Bits Feature Map Format in Inner Channel Group Mode diff --git a/docs/plus_c/feature_guide/customized_api/create_kl730_single_model_with_sw_npu_format_convert_example.md b/docs/plus_c/feature_guide/customized_api/create_kl730_single_model_with_sw_npu_format_convert_example.md new file mode 100644 index 0000000..79e7db0 --- /dev/null +++ b/docs/plus_c/feature_guide/customized_api/create_kl730_single_model_with_sw_npu_format_convert_example.md @@ -0,0 +1,834 @@ +# Create KL730 Single Model with Software NPU Format Convert Example + +In this customized inference example, we will focus on converting source data into NPU format. Some specific model inputs in NPU format that cannot utilize the [Hardware Image Preprocessing](./../../appendix/hardware_image_preprocessing.md) conversion will use this example to learn how to perform the conversion manually. + +For more information about the NPU format and the hardware NPU data layout conversion support list, please refer to the [Hardware Image Preprocessing](./../../appendix/hardware_image_preprocessing.md#limitation) documentation. + +--- + +## 1. Download Source Code + +1. Download the latest **kneron_plus_vXXX.zip** into Windows/Ubuntu from . It is located at **Kneron PLUS** section. + +2. Unzip kneron_plus_vXXX.zip + + Note: **{PLUS_FOLDER_PATH}** will be used below for representing the unzipped folder path of PLUS. + +3. Please contact Kneron to obtain the latest **KL730_SDK_vXXX.zip**. + + Note: KL730 SDK can only be developed on Ubuntu + +4. Unzip KL730_SDK_vXXX.zip + + Note: **{KL730_SDK_TOP_FOLDER_PATH}** will be used below for representing the unzipped folder path of KL730 Develop Package. + +5. Unzip {KL730_SDK_TOP_FOLDER_PATH}/02_APP/02_Software_Tool_Kit/sdk_vX.X.X.tar.gz + + Note: **{KL730_SDK_FOLDER_PATH}** will be used below for representing the unzipped folder path of KL730 SDK. + +--- + +## 2. PLUS (Software) Development + +1. Create my_KL730_sin_with_sw_npu_fmt_cvt_example folder + + ```bash + $ cd {PLUS_FOLDER_PATH}/examples/ + $ mkdir my_KL730_sin_with_sw_npu_fmt_cvt_example + ``` + + +2. Add *CMakelists.txt* + + ```bash + # build with current *.c/*.cpp plus common source files in parent folder + # executable name is current folder name. + + get_filename_component(app_name ${CMAKE_CURRENT_SOURCE_DIR} NAME) + string(REPLACE " " "_" app_name ${app_name}) + + file(GLOB local_src + "*.c" + "*.cpp" + ) + + set(common_src + ../../ex_common/helper_functions.c + ) + + add_executable(${app_name} + ${local_src} + ${common_src}) + + target_link_libraries(${app_name} ${KPLUS_LIB_NAME} ${USB_LIB} ${MATH_LIB} pthread) + ``` + +3. Add *my_KL730_sin_with_sw_npu_fmt_cvt_example.h* + + - Please define the customized **header** structure and customized **result** structure in this file. + + - Header (my_KL730_sin_with_sw_npu_fmt_cvt_example_header_t) is used for **sending** data to SCPU firmware. What kind of data should be contained can be customized based on the your requirement. + + - Result (my_KL730_sin_with_sw_npu_fmt_cvt_example_result_t) is used for **receiving** data from SCPU firmware. What kind of data should be contained can be customized based on the output of model inference. + + - **kp_inference_header_stamp_t** must be contained in both header and result structures. + + - The **JOB_ID** describes the unique id of the task you want to execute in firmware, and it must be unique and above 1000. + + - This file should be synchronized with the .h file in SCPU firmware. + + ```cpp + #pragma once + + #define MY_KL730_SIN_WITH_SW_NPU_FMT_CVT_EXAMPLE_JOB_ID 4002 + #define YOLO_BOX_MAX 100 + + typedef struct { + uint32_t class_count; + uint32_t box_count; + kp_bounding_box_t boxes[YOLO_BOX_MAX]; + } __attribute__((aligned(4))) my_KL730_sin_with_sw_npu_fmt_cvt_example_yolo_result_t; + + typedef struct { + /* header stamp is necessary */ + kp_inference_header_stamp_t header_stamp; + + uint32_t img_width; + uint32_t img_height; + } __attribute__((aligned(4))) my_KL730_sin_with_sw_npu_fmt_cvt_example_header_t; + + typedef struct { + /* header stamp is necessary */ + kp_inference_header_stamp_t header_stamp; + + my_KL730_sin_with_sw_npu_fmt_cvt_example_yolo_result_t yolo_result; + } __attribute__((aligned(4))) my_KL730_sin_with_sw_npu_fmt_cvt_example_result_t; + ``` + +4. Add *my_KL730_sin_with_sw_npu_fmt_cvt_example.c* + + - There are 6 steps for inferencing in Kneron AI device: + + 1. Connect Kneron AI device. + + 2. Upload the firmware to AI device. + + 3. Upload the model to AI device. + + 4. Prepare data for the header. + + 5. Send the header and image buffer to firmware via **kp_customized_inference_send()**. + + 6. Receive the result from firmware via **kp_customized_inference_receive()**. + + - In this example, the **image** is transcoded into RGB565, and the width and height of the image is carried by the header. + + - Sending header and receiving result can be executed sequentially or on two different threads. + + ```cpp + #include + #include + #include + #include + + #include "kp_core.h" + #include "kp_inference.h" + #include "helper_functions.h" + + #include "my_KL730_sin_with_sw_npu_fmt_cvt_example.h" + + static char _scpu_fw_path[128] = "../../res/firmware/KL730/kp_firmware.tar"; + static char _model_file_path[128] = "../../res/models/KL730/YoloV5s_640_640_3/models_730.nef"; + static char _image_file_path[128] = "../../res/images/one_bike_many_cars_608x608.bmp"; + static int _loop = 10; + + int main(int argc, char *argv[]) + { + kp_device_group_t device; + kp_model_nef_descriptor_t model_desc; + int ret; + + /******* connect the device *******/ + { + int port_id = 0; // 0 for one device auto-search + int error_code; + + // internal parameter to indicate the desired port id + if (argc > 1) { + port_id = atoi(argv[1]); + } + + // connect device + device = kp_connect_devices(1, &port_id, &error_code); + if (!device) { + printf("connect device failed, port ID = '%d', error = '%d'\n", port_id, error_code); + exit(0); + } + + kp_set_timeout(device, 5000); + printf("connect device ... OK\n"); + } + + /******* upload firmware to device *******/ + { + ret = kp_load_firmware_from_file(device, _scpu_fw_path, NULL); + if (ret != KP_SUCCESS) { + printf("upload firmware failed, error = %d\n", ret); + exit(0); + } + + printf("upload firmware ... OK\n"); + } + + /******* upload model to device *******/ + { + ret = kp_load_model_from_file(device, _model_file_path, &model_desc); + if (ret != KP_SUCCESS) { + printf("upload model failed, error = %d\n", ret); + exit(0); + } + + printf("upload model ... OK\n"); + } + + /******* prepare the image buffer read from file *******/ + // here convert a bmp file to RGB565 format buffer + + int img_width, img_height; + char *img_buf = helper_bmp_file_to_raw_buffer(_image_file_path, &img_width, &img_height, KP_IMAGE_FORMAT_RGB565); + + if (!img_buf) { + printf("read image file failed\n"); + exit(0); + } + + printf("read image ... OK\n"); + printf("\nstarting inference loop %d times:\n", _loop); + + /******* prepare input and output header/buffers *******/ + my_KL730_sin_with_sw_npu_fmt_cvt_example_header_t input_header; + my_KL730_sin_with_sw_npu_fmt_cvt_example_result_t output_result; + + input_header.header_stamp.job_id = MY_KL730_SIN_WITH_SW_NPU_FMT_CVT_EXAMPLE_JOB_ID; + input_header.header_stamp.total_image = 1; + input_header.header_stamp.image_index = 0; + input_header.img_width = img_width; + input_header.img_height = img_height; + + int header_size = sizeof(my_KL730_sin_with_sw_npu_fmt_cvt_example_header_t); + int image_size = img_width * img_height * 2; // RGB565 + int result_size = sizeof(my_KL730_sin_with_sw_npu_fmt_cvt_example_result_t); + int recv_size = 0; + + /******* starting inference work *******/ + + for (int i = 0; i < _loop; i++) + { + ret = kp_customized_inference_send(device, (void *)&input_header, header_size, (uint8_t *)img_buf, image_size); + + if (ret != KP_SUCCESS) { + break; + } + + ret = kp_customized_inference_receive(device, (void *)&output_result, result_size, &recv_size); + + if (ret != KP_SUCCESS) { + break; + } + + printf("\n[loop %d]\n", i + 1); + helper_print_yolo_box_on_bmp((kp_yolo_result_t *)&output_result.yolo_result, _image_file_path); + } + + printf("\n"); + + if (ret != KP_SUCCESS) { + printf("\ninference failed, error = %d\n", ret); + return -1; + } + + free(img_buf); + kp_disconnect_devices(device); + + return 0; + } + ``` + + +--- + +## 3. Firmware Development + +**Note**: For further information of KL730 VMF_NNM, please refer **Leipzig_SDK_Multimedia_Framework_Programming_Guide.pdf** in {KL730_SDK_TOP_FOLDER_PATH}/02_APP/01_Documents/ + +1. Go to App Flow Folder {KL730_SDK_FOLDER_PATH}/apps/vmf_nnm/solution/app_flow + +2. Add *my_KL730_sin_with_sw_npu_fmt_cvt_example_inf.h* into include folder + + - The content of this file should be synchronized with **my_KL730_sin_with_sw_npu_fmt_cvt_example.h** in PLUS. + + ```cpp + #include "kp_struct.h" + + #define MY_KL730_SIN_WITH_SW_NPU_FMT_CVT_EXAMPLE_JOB_ID 4002 + #define YOLO_BOX_MAX 100 + + typedef struct { + uint32_t class_count; + uint32_t box_count; + kp_bounding_box_t boxes[YOLO_BOX_MAX]; + } __attribute__((aligned(4))) my_KL730_sin_with_sw_npu_fmt_cvt_example_yolo_result_t; + + typedef struct { + /* header stamp is necessary */ + kp_inference_header_stamp_t header_stamp; + + uint32_t img_width; + uint32_t img_height; + } __attribute__((aligned(4))) my_KL730_sin_with_sw_npu_fmt_cvt_example_header_t; + + typedef struct { + /* header stamp is necessary */ + kp_inference_header_stamp_t header_stamp; + + my_KL730_sin_with_sw_npu_fmt_cvt_example_yolo_result_t yolo_result; + } __attribute__((aligned(4))) my_KL730_sin_with_sw_npu_fmt_cvt_example_result_t; + + void my_KL730_sin_with_sw_npu_fmt_cvt_example_inf(int job_id, int num_input_buf, void **inf_input_buf_list); + void my_KL730_sin_with_sw_npu_fmt_cvt_example_inf_deinit(); + ``` + +3. Add *my_KL730_sin_with_sw_npu_fmt_cvt_example_inf.c* + + - There are four steps for inferencing in one model: + + 1. Prepare the memory space for the result. + + 2. Prepare **VMF_NNM_INFERENCE_APP_CONFIG_T**, which is used for configure the inference process. + + 3. Activate NCPU firmware via **VMF_NNM_Inference_App_Execute()**. + + 4. Send the result to PLUS via **VMF_NNM_Fifoq_Manager_Result_Enqueue()**. + + - For the customized model, **model_id** of **VMF_NNM_INFERENCE_APP_CONFIG_T** should be set to the id of the customized model. + + - For the customized pre-process and post-process, please provide the function pointer to **pre_proc_func** and **post_proc_func** of **VMF_NNM_INFERENCE_APP_CONFIG_T**. Please refer [Pre/Post Process](#4-pre-process-and-post-process-development) for more information. + + - The inference result will be written to **ncpu_result_buf** of **VMF_NNM_INFERENCE_APP_CONFIG_T**. Therefore, you must provide a memory space for it (In this example, **ncpu_result_buf** is pointed to **yolo_result** in **output_result**.) + + ```cpp + #include + #include + #include + #include + + #include "model_type.h" + #include "vmf_nnm_inference_app.h" + #include "vmf_nnm_fifoq_manager.h" + + #include "my_KL730_sin_with_sw_npu_fmt_cvt_example_inf.h" + #include "user_post_process_yolov5.h" + #include "user_pre_process_yolov5_with_sw_npu_format_convert.h" + + static bool g_bSensorEnable = false; + static bool g_isInit = false; + static ex_yolo_post_proc_config_t post_proc_params_v5s = { + .prob_thresh = 0.15, + .nms_thresh = 0.5, + .max_detection = YOLO_BOX_MAX, + .max_detection_per_class = YOLO_BOX_MAX, + .nms_mode = EX_NMS_MODE_SINGLE_CLASS, + .anchor_layer_num = 3, + .anchor_cell_num_per_layer = 3, + .data = {{{10, 13}, {16, 30}, {33, 23}}, + {{30, 61}, {62, 45}, {59, 119}}, + {{116, 90}, {156, 198}, {373, 326}}, + {{0, 0}, {0, 0}, {0, 0}}, + {{0, 0}, {0, 0}, {0, 0}}}, + }; + + void my_KL730_sin_with_sw_npu_fmt_cvt_example_inf(int job_id, int num_input_buf, void **inf_input_buf_list) + { + // 'inf_input_buf' and 'inf_result_buf' are provided by kdp2 middleware + // the content of 'inf_input_buf' is transmitted from host SW = header + image + // 'inf_result_buf' is used to carry inference result back to host SW = header + inference result (from ncpu/npu) + + // now get an available free result buffer + // normally the begin part of result buffer should contain app-defined result header + // and the rest is for ncpu/npu inference output data + int ret = KP_SUCCESS; + + // initializing the resources required for preprocessing for the first time + if (false == g_isInit) { + ret = user_pre_process_yolov5_with_sw_npu_format_convert_init(); + if (KP_SUCCESS != ret) { + VMF_NNM_Fifoq_Manager_Status_Code_Enqueue(job_id, ret); + return; + } + + g_isInit = true; + } + + // verify that the input data number meets the requirements of the model + if (1 != num_input_buf) { + VMF_NNM_Fifoq_Manager_Status_Code_Enqueue(job_id, KP_FW_WRONG_INPUT_BUFFER_COUNT_110); + return; + } + + int result_buf_size; + uintptr_t inf_result_buf; + uintptr_t inf_result_phy_addr; + + /******* Prepare the memory space of result *******/ + if (0 != VMF_NNM_Fifoq_Manager_Result_Get_Free_Buffer(&inf_result_buf, &inf_result_phy_addr, &result_buf_size, -1)) { + printf("[%s] get result free buffer failed\n", __FUNCTION__); + return; + } + + my_KL730_sin_with_sw_npu_fmt_cvt_example_header_t *input_header = (my_KL730_sin_with_sw_npu_fmt_cvt_example_header_t *)inf_input_buf_list[0]; + my_KL730_sin_with_sw_npu_fmt_cvt_example_result_t *output_result = (my_KL730_sin_with_sw_npu_fmt_cvt_example_result_t *)inf_result_buf; + + /******* Prepare the configuration *******/ + + // config image preprocessing and model settings + VMF_NNM_INFERENCE_APP_CONFIG_T inf_config; + memset(&inf_config, 0, sizeof(VMF_NNM_INFERENCE_APP_CONFIG_T)); + + // image buffer address should be just after the header + inf_config.num_image = 1; + inf_config.image_list[0].image_buf = (void *)((uintptr_t)input_header + sizeof(my_KL730_sin_with_sw_npu_fmt_cvt_example_header_t)); + inf_config.image_list[0].image_width = input_header->img_width; + inf_config.image_list[0].image_height = input_header->img_height; + inf_config.image_list[0].image_channel = 3; // assume RGB565 + inf_config.image_list[0].image_format = KP_IMAGE_FORMAT_RGB565; // assume RGB565 + inf_config.image_list[0].image_norm = KP_NORMALIZE_KNERON; // this depends on model + inf_config.image_list[0].image_resize = KP_RESIZE_ENABLE; // enable resize + inf_config.image_list[0].image_padding = KP_PADDING_CORNER; // enable padding on corner + inf_config.model_id = KNERON_YOLOV5S_COCO80_640_640_3; // this depends on model + + // setting pre/post-proc configuration + inf_config.pre_proc_config = NULL; + inf_config.pre_proc_func = user_pre_process_yolov5_with_sw_npu_format_convert; + inf_config.post_proc_config = (void *)&post_proc_params_v5s; // yolo post-process configurations for yolo v5 series + inf_config.post_proc_func = user_post_yolov5_no_sigmoid; + + // set up result output buffer for ncpu/npu + inf_config.ncpu_result_buf = (void *)&(output_result->yolo_result); // give result buffer for ncpu/npu, callback will carry it + + + /******* Activate inferencing in NCPU *******/ + + // run preprocessing and inference, trigger ncpu/npu to do the work + // if enable_parallel=true (works only for single model), result callback is needed + // however if inference error then no callback will be invoked + ret = VMF_NNM_Inference_App_Execute(&inf_config); + + /******* Send the result to PLUS *******/ + + // header_stamp is a must to correctly transfer result data back to host SW + output_result->header_stamp.magic_type = KDP2_MAGIC_TYPE_INFERENCE; + output_result->header_stamp.total_size = sizeof(my_KL730_sin_with_sw_npu_fmt_cvt_example_result_t); + output_result->header_stamp.job_id = job_id; + output_result->header_stamp.status_code = ret; + + // send output result buffer back to host SW + VMF_NNM_Fifoq_Manager_Result_Enqueue(inf_result_buf, inf_result_phy_addr, result_buf_size, -1, false); + } + + void my_KL730_sin_with_sw_npu_fmt_cvt_example_inf_deinit() + { + if (true == g_isInit) { + if (KP_SUCCESS != user_pre_process_yolov5_with_sw_npu_format_convert_deinit()) { + printf("[%s] user_pre_process_yolov5_with_sw_npu_format_convert_deinit fail ...\n", __FUNCTION__); + } else { + g_isInit = false; + } + } + } + ``` + + - Dig into the registered preprocessing function to demonstrate the conversion of source data to NPU format (In *{KL730_SDK_FOLDER_PATH}/apps/vmf_nnm/solution/app_flow/pre_post_proc/user_pre_process_yolov5_with_sw_npu_format_convert.c*) + + - The major process in *user_pre_process_yolov5_with_sw_npu_format_convert.c*: + - Initialization function `user_pre_process_yolov5_with_sw_npu_format_convert_init()` + 1. Get the model input tensor information + 2. Allocate the memory for the working buffer + - Release function `user_pre_process_yolov5_with_sw_npu_format_convert_deinit()` + 1. Release the working buffer + - Process function `user_pre_process_yolov5_with_sw_npu_format_convert()` + 1. Do image preprocessing for fitting the model input shape + 2. Convert the image data to ONNX data layout (HxWxC to CxHxW) + 3. Do normalization + 4. Convert the ONNX data to NPU data by `ex_convert_onnx_data_to_npu_data()` and the input tensor information + + - **Note:** The conversion process details can be found in the source code of the ex_convert_onnx_data_to_npu_data() function and [Convert ONNX & NPU Data on the KL730 Platform](../../appendix/convert_onnx_data_to_npu_data_on_kl730.md) + + ```cpp + #include + + #include "user_pre_process_yolov5_with_sw_npu_format_convert.h" + #include "vmf_nnm_inference_app.h" + #include "model_type.h" + #include "user_utils.h" + + static VMF_NNM_MODEL_TENSOR_DESCRIPTOR_T tensor_descriptor = {0}; + static uint32_t onnx_data_channel = 0; + static uint32_t onnx_data_height = 0; + static uint32_t onnx_data_width = 0; + static uint32_t onnx_data_buf_size = 0; + static float* onnx_data_buf = NULL; + + int user_pre_process_yolov5_with_sw_npu_format_convert_init() + { + int ret = KP_SUCCESS; + + VMF_NNM_MODEL_TENSOR_INFO_V2_T *tensor_info = NULL; + + if (NULL == onnx_data_buf) { + /* get YOLOv5 model input shape */ + ret = VMF_NNM_MODEL_Get_Input_Tensor_Descriptor(KNERON_YOLOV5S_COCO80_640_640_3, 0, &tensor_descriptor); + if (0 == ret) { + ret = KP_FW_GET_MODEL_INFO_FAILED_109; + goto FUNC_OUT; + } else { + ret = KP_SUCCESS; + } + + if (NGS_MODEL_TENSOR_SHAPE_INFO_VERSION_2 != tensor_descriptor.tensor_shape_info.version) { + ret = KP_FW_ERROR_UNSUPPORT_TOOLCHAIN_VERSION_136; + goto FUNC_OUT; + } + + /* get model input size (shape order: BxCxHxW) (KL730 only support kp_tensor_shape_info_v2_t) */ + tensor_info = &(tensor_descriptor.tensor_shape_info.tensor_shape_info_data.v2); + onnx_data_channel = tensor_info->shape[1]; + onnx_data_height = tensor_info->shape[2]; + onnx_data_width = tensor_info->shape[3]; + + /* malloc origin model input data */ + onnx_data_buf_size = onnx_data_width * onnx_data_height * onnx_data_channel; + onnx_data_buf = calloc(onnx_data_buf_size, sizeof(float)); + + if (NULL == onnx_data_buf) { + ret = KP_FW_DDR_MALLOC_FAILED_102; + goto FUNC_OUT; + } + } + + FUNC_OUT: + return ret; + } + + int user_pre_process_yolov5_with_sw_npu_format_convert_deinit() + { + int ret = KP_SUCCESS; + + if (NULL != onnx_data_buf) { + free(onnx_data_buf); + onnx_data_buf = NULL; + } else { + ret = KP_FW_DDR_MALLOC_FAILED_102; + goto FUNC_OUT; + } + + FUNC_OUT: + return ret; + } + + int user_pre_process_yolov5_with_sw_npu_format_convert(struct kdp_image_s *image_p, unsigned int index) + { + int ret = KP_SUCCESS; + + /* get image source information and model input information */ + unsigned int dwSrcWidth = RAW_INPUT_COL(image_p, index); + unsigned int dwSrcHeight = RAW_INPUT_ROW(image_p, index); + unsigned char *pSrcBuffer = (unsigned char*)RAW_IMAGE_MEM_ADDR(image_p, index); + unsigned int dwSrcBufferSize = RAW_IMAGE_MEM_LEN(image_p, index); + unsigned int dwSrcNormalization = RAW_FORMAT(image_p, index); + + unsigned int dwDstWidth = DIM_INPUT_COL(image_p, index); + unsigned int dwDstHeight = DIM_INPUT_ROW(image_p, index); + unsigned char *pDstBuffer = (unsigned char*)PREPROC_INPUT_MEM_ADDR(image_p, index); + unsigned int dwDstBufferSize = PREPROC_INPUT_MEM_LEN(image_p, index); + + /* setting pre-process related image configuration */ + float fScaleWidth = (float)(dwDstWidth - 1) / (float)(dwSrcWidth - 1); + float fScaleHeight = (float)(dwDstHeight - 1) / (float)(dwSrcHeight - 1); + float fScale = 0; + unsigned int dwResizeWidth = 0; + unsigned int dwResizeHeight = 0; + unsigned int dwPadLeft = 0; + unsigned int dwPadRight = 0; + unsigned int dwPadTop = 0; + unsigned int dwPadBottom = 0; + unsigned int img_buf_rgba8888_offset = 0; + unsigned int onnx_data_buf_offset = 0; + + /* to set the image engine (IE) for hardware image processing, the process involves resizing, padding, and converting the color space */ + /* Note: In this example function, we only use IE for general image processing without any exceptional Kneron pre-processing support, such as hardware normalization. */ + VMF_NNM_IE_CONFIG_T ie_config = {0}; + + ie_config.src_buffer_addr = pSrcBuffer; + ie_config.src_buffer_size = dwSrcBufferSize; + ie_config.src_format = RAW_FORMAT(image_p, index) & IMAGE_FORMAT_NPU; + ie_config.src_width = dwSrcWidth; + ie_config.src_height = dwSrcHeight; + + ie_config.dst_buffer_addr = pDstBuffer; + ie_config.dst_buffer_size = dwDstBufferSize; + ie_config.dst_format = KP_IMAGE_FORMAT_RGBA8888; + ie_config.dst_width = dwDstWidth; + ie_config.dst_height = dwDstHeight; + ie_config.dst_angle = 0; + + ie_config.enable_crop = false; + + ie_config.image_norm = KP_NORMALIZE_DISABLE; /* Note: Disable hardware normalization when using software quantization and NPU layout conversion */ + ie_config.image_resize = KP_RESIZE_ENABLE; + ie_config.image_padding = KP_PADDING_CORNER; + + ret = VMF_NNM_IE_Execute(&ie_config); + if (KP_SUCCESS != ret) { + printf("VMF_NNM_IE_Execute failed\n"); + goto FUNC_OUT; + } + + /* prepare origin model input data (re-layout 640x640x3 rgba8888 image to 1x3x640x640 model input data) */ + for (unsigned int channel = 0; channel < onnx_data_channel; channel++) { + img_buf_rgba8888_offset = channel; + + for (unsigned int pixel = 0; pixel < onnx_data_height * onnx_data_width; pixel++) { + onnx_data_buf[onnx_data_buf_offset + pixel] = (float)pDstBuffer[img_buf_rgba8888_offset]; + img_buf_rgba8888_offset += 4; + } + + onnx_data_buf_offset += (onnx_data_height * onnx_data_width); + } + + /* do software normalization process (assume KP_NORMALIZE_KNERON normalization) */ + /* ---------------------------------------------------------------------------- */ + /* kp_normalize_mode_t and HW normalization flag mapping */ + /* ---------------------------------------------------------------------------- */ + /* KP_NORMALIZE_KNERON: IMAGE_FORMAT_SUB128 */ + /* KP_NORMALIZE_TENSOR_FLOW: IMAGE_FORMAT_SUB128 */ + /* KP_NORMALIZE_CUSTOMIZED_SUB128: IMAGE_FORMAT_SUB128 */ + /* KP_NORMALIZE_YOLO: IMAGE_FORMAT_RIGHT_SHIFT_ONE_BIT */ + /* KP_NORMALIZE_CUSTOMIZED_DIV2: IMAGE_FORMAT_RIGHT_SHIFT_ONE_BIT */ + if (!(dwSrcNormalization & IMAGE_FORMAT_SUB128)) { + printf("Unsupport normalization configuration\n"); + ret = KP_FW_NOT_SUPPORT_PREPROCESSING_108; + goto FUNC_OUT; + } + + for (unsigned int idx = 0; idx < onnx_data_buf_size; idx++) { + onnx_data_buf[idx] = onnx_data_buf[idx] / 256.0 - 0.5f; + } + + /* convert ONNX data to NPU data */ + ret = ex_convert_onnx_data_to_npu_data(&tensor_descriptor, /* tensor information */ + onnx_data_buf, /* tensor data in ONNX format */ + onnx_data_buf_size, /* element number of onnx_data_buf */ + (int8_t **)&pDstBuffer, /* tensor data in NPU format */ + (int32_t *)&dwDstBufferSize /* data size of npu_data_buf */); + if (KP_SUCCESS != ret) { + printf("ex_convert_onnx_data_to_npu_data failed\n"); + goto FUNC_OUT; + } + + /* setting pre-process related image configuration */ + if (fScaleWidth < fScaleHeight) { + fScale = fScaleWidth; + } else { + fScale = fScaleHeight; + } + + dwResizeWidth = (dwSrcWidth - 1) * fScale + 1.5f; + dwResizeHeight = (dwSrcHeight - 1) * fScale + 1.5f; + dwPadRight = dwDstWidth - dwResizeWidth; + dwPadBottom = dwDstHeight - dwResizeHeight; + + RAW_PAD_TOP(image_p, index) = dwPadTop; + RAW_PAD_BOTTOM(image_p, index) = dwPadBottom; + RAW_PAD_LEFT(image_p, index) = dwPadLeft; + RAW_PAD_RIGHT(image_p, index) = dwPadRight; + RAW_CROP_TOP(image_p, index) = 0; + RAW_CROP_LEFT(image_p, index) = 0; + RAW_CROP_RIGHT(image_p, index) = 0; + RAW_CROP_BOTTOM(image_p, index) = 0; + RAW_SCALE_WIDTH(image_p, index) = (float)dwSrcWidth / (float)dwResizeWidth; + RAW_SCALE_HEIGHT(image_p, index) = (float)dwSrcHeight / (float)dwResizeHeight; + + FUNC_OUT: + return ret; + } + ``` + +4. Go to Companion Solution Folder {KL730_SDK_FOLDER_PATH}/apps/vmf_nnm/solution/solution_companion_user_ex + +5. Edit *application_init.c* + + - **_app_func** is the entry interface for all inference request. + + - Inference jobs will be dispatched to the corresponding function based on the **job_id** in **kp_inference_header_stamp_t** in the header. + + - You need to establish a switch case for **MY_KL730_SIN_WITH_SW_NPU_FMT_CVT_EXAMPLE_JOB_ID** and correspond the switch case to **my_KL730_sin_with_sw_npu_fmt_cvt_example_inf()**. + + ```cpp + #include + #include + #include + #include + #include + #include + #include + #include + + #include + #include + + // inference app + #include "kdp2_inf_app_yolo.h" + #include "demo_customize_inf_single_model.h" + #include "demo_customize_inf_multiple_models.h" + #include "application_init.h" + /* ======================================== */ + /* Add Line Begin */ + /* ======================================== */ + #include "my_KL730_sin_with_sw_npu_fmt_cvt_example_inf.h" + /* ======================================== */ + /* Add Line End */ + /* ======================================== */ + + /** + * @brief To register AI applications + * @param[in] num_input_buf number of data inputs in list + * @param[in] inf_input_buf_list list of data input for inference task + * @return N/A + * @note Add a switch case item for a new inf_app application + */ + static void _app_func(int num_input_buf, void** inf_input_buf_list); + + static void _app_func(int num_input_buf, void** inf_input_buf_list) + { + // check header stamp + if (0 >= num_input_buf) { + kmdw_printf("No input buffer for app function\n"); + return; + } + + kp_inference_header_stamp_t *header_stamp = (kp_inference_header_stamp_t *)inf_input_buf_list[0]; + uint32_t job_id = header_stamp->job_id; + + switch (job_id) + { + case KDP2_INF_ID_APP_YOLO: + kdp2_app_yolo_inference(job_id, num_input_buf, inf_input_buf_list); + break; + case KDP2_JOB_ID_APP_YOLO_CONFIG_POST_PROC: + kdp2_app_yolo_config_post_process_parameters(job_id, num_input_buf, inf_input_buf_list); + break; + case DEMO_KL730_CUSTOMIZE_INF_SINGLE_MODEL_JOB_ID: // a demo code implementation in SCPU for user-defined/customized infernece from one model + demo_customize_inf_single_model(job_id, num_input_buf, inf_input_buf_list); + break; + case DEMO_KL730_CUSTOMIZE_INF_MULTIPLE_MODEL_JOB_ID: // a demo code implementation in SCPU for user-defined/customized infernece from two models + demo_customize_inf_multiple_models(job_id, num_input_buf, inf_input_buf_list); + break; + /* ======================================== */ + /* Add Line Begin */ + /* ======================================== */ + case MY_KL730_SIN_WITH_SW_NPU_FMT_CVT_EXAMPLE_JOB_ID: + my_KL730_sin_with_sw_npu_fmt_cvt_example_inf(job_id, num_input_buf, inf_input_buf_list); + break; + /* ======================================== */ + /* Add Line End */ + /* ======================================== */ + default: + VMF_NNM_Fifoq_Manager_Status_Code_Enqueue(job_id, KP_FW_ERROR_UNKNOWN_APP); + printf("unsupported job_id %d \n",job_id); + break; + } + } + + static void _app_func_deinit(unsigned int job_id); + + void _app_func_deinit(unsigned int job_id) + { + switch (job_id) + { + case KDP2_INF_ID_APP_YOLO: + kdp2_app_yolo_inference_deinit(); + break; + case DEMO_KL730_CUSTOMIZE_INF_SINGLE_MODEL_JOB_ID: + demo_customize_inf_single_model_deinit(); + break; + case DEMO_KL730_CUSTOMIZE_INF_MULTIPLE_MODEL_JOB_ID: + demo_customize_inf_multiple_model_deinit(); + break; + /* ======================================== */ + /* Add Line Begin */ + /* ======================================== */ + case MY_KL730_SIN_WITH_SW_NPU_FMT_CVT_EXAMPLE_JOB_ID: + my_KL730_sin_with_sw_npu_fmt_cvt_example_inf_deinit(); + break; + /* ======================================== */ + /* Add Line End */ + /* ======================================== */ + default: + printf("%s, unsupported job_id %d \n", __func__, job_id); + break; + } + } + + void app_initialize(void) + { + printf(">> Start running KL730 KDP2 companion mode ...\n"); + + /* initialize inference app */ + /* register APP functions */ + /* specify depth of inference queues */ + VMF_NNM_Inference_App_Init(_app_func); + VMF_NNM_Fifoq_Manager_Init(); + + return; + } + + void app_destroy(void) + { + _app_func_deinit(KDP2_INF_ID_APP_YOLO); + _app_func_deinit(DEMO_KL730_CUSTOMIZE_INF_SINGLE_MODEL_JOB_ID); + _app_func_deinit(DEMO_KL730_CUSTOMIZE_INF_MULTIPLE_MODEL_JOB_ID); + /* ======================================== */ + /* Add Line Begin */ + /* ======================================== */ + _app_func_deinit(MY_KL730_SIN_WITH_SW_NPU_FMT_CVT_EXAMPLE_JOB_ID); + /* ======================================== */ + /* Add Line End */ + /* ======================================== */ + + VMF_NNM_Inference_App_Destroy(); + VMF_NNM_Fifoq_Manager_Destroy(); + } + ``` + +--- + +## 4. Pre-process and Post-process Development + + +If the customized models need a customized pre-process or post-process on Kneron AI device, you can add the pre-process and post-process in the following files. + +1. Go to NCPU Project Main Folder {KL730_SDK_FOLDER_PATH}/apps/vmf_nnm/solution/app_flow/pre_post_proc + +2. Add your customized pre-process/post-process header file into include folder. + +3. Add your customized post-process/post-process implementation c file into current folder. + +4. Register the pre/post process into **pre_proc_func** and **post_proc_func** of **VMF_NNM_INFERENCE_APP_CONFIG_T** during [firmware development](#3-firmware-development). + + - If **pre_proc_func** of **VMF_NNM_INFERENCE_APP_CONFIG_T** is not set, hardware auto pre-process will be adapted during inference flow. + + - If **post_proc_func** of **VMF_NNM_INFERENCE_APP_CONFIG_T** is not set, inference raw output data will be put into result buffer without post-process. + +**Note**: During developing the post-processing, you must be aware of what pre-process has done, including image resize, image padding, and image cropping. + +**Note**: In post-processing, the memory layout of data in **raw_cnn_res_t** for KL520, KL730 and KL720 are different. Please reference [Kneron NPU Raw Output Channel Order](../../appendix/npu_raw_output_memory_layout.md). diff --git a/docs/plus_c/feature_guide/customized_api/index.md b/docs/plus_c/feature_guide/customized_api/index.md index a017900..d6eb4b8 100644 --- a/docs/plus_c/feature_guide/customized_api/index.md +++ b/docs/plus_c/feature_guide/customized_api/index.md @@ -12,6 +12,7 @@ Documents in **Customized API** explain the usage of create customized API in So - [Create Multiple Model Example for KL720](./create_kl720_multiple_models_example.md) - [Create Single Model Example for KL730](./create_kl730_single_model_example.md) - [Create Multiple Model Example for KL730](./create_kl730_multiple_models_example.md) +- [Create Single Model with Software NPU Format Convert Example for KL730](./create_kl730_single_model_with_sw_npu_format_convert_example.md) - [NCPU Firmware Configuration](./ncpu_firmware_configuration.md) - [Run Customized Examples](./run_customized_examples.md) diff --git a/docs/plus_c/feature_guide/generic_inference.md b/docs/plus_c/feature_guide/generic_inference.md index 44e8510..f733de8 100644 --- a/docs/plus_c/feature_guide/generic_inference.md +++ b/docs/plus_c/feature_guide/generic_inference.md @@ -29,7 +29,7 @@ ![](../imgs/generic_inference_flow.svg) -For **Generic Image Inference API**, images (RGB565, RGBA8888, YUYV422,...) can be provided as the input for the Kneron Device. And Kneron Device provides the automatic hardware image pre-processing including resize, padding, normalization and data re-layout before NPU inference. +For **Generic Image Inference API**, images (RGB565, RGBA8888, YUYV422,...) can be provided as the input for the Kneron Device. And Kneron Device provides the automatic [hardware image preprocessing](../appendix/hardware_image_preprocessing.md) including resize, padding, normalization and data re-layout before NPU inference. For **Generic Data Inference API**, data (or images), which is not supported by automatic hardware image pre-processing, can be used as the input for NPU inference, if and only if the data has been performed pre-processing on Host to the format that model requests on NPU. @@ -42,10 +42,12 @@ The pre-processing on Host includes but not limited to: Please refer following sections for according information: -- [Supported Image Format](../../plus_c/appendix/supported_image_format.md) for the supported image format of hardware image pre-processing. -- [Supported NPU Data Layout Format (KL520, KL720 and KL630)](../../plus_c/appendix/supported_npu_data_layout_format.md) for the NPU layout format. -- [Convert ONNX & NPU Data on the KL730 Platform](../../plus_c/appendix/convert_onnx_data_to_npu_data_on_kl730.md) for the KL730 ONNX/NPU data conversion. -- [3.1 Generic Data Inference With Pre-Processing on Host](#31-generic-data-inference-with-pre-processing-on-host) for the demonstration of the pre-processing. +- [Supported Image Format](../../plus_c/appendix/supported_image_format.md) for the supported image format of hardware image pre-processing. +- [Supported NPU Data Layout Format (KL520, KL720 and KL630)](../../plus_c/appendix/supported_npu_data_layout_format.md) for the KL520, KL720 and KL630 NPU layout format. +- [Supported NPU Data Layout Format (KL730)](../../plus_c/appendix/supported_npu_data_layout_format.md) for the KL730 NPU layout format. +- [Hardware Image Preprocessing](../appendix/hardware_image_preprocessing.md) for the efficient image preprocessing +- [Convert ONNX & NPU Data on the KL730 Platform](../../plus_c/appendix/convert_onnx_data_to_npu_data_on_kl730.md) for the KL730 ONNX/NPU data conversion. +- [3.1 Generic Data Inference With Pre-Processing on Host](#31-generic-data-inference-with-pre-processing-on-host) for the demonstration of the pre-processing. Furthermore, **Generic Inference** provide following functions to retrieve specific output node data (More information please reference *API Reference/Inference API*): @@ -70,7 +72,7 @@ Generic image inference examples are using the **Generic Image Inference API**, However, **Generic Image Inference API** can only provide the raw output from the model without post-processing. If you wish to get the result with post-processing, you may implement the corresponding post-processing in Software (Please refer [2.2 Generic Image Inference With Post-Processing on Host](#22-generic-image-inference-with-post-processing-on-host) for the demonstration). -In **Generic Image Inference API**, you may customized what to do in the pre-processing. There are few items are provided: +In **Generic Image Inference API**, you may customized what to do in the [hardware image preprocessing](../appendix/hardware_image_preprocessing.md). There are few items are provided: 1. Image Resize - You can choose to do or not to do the image resize by setting `resize_mode` in `kp_generic_input_node_image_t` of `kp_generic_image_inference_desc_t`. @@ -85,6 +87,7 @@ In **Generic Image Inference API**, you may customized what to do in the pre-pro 5. Data Normalization - You can choose to do *Kneron Normalization*, *Tensor Flow Normalization*, *Yolo Normalization*, or other *Customized Normalization* by setting `normalize_mode` in `kp_generic_input_node_image_t` of `kp_generic_image_inference_desc_t`. +>The **limitations** for the specified model input NPU format can be found in the [hardware image preprocessing](../appendix/hardware_image_preprocessing.md#limitation) documentation. ### 2.1 Generic Image Inference With Raw Output diff --git a/docs/plus_c/introduction/run_examples.md b/docs/plus_c/introduction/run_examples.md index 9561283..c13c71d 100644 --- a/docs/plus_c/introduction/run_examples.md +++ b/docs/plus_c/introduction/run_examples.md @@ -26,6 +26,7 @@ The provided examples are designed to show how to use KP APIs and present Kneron - [1.5 Generic Command Example](#15-generic-command-example) - [1.6 DFUT_console](#16-dfut_console) - [1.7 Device FIFO Queue Config Example](#17-device-fifo-queue-config-example) + - [1.8 Get Model Information Example](#18-get-model-information-example) - [2. Inference API Examples](#2-inference-api-examples) - [2.1 Generic Inference Example](#21-generic-inference-example) - [2.2 Customized Inference Example](#22-customized-inference-example) @@ -369,7 +370,7 @@ Therefore, all the functions in console mode, other than executable file name, a 11. For writing model into KL730, please refer [Write Model Into KL730](./write_model_to_flash.md#62-use-command-line-to-write-model-into-ai-device). -## 1.7 Device FIFO Queue Config Example +### 1.7 Device FIFO Queue Config Example This example is to show how to configure the `kp_ddr_manage_attr_t` and the usage of `kp_store_ddr_manage_attr()`. @@ -420,6 +421,80 @@ dumped node 1 output to 'output_bike_cars_street_224x224_node1_14x14x255.txt' ``` +### 1.8 Get Model Information Example + +This example demonstrates how to use `kp_load_model_from_file()` to parse the NEF file and retrieve model information from the NEF descriptor `kp_model_nef_descriptor_t`. This tool allows you to quickly probe the model metadata. + +```bash +$ sudo ./model_information -port 25 -target KL520 -model ../../res/models/KL520/tiny_yolo_v3/models_520.nef +``` + +```bash +-h : help +-target : [target platform] (KL520, KL720, KL630, KL730) = KL520 +-port : [port id set] = 25 (all, auto or specified port id set, can also be "13,537" for multiple devices) +-model : [model file path] (.nef) = ../../res/models/KL520/tiny_yolo_v3/models_520.nef + +connect device ... OK +upload firmware ... OK +upload model from usb ... OK +======================================================= +[nef metadata] +======================================================= + target: KL520 + crc: 0x6CBF1FF9 + num_models: 1 +======================================================= + kn_num: 0 + toolchain_version: kneron_compiler version: 2024-12-02(7b261fd55a)/kneron_nef_utils version: 2025-01-07(d9ea70a); + compiler_version: + nef_schema_version: 0.0.1 + platform: +======================================================= +[Model #0] +======================================================= + target: KL520 + version: 0x1 + id: 19 + setup_bin_schema_version: 0.0.0 + file_schema_version: 0.0.0 +======================================================= +[input node] +======================================================= + index: 0 + name: + data_layout: 4W4C8B + quantization parameter version: 1 + quantized_axis: 1 + quantization_parameter[0]: scale 1.000000 radix 8 + input shape npu: [ 1, 3, 224, 224] + input shape onnx: [ 1, 3, 224, 224] + input axis permutation onnx to npu: [ 0, 1, 2, 3] +======================================================= +[output node] +======================================================= + index: 0 + name: + data_layout: 16W1C8B + quantization parameter version: 1 + quantized_axis: 1 + quantization_parameter[0]: scale 1.471767 radix 2 + output shape npu: [ 1, 255, 7, 7] + output shape onnx: [ 1, 255, 7, 7] + output axis permutation onnx to npu: [ 0, 1, 2, 3] +======================================================= + index: 1 + name: + data_layout: 16W1C8B + quantization parameter version: 1 + quantized_axis: 1 + quantization_parameter[0]: scale 1.430706 radix 2 + output shape npu: [ 1, 255, 14, 14] + output shape onnx: [ 1, 255, 14, 14] + output axis permutation onnx to npu: [ 0, 1, 2, 3] +======================================================= +``` + --- ## 2. Inference API Examples diff --git a/docs/plus_c/introduction/upgrade_ai_device_to_kdp2.md b/docs/plus_c/introduction/upgrade_ai_device_to_kdp2.md index c7d153c..60bc7e4 100644 --- a/docs/plus_c/introduction/upgrade_ai_device_to_kdp2.md +++ b/docs/plus_c/introduction/upgrade_ai_device_to_kdp2.md @@ -1,6 +1,6 @@ # Upgrade AI Device to KDP2 Firmware -**Note**: KneronDFUT supports 3 platforms - Windows 10 (x86_64 64-bit), Ubuntu 18.04 (x86_64 64-bit), and Raspberry Pi OS - Buster (armv7l 32-bit) +**Note**: KneronDFUT supports 3 platforms - Windows 10, 11 (x86_64 64-bit) and Ubuntu 18.04 (x86_64 64-bit) **Note**: If you are not using the 3 platforms, you may use the DFUT_console provided in Kneron PLUS. Please refer [Build with DFUT_console](../../plus_c/introduction/build_plus.md#23-build-with-dfutconsole) diff --git a/docs/plus_c/introduction/write_model_to_flash.md b/docs/plus_c/introduction/write_model_to_flash.md index 03d43db..6bdf77f 100644 --- a/docs/plus_c/introduction/write_model_to_flash.md +++ b/docs/plus_c/introduction/write_model_to_flash.md @@ -1,6 +1,6 @@ # Write Model To Flash -**Note**: KneronDFUT supports 3 platforms - Windows 10 (x86_64 64-bit), Ubuntu 18.04 (x86_64 64-bit), and Raspberry Pi OS - Buster (armv7l 32-bit) +**Note**: KneronDFUT supports 3 platforms - Windows 10, 11 (x86_64 64-bit) and Ubuntu 18.04 (x86_64 64-bit) **Note**: If you are not using the 3 platforms, you may use the DFUT_console provided in Kneron PLUS. Please refer [Build with DFUT_console](../../plus_c/introduction/build_plus.md#23-build-with-dfutconsole) diff --git a/docs/plus_c/release_note/index.md b/docs/plus_c/release_note/index.md index a7ceaf8..291a558 100644 --- a/docs/plus_c/release_note/index.md +++ b/docs/plus_c/release_note/index.md @@ -1,7 +1,9 @@ ## Release Note ### KneronPLUS 3 -- [3.1.0 (Latest Version)](./v3/v3_1_0.md) +- [3.1.2 (Latest Version)](./v3/v3_1_2.md) +- [3.1.1](./v3/v3_1_1.md) +- [3.1.0](./v3/v3_1_0.md) - [3.0.0](./v3/v3_0_0.md) ### KneronPLUS 2 diff --git a/docs/plus_c/release_note/v3/v3_1_1.md b/docs/plus_c/release_note/v3/v3_1_1.md new file mode 100644 index 0000000..6d47d82 --- /dev/null +++ b/docs/plus_c/release_note/v3/v3_1_1.md @@ -0,0 +1,92 @@ +# Kneron PLUS 3.1.1 + +## Features +- N/A + +## Changes +- N/A + +## Bug Fixes +- Fix KL730 load model issue on toolchain 0.28.2 NEF files + +## The following components are contained in Kneron PLUS: +- KP API (C/Python) +- Example code +- ModelZoo example code +- KDP2 firmware code +- Pre-build firmware binary files +- NEF files for demonstration purposes + +*** + +# Kneron PLUS Enterprise 3.1.1 + +## Features +- N/A + +## Changes +- N/A + +## Bug Fixes +- Fix KL730 load model issue on toolchain 0.28.2 NEF files + +## The following components are contained in Kneron PLUS: +- KP API (C/Python) +- Example code +- Enterprise example code +- ModelZoo example code +- KDP2 firmware code +- Pre-build firmware binary files +- NEF files for demonstration purposes + +*** + +## Verified Platforms for C +| OS | Platform | +|--------------------------|---------------| +| Windows 10, 11 | x86_64 64-bit | +| Ubuntu 18.04, 20.04 | x86_64 64-bit | + +## Verified Platforms for Python +| OS | Platform | Python Version | +|--------------------------|---------------|--------------------------| +| Windows 10, 11 | x86_64 64-bit | 3.5-3.11 (x86_64 64-bit) | +| Ubuntu 18.04, 20.04 | x86_64 64-bit | 3.5-3.11 (x86_64 64-bit) | + +## Provide Model +* KL520 + * tiny_yolo_v3 + * ssd_fd_lm + * fcos-drk53s_w512h512_kn-model-zoo + * resnet18_w224h224_kn-model-zoo + * yolov5-noupsample_w640h640_kn-model-zoo +* KL720 + * YoloV5s_640_640_3 + * yolov5_pd + * fcos-drk53s_w512h512_kn-model-zoo + * resnet18_w224h224_kn-model-zoo + * yolov5-noupsample_w640h640_kn-model-zoo + * kn-model-zoo-mmcls_regnetx + * kn-model-zoo-mmcls_regnetx + * kn-model-zoo-mmpose_rsn18hand + * kn-model-zoo-mmseg_stdc + * kn-model-zoo-mmtracking_bytetrack +* KL630 + * YoloV5s_640_640_3 + * YoloV5s480_256_3_pdc +* KL730 + * YoloV5s_640_640_3 + * YoloV5s480_256_3_pdc + +## Supported Device +* KL520 (USB boot/Flash boot) +* KL720 (Flash boot) +* KL630 (USB boot/Flash boot) +* KL730 (USB boot/Flash boot) + +## Versions +* KL520 firmware v2.2.0 +* KL720 firmware v2.2.0 +* KL630 firmware SDK-v2.5.7 +* KL730 firmware SDK-v1.2.1 +* Kneron DFUT v3.1.0 \ No newline at end of file diff --git a/docs/plus_c/release_note/v3/v3_1_2.md b/docs/plus_c/release_note/v3/v3_1_2.md new file mode 100644 index 0000000..f5915d1 --- /dev/null +++ b/docs/plus_c/release_note/v3/v3_1_2.md @@ -0,0 +1,110 @@ +# Kneron PLUS 3.1.2 + +## Features +- Provide model information tool for quickly prob NEF metadata +- Provide kl730_demo_customize_inf_single_model_with_sw_npu_format_convert example +- KL730 removes FIFO queue setting size limitation +- KL730 Support New NPU Formats: + - KP_MODEL_TENSOR_DATA_LAYOUT_HW4C8B_KEEP_A + - KP_MODEL_TENSOR_DATA_LAYOUT_HW4C8B_DROP_A + - KP_MODEL_TENSOR_DATA_LAYOUT_HW1C8B + - KP_MODEL_TENSOR_DATA_LAYOUT_HW1C16B_LE + - KP_MODEL_TENSOR_DATA_LAYOUT_HW1C16B_BE + +## Changes +N/A + +## Bug Fixes +- Fix KL730 vision model inproc support issue +- The KL730 may be missing when setting invalid hardware image process parameters + +## The following components are contained in Kneron PLUS: +- KP API (C/Python) +- Example code +- ModelZoo example code +- KDP2 firmware code +- Pre-build firmware binary files +- NEF files for demonstration purposes + +*** + +# Kneron PLUS Enterprise 3.1.2 + +## Features +- Provide model information tool for quickly prob NEF metadata +- Provide kl730_demo_customize_inf_single_model_with_sw_npu_format_convert example +- KL730 removes FIFO queue setting size limitation +- KL730 Support New NPU Formats: + - KP_MODEL_TENSOR_DATA_LAYOUT_HW4C8B_KEEP_A + - KP_MODEL_TENSOR_DATA_LAYOUT_HW4C8B_DROP_A + - KP_MODEL_TENSOR_DATA_LAYOUT_HW1C8B + - KP_MODEL_TENSOR_DATA_LAYOUT_HW1C16B_LE + - KP_MODEL_TENSOR_DATA_LAYOUT_HW1C16B_BE + +## Changes +N/A + +## Bug Fixes +- Fix KL730 vision model inproc support issue +- The KL730 may be missing when setting invalid hardware image process parameters + +## The following components are contained in Kneron PLUS: +- KP API (C/Python) +- Example code +- Enterprise example code +- ModelZoo example code +- KDP2 firmware code +- Pre-build firmware binary files +- NEF files for demonstration purposes + +*** + +## Verified Platforms for C +| OS | Platform | +|--------------------------|---------------| +| Windows 10, 11 | x86_64 64-bit | +| Ubuntu 18.04, 20.04 | x86_64 64-bit | + +## Verified Platforms for Python +| OS | Platform | Python Version | +|--------------------------|---------------|--------------------------| +| Windows 10, 11 | x86_64 64-bit | 3.5-3.11 (x86_64 64-bit) | +| Ubuntu 18.04, 20.04 | x86_64 64-bit | 3.5-3.11 (x86_64 64-bit) | + +## Provide Model +* KL520 + * tiny_yolo_v3 + * ssd_fd_lm + * fcos-drk53s_w512h512_kn-model-zoo + * resnet18_w224h224_kn-model-zoo + * yolov5-noupsample_w640h640_kn-model-zoo +* KL720 + * YoloV5s_640_640_3 + * yolov5_pd + * fcos-drk53s_w512h512_kn-model-zoo + * resnet18_w224h224_kn-model-zoo + * yolov5-noupsample_w640h640_kn-model-zoo + * kn-model-zoo-mmcls_regnetx + * kn-model-zoo-mmcls_regnetx + * kn-model-zoo-mmpose_rsn18hand + * kn-model-zoo-mmseg_stdc + * kn-model-zoo-mmtracking_bytetrack +* KL630 + * YoloV5s_640_640_3 + * YoloV5s480_256_3_pdc +* KL730 + * YoloV5s_640_640_3 + * YoloV5s480_256_3_pdc + +## Supported Device +* KL520 (USB boot/Flash boot) +* KL720 (Flash boot) +* KL630 (USB boot/Flash boot) +* KL730 (USB boot/Flash boot) + +## Versions +* KL520 firmware v2.2.0 +* KL720 firmware v2.2.0 +* KL630 firmware SDK-v2.5.7 +* KL730 firmware SDK-v1.3.0 +* Kneron DFUT v3.1.2 diff --git a/docs/plus_c_api/api_reference_3.1.x/kp_core.h.md b/docs/plus_c_api/api_reference_3.1.0/kp_core.h.md similarity index 100% rename from docs/plus_c_api/api_reference_3.1.x/kp_core.h.md rename to docs/plus_c_api/api_reference_3.1.0/kp_core.h.md diff --git a/docs/plus_c_api/api_reference_3.1.x/kp_inference.h.md b/docs/plus_c_api/api_reference_3.1.0/kp_inference.h.md similarity index 100% rename from docs/plus_c_api/api_reference_3.1.x/kp_inference.h.md rename to docs/plus_c_api/api_reference_3.1.0/kp_inference.h.md diff --git a/docs/plus_c_api/api_reference_3.1.x/kp_inference_v1.h.md b/docs/plus_c_api/api_reference_3.1.0/kp_inference_v1.h.md similarity index 100% rename from docs/plus_c_api/api_reference_3.1.x/kp_inference_v1.h.md rename to docs/plus_c_api/api_reference_3.1.0/kp_inference_v1.h.md diff --git a/docs/plus_c_api/api_reference_3.1.x/kp_struct.h.md b/docs/plus_c_api/api_reference_3.1.0/kp_struct.h.md similarity index 100% rename from docs/plus_c_api/api_reference_3.1.x/kp_struct.h.md rename to docs/plus_c_api/api_reference_3.1.0/kp_struct.h.md diff --git a/docs/plus_c_api/api_reference_3.1.x/kp_struct_v1.h.md b/docs/plus_c_api/api_reference_3.1.0/kp_struct_v1.h.md similarity index 100% rename from docs/plus_c_api/api_reference_3.1.x/kp_struct_v1.h.md rename to docs/plus_c_api/api_reference_3.1.0/kp_struct_v1.h.md diff --git a/docs/plus_c_api/api_reference_3.1.x/kp_version.h.md b/docs/plus_c_api/api_reference_3.1.0/kp_version.h.md similarity index 100% rename from docs/plus_c_api/api_reference_3.1.x/kp_version.h.md rename to docs/plus_c_api/api_reference_3.1.0/kp_version.h.md diff --git a/docs/plus_c_api/api_reference_3.1.2/kp_core.h.md b/docs/plus_c_api/api_reference_3.1.2/kp_core.h.md new file mode 100644 index 0000000..840ff2a --- /dev/null +++ b/docs/plus_c_api/api_reference_3.1.2/kp_core.h.md @@ -0,0 +1,543 @@ +# Kneron PLUS core APIs + + +Core functions provide fundamental functionality like connection and firmware update + + + + + + +**Include Header File:** kp_core.h + +- Functions + - [kp_connect_devices](#kp_connect_devices) + - [kp_connect_devices_without_check](#kp_connect_devices_without_check) + - [kp_disable_firmware_log](#kp_disable_firmware_log) + - [kp_disconnect_devices](#kp_disconnect_devices) + - [kp_enable_firmware_log](#kp_enable_firmware_log) + - [kp_error_string](#kp_error_string) + - [kp_get_model_info](#kp_get_model_info) + - [kp_get_system_info](#kp_get_system_info) + - [kp_get_version](#kp_get_version) + - [kp_install_driver_for_windows](#kp_install_driver_for_windows) + - [kp_load_encrypted_models](#kp_load_encrypted_models) + - [kp_load_encrypted_models_from_file](#kp_load_encrypted_models_from_file) + - [kp_load_firmware](#kp_load_firmware) + - [kp_load_firmware_from_file](#kp_load_firmware_from_file) + - [kp_load_model](#kp_load_model) + - [kp_load_model_from_file](#kp_load_model_from_file) + - [kp_load_model_from_flash](#kp_load_model_from_flash) + - [kp_release_model_nef_descriptor](#kp_release_model_nef_descriptor) + - [kp_reset_device](#kp_reset_device) + - [kp_scan_devices](#kp_scan_devices) + - [kp_set_npu_timeout](#kp_set_npu_timeout) + - [kp_set_timeout](#kp_set_timeout) + - [kp_store_ddr_manage_attr](#kp_store_ddr_manage_attr) + + +--- + + + + +## **Functions** +### **kp_connect_devices** +> To connect multiple (including one) Kneron devices. + +```c +kp_device_group_t kp_connect_devices( + int num_devices + int device_port_ids[] + int *error_code +) +``` +**Parameters:** + +
+num_devices     [in]      number of devices
+device_port_ids [in]      an array contains device's port ID which can be known from kp_scan_devices(), if '0' is given then it will try to connect first connectable device.
+error_code      [out]     optional variable to indicate an error if connecting devices failed.
+
+**Returns:** + +kp_device_group_t represents a set of devices handle, if NULL means failed. + + +--- +### **kp_connect_devices_without_check** +> To connect multiple (including one) Kneron devices without any examinations of system info. + +```c +kp_device_group_t kp_connect_devices_without_check( + int num_devices + int device_port_ids[] + int *error_code +) +``` +**Parameters:** + +
+num_devices     [in]      number of devices
+device_port_ids [in]      an array contains device's port ID which can be known from kp_scan_devices(), if '0' is given then it will try to connect first connectable device.
+error_code      [out]     optional variable to indicate an error if connecting devices failed.
+
+**Returns:** + +kp_device_group_t represents a set of devices handle, if NULL means failed. + + +--- +### **kp_disable_firmware_log** +> Disable firmware log of all devices with firmware log enabled. + +```c +int kp_disable_firmware_log( + kp_device_group_t devices +) +``` +**Parameters:** + +
+devices         [in]      a set of devices handle.
+
+**Returns:** + +refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_disconnect_devices** +> To disconnect a Kneron device. + +```c +int kp_disconnect_devices( + kp_device_group_t devices +) +``` +**Parameters:** + +
+devices         [in]      a set of devices handle.
+
+**Returns:** + +refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_enable_firmware_log** +> Enable firmware log from certain device. + +```c +int kp_enable_firmware_log( + kp_device_group_t devices + int dev_port_id + char *log_file_path +) +``` +This function enables receiving firmware log from certain device with specific device index. +The firmware log could be written to text file or directly output to stdout. + + + +**Parameters:** + +
+devices         [in]      a set of devices handle.
+dev_port_id     [in]      the device port id to enable firmware log.
+log_file_path   [in]      the log file path, if NULL is passed then firmware log would be directly output to stdout.
+
+**Returns:** + +refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_error_string** +> Translate error code to char string. + +```c +const char *kp_error_string( + int error_code +) +``` +**Parameters:** + +
+error_code      [in]      status/error code from enum KP_API_RETURN_CODE.
+
+**Returns:** + +a char buffer of string represents the error message. + + +--- +### **kp_get_model_info** +> Get model info (crc, model id, etc.) (must release model_desc by kp_release_model_nef_descriptor). + +```c +int kp_get_model_info( + kp_device_group_t devices + int dev_port_id + kp_model_nef_descriptor_t *all_models_desc +) +``` +**Parameters:** + +
+devices         [in]      a set of devices handle.
+dev_port_id     [in]      specific device port id.
+all_models_desc [out]     return value of model info.
+
+**Returns:** + +refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_get_system_info** +> Get system info (kn number and firmware version). + +```c +int kp_get_system_info( + kp_device_group_t devices + int dev_port_id + kp_system_info_t *system_info +) +``` +**Parameters:** + +
+devices         [in]      a set of devices handle.
+dev_port_id     [in]      specific device port id.
+system_info     [out]     return value of system info.
+
+**Returns:** + +refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_get_version** +> Get PLUS version. + +```c +const char *kp_get_version() +``` +**Returns:** + +a string represents the PLUS version. + + +--- +### **kp_install_driver_for_windows** +> Install device driver on Windows + +```c +int kp_install_driver_for_windows( + kp_product_id_t device_pid +) +``` +**Parameters:** + +
+device_pid                product id of the device
+
+**Returns:** + +int refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_load_encrypted_models** +> upload encrypted models to multiple device through USB, and return kp_model_nef_descriptor_t *model_desc (must release model_desc by kp_release_model_nef_descriptor) + +```c +int kp_load_encrypted_models( + kp_device_group_t devices + void *nef_buf[] + int nef_size + int nef_num + kp_model_nef_descriptor_t *model_desc +) +``` +**Parameters:** + +
+devices         [in]      a set of devices handle.
+nef_buf         [in]      number of buffers that contain the content of NEF files.
+nef_size        [in]      file size of the NEF.
+nef_num         [in]      total number of NEF files.
+model_desc      [out]     this parameter is output for describing the uploaded models.
+
+**Returns:** + +refer to KP_API_RETURN_CODE in kp_struct.h + + +**Notes:** + +> for `nef_size`, the lengths of all encrypted NEF files originated from the same unencrypted NEF file should be the same. + + +--- +### **kp_load_encrypted_models_from_file** +> Similar to kp_load_encrypted_models(), and it accepts file paths instead of buffers (must release model_desc by kp_release_model_nef_descriptor). + +```c +int kp_load_encrypted_models_from_file( + kp_device_group_t devices + char *file_path[] + int nef_num + kp_model_nef_descriptor_t *model_desc +) +``` +**Parameters:** + +
+devices         [in]      a set of devices handle.
+file_path       [in]      file pathes of NEF files.
+nef_num         [in]      total number of NEF files.
+model_desc      [out]     this parameter is output for describing the uploaded models.
+
+**Returns:** + +refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_load_firmware** +> upload firmware from buffers + +```c +int kp_load_firmware( + kp_device_group_t devices + void *scpu_fw_buf + int scpu_fw_size + void *ncpu_fw_buf + int ncpu_fw_size +) +``` +**Parameters:** + +
+devices         [in]      a set of devices handle.
+scpu_fw_buf     [in]      scpu firmware buffer
+scpu_fw_size    [in]      scpu firmware size
+ncpu_fw_buf     [in]      ncpu firmware buffer
+ncpu_fw_size    [in]      ncpu firmware size
+
+**Returns:** + +refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_load_firmware_from_file** +> upload firmware from file + +```c +int kp_load_firmware_from_file( + kp_device_group_t devices + const char *scpu_fw_path + const char *ncpu_fw_path +) +``` +**Parameters:** + +
+devices         [in]      a set of devices handle.
+scpu_fw_path    [in]      scpu firmware file path
+ncpu_fw_path    [in]      ncpu firmware file path
+
+**Returns:** + +refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_load_model** +> upload models to device through USB, and return kp_model_nef_descriptor_t *model_desc (must release model_desc by kp_release_model_nef_descriptor) + +```c +int kp_load_model( + kp_device_group_t devices + void *nef_buf + int nef_size + kp_model_nef_descriptor_t *model_desc +) +``` +**Parameters:** + +
+devices         [in]      a set of devices handle.
+nef_buf         [in]      a buffer contains the content of NEF file.
+nef_size        [in]      file size of the NEF.
+model_desc      [out]     this parameter is output for describing the uploaded models.
+
+**Returns:** + +refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_load_model_from_file** +> Similar to kp_load_model(), and it accepts file path instead of a buffer (must release model_desc by kp_release_model_nef_descriptor) + +```c +int kp_load_model_from_file( + kp_device_group_t devices + const char *file_path + kp_model_nef_descriptor_t *model_desc +) +``` +**Parameters:** + +
+devices         [in]      a set of devices handle.
+file_path       [in]      a buffer contains the content of NEF file.
+model_desc      [out]     this parameter is output for describing the uploaded models.
+
+**Returns:** + +refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_load_model_from_flash** +> Load model from device flash, and return kp_model_nef_descriptor_t *model_desc (must release model_desc by kp_release_model_nef_descriptor) + +```c +int kp_load_model_from_flash( + kp_device_group_t devices + kp_model_nef_descriptor_t *model_desc +) +``` +**Parameters:** + +
+devices         [in]      a set of devices handle.
+model_desc      [out]     this parameter is output for describing the uploaded models.
+                          
+
+**Returns:** + +int refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_release_model_nef_descriptor** +> To free a kp_model_nef_descriptor_t data buff. + +```c +int kp_release_model_nef_descriptor( + kp_model_nef_descriptor_t *model_desc +) +``` +**Parameters:** + +
+model_desc      [in]      a model info descriptor.
+
+**Returns:** + +refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_reset_device** +> reset the device in hardware mode or software mode. + +```c +int kp_reset_device( + kp_device_group_t devices + kp_reset_mode_t reset_mode +) +``` +**Parameters:** + +
+devices         [in]      a set of devices handle.
+reset_mode      [in]      refer to kp_reset_mode_t.
+
+**Returns:** + +refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_scan_devices** +> Scan all Kneron devices and report a list. + +```c +kp_devices_list_t *kp_scan_devices() +``` +This function can get devices connectivity information at runtime. + + + +**Returns:** + +refer to kp_devices_list_t. + + +--- +### **kp_set_npu_timeout** +> To set a global timeout value for NPU inference timeout. (Please call after the load model function.) (Only support KL730/KL830.) + +```c +int kp_set_npu_timeout( + kp_device_group_t devices + unsigned int seconds +) +``` +**Parameters:** + +
+devices         [in]      a set of devices handle.
+seconds         [in]      pre-set NPU timeout value in seconds. (Set as 0 is wait forever.)
+
+**Returns:** + +refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_set_timeout** +> To set a global timeout value for all USB communications with the device. + +```c +void kp_set_timeout( + kp_device_group_t devices + int milliseconds +) +``` +**Parameters:** + +
+devices         [in]      a set of devices handle.
+milliseconds    [in]      pre-set timeout value in milliseconds.
+
+--- +### **kp_store_ddr_manage_attr** +> Store ddr manage attribute into device group + +```c +int kp_store_ddr_manage_attr( + kp_device_group_t devices + kp_ddr_manage_attr_t ddr_attr +) +``` +**Parameters:** + +
+devices                   a set of devices handle.
+ddr_attr                  ddr manage attributes, the zero item in this parameter will be auto generated
+
+**Returns:** + +int refer to KP_API_RETURN_CODE in kp_struct.h + + +--- diff --git a/docs/plus_c_api/api_reference_3.1.2/kp_inference.h.md b/docs/plus_c_api/api_reference_3.1.2/kp_inference.h.md new file mode 100644 index 0000000..de3a44e --- /dev/null +++ b/docs/plus_c_api/api_reference_3.1.2/kp_inference.h.md @@ -0,0 +1,506 @@ +# Kneron PLUS inference APIs + + +The inference functions provide sophisticated functionally for different applications. +Different set of inference APIs would need different models to make it work. + + + + + + +**Include Header File:** kp_inference.h + +- Functions + - [kp_customized_command_noack_send](#kp_customized_command_noack_send) + - [kp_customized_command_send](#kp_customized_command_send) + - [kp_customized_inference_receive](#kp_customized_inference_receive) + - [kp_customized_inference_send](#kp_customized_inference_send) + - [kp_dbg_receive_checkpoint_data](#kp_dbg_receive_checkpoint_data) + - [kp_dbg_set_enable_checkpoints](#kp_dbg_set_enable_checkpoints) + - [kp_generic_data_inference_receive](#kp_generic_data_inference_receive) + - [kp_generic_data_inference_send](#kp_generic_data_inference_send) + - [kp_generic_image_inference_receive](#kp_generic_image_inference_receive) + - [kp_generic_image_inference_send](#kp_generic_image_inference_send) + - [kp_generic_inference_retrieve_fixed_node](#kp_generic_inference_retrieve_fixed_node) + - [kp_generic_inference_retrieve_float_node](#kp_generic_inference_retrieve_float_node) + - [kp_generic_inference_retrieve_raw_fixed_node](#kp_generic_inference_retrieve_raw_fixed_node) + - [kp_inference_configure](#kp_inference_configure) + - [kp_profile_get_statistics](#kp_profile_get_statistics) + - [kp_profile_set_enable](#kp_profile_set_enable) + - [kp_release_dbg_checkpoint_data](#kp_release_dbg_checkpoint_data) + - [kp_release_fixed_node_output](#kp_release_fixed_node_output) + - [kp_release_float_node_output](#kp_release_float_node_output) + - [kp_release_raw_fixed_node_output](#kp_release_raw_fixed_node_output) + + +--- + + + + +## **Functions** +### **kp_customized_command_noack_send** +> To sned command. + +```c +int kp_customized_command_noack_send( + kp_device_group_t devices + void *cmd + int cmd_size +) +``` +**Parameters:** + +
+devices         [in]      a set of devices handle.
+cmd             [in]      RMI command.
+cmd_size        [in]      write length.
+
+**Returns:** + +refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_customized_command_send** +> send a user-defined command and receive the command result, users also need to implement code in firmware side as well. + +```c +int kp_customized_command_send( + kp_device_group_t devices + void *cmd + int cmd_size + void *return_buf + int return_buf_size +) +``` +**Parameters:** + +
+devices         [in]      a set of devices handle.
+cmd             [in]      user-defined command buffer, shoud include 'kp_inference_header_stamp_t' in the beginning; using 'job_id' as user-defined command ID, others will be handled by API.
+cmd_size        [in]      command buffer size.
+return_buf      [out]     user-defined command return buffer in any user-defined format.
+return_buf_size [out]     return buffer size.
+
+**Returns:** + +refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_customized_inference_receive** +> receive inference result of age gender + +```c +int kp_customized_inference_receive( + kp_device_group_t devices + void *result_buffer + int buf_size + int *recv_size +) +``` +**Parameters:** + +
+devices         [in]      a set of devices handle.
+result_buffer   [out]     user-prepared result buffer, when receiving data, it begins with 'kp_inference_header_stamp_t'. user should guarantee buffer size is big enough.
+buf_size        [in]      result buffer size.
+recv_size       [out]     received result size.
+
+**Returns:** + +refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_customized_inference_send** +> send image for age gender inference + +```c +int kp_customized_inference_send( + kp_device_group_t devices + void *header + int header_size + uint8_t *image + int image_size +) +``` +**Parameters:** + +
+devices         [in]      a set of devices handle.
+header          [in]      user-defined image header, shoud include 'kp_inference_header_stamp_t' in the beginning; in the header stamp, only 'job_id' is needed for user to fill in, others will be handled by API.
+header_size     [in]      image header size.
+image           [in]      image buffer.
+image_size      [in]      image buffer size.
+
+**Returns:** + +refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_dbg_receive_checkpoint_data** +> To receive debug checkpoint data, use it only if you enable kp_dbg_set_enable_checkpoints(). + +```c +int kp_dbg_receive_checkpoint_data( + kp_device_group_t devices + void **checkpoint_buf +) +``` +**Parameters:** + +
+devices         [in]      a set of devices handle.
+checkpoint_buf  [out]     a buffer contains checkpoint data, memory is allocated automatically while needed.
+
+**Returns:** + +refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_dbg_set_enable_checkpoints** +> Enable/Disable inference breakpoints in firmware for inference debugging purpose. + +```c +int kp_dbg_set_enable_checkpoints( + kp_device_group_t devices + uint32_t checkpoint_flags + bool enable +) +``` +**Parameters:** + +
+devices         [in]      a set of devices handle.
+checkpoint_flags[in]      bit-fields settings, refer to kp_dbg_checkpoint_flag_t.
+enable          [in]      set enable/disable.
+
+**Returns:** + +refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_generic_data_inference_receive** +> + +```c +int kp_generic_data_inference_receive( + kp_device_group_t devices + kp_generic_data_inference_result_header_t *output_desc + uint8_t *raw_out_buffer + uint32_t buf_size +) +``` +When a image inference is done, this function can be used to get the results in RAW format. + +Note that the data received is in Kneron RAW format, users need kp_generic_inference_retrieve_float_node() to convert RAW format data to floating-point data. + + + +**Parameters:** + +
+devices         [in]      a set of devices handle.
+output_desc     [in]      refer to kp_generic_data_inference_result_header_t for describing some information of received data.
+raw_out_buffer  [out]     a user-allocated buffer for receiving the RAW data results, the needed buffer size can be known from the 'max_raw_out_size' in 'model_desc' through kp_load_model().
+buf_size        [in]      size of raw_out_buffer.
+
+**Returns:** + +int refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_generic_data_inference_send** +> Generic raw inference with multiple input images and bypass pre-process send. + +```c +int kp_generic_data_inference_send( + kp_device_group_t devices + kp_generic_data_inference_desc_t *inf_data +) +``` +This is to perform one model inference with multiple input images without pre-processing on device, it is non-blocking if device buffer queue is not full. + +When this is performed, user can issue kp_generic_data_inference_receive() to get the result. + +In addition, to have better performance, users can issue multiple kp_generic_data_inference_send() then start to receive results through kp_generic_data_inference_receive(). + + + +**Parameters:** + +
+devices         [in]      a set of devices handle.
+inf_data        [in]      inference data of needed parameters for performing inference including image buffer size, model id.
+
+**Returns:** + +int refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_generic_image_inference_receive** +> + +```c +int kp_generic_image_inference_receive( + kp_device_group_t devices + kp_generic_image_inference_result_header_t *output_desc + uint8_t *raw_out_buffer + uint32_t buf_size +) +``` +**Parameters:** + +
+devices         [in]      a set of devices handle.
+output_desc     [in]      refer to kp_generic_image_inference_result_header_t for describing some information of received data.
+raw_out_buffer  [out]     a user-allocated buffer for receiving the RAW data results, the needed buffer size can be known from the 'max_raw_out_size' in 'model_desc' through kp_load_model().
+buf_size        [in]      size of raw_out_buffer.
+
+**Returns:** + +int refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_generic_image_inference_send** +> Generic raw inference with multiple input images send. + +```c +int kp_generic_image_inference_send( + kp_device_group_t devices + kp_generic_image_inference_desc_t *inf_data +) +``` +This is to perform one model inference with multiple input images, it is non-blocking if device buffer queue is not full. + +When this is performed, user can issue kp_generic_image_inference_receive() to get the result. + +In addition, to have better performance, users can issue multiple kp_generic_image_inference_send() then start to receive results through kp_generic_image_inference_receive(). + + + +**Parameters:** + +
+devices         [in]      a set of devices handle.
+inf_data        [in]      inference data of needed parameters for performing inference including image buffer size, model id.
+
+**Returns:** + +int refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_generic_inference_retrieve_fixed_node** +> Retrieve single node output data from raw output buffer. + +```c +kp_inf_fixed_node_output_t *kp_generic_inference_retrieve_fixed_node( + uint32_t node_idx + uint8_t *raw_out_buffer + kp_channel_ordering_t ordering +) +``` +This function retrieves and converts RAW format data to fixed-point data on the per-node basis. + + + +**Parameters:** + +
+node_idx        [in]      wanted output node index, starts from 0. Number of total output nodes can be known from 'kp_generic_raw_result_header_t'
+raw_out_buffer  [in]      the RAW output buffer, it should come from kp_generic_raw_inference_receive().
+ordering        [in]      the RAW output channel ordering
+
+**Returns:** + +refer to kp_inf_fixed_node_output_t. It describes fixed-point values of this node in specific channel ordering. + + +--- +### **kp_generic_inference_retrieve_float_node** +> Retrieve single node output data from raw output buffer. + +```c +kp_inf_float_node_output_t *kp_generic_inference_retrieve_float_node( + uint32_t node_idx + uint8_t *raw_out_buffer + kp_channel_ordering_t ordering +) +``` +This function retrieves and converts RAW format data to floating-point data on the per-node basis. + + + +**Parameters:** + +
+node_idx        [in]      wanted output node index, starts from 0. Number of total output nodes can be known from 'kp_generic_raw_result_header_t'
+raw_out_buffer  [in]      the RAW output buffer, it should come from kp_generic_raw_inference_receive().
+ordering        [in]      the RAW output channel ordering
+
+**Returns:** + +refer to kp_inf_float_node_output_t. It describes floating-point values of this node in specific channel ordering. + + +--- +### **kp_generic_inference_retrieve_raw_fixed_node** +> Retrieve single node output data from raw output buffer. + +```c +kp_inf_raw_fixed_node_output_t *kp_generic_inference_retrieve_raw_fixed_node( + uint32_t node_idx + uint8_t *raw_out_buffer +) +``` +This function retrieves RAW format data in fixed-point format on the per-node basis. + +The return pointer of 'kp_inf_raw_fixed_node_output_t' actually points to raw_out_buffer so do not free raw_out_buffer before completing the use of 'kp_inf_raw_fixed_node_output_t *' + + + +**Parameters:** + +
+node_idx        [in]      wanted output node index, starts from 0. Number of total output nodes can be known from 'kp_generic_raw_result_header_t'
+raw_out_buffer  [in]      the RAW output buffer, it should come from kp_generic_raw_inference_receive().
+
+**Returns:** + +refer to kp_inf_raw_fixed_node_output_t. It describes fixed-point values of this node with the Kneron device origin raw data buffer and channel ordering (KL520: height x channel x width (aligned to 16 byte), KL720: channel x height x width (aligned to 16 byte)). + + +--- +### **kp_inference_configure** +> Configure inference settings. + +```c +int kp_inference_configure( + kp_device_group_t devices + kp_inf_configuration_t *conf +) +``` +**Parameters:** + +
+conf            [in]      refer to kp_inf_configuration_t.
+
+**Returns:** + +refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_profile_get_statistics** +> Collect inference profile results. + +```c +int kp_profile_get_statistics( + kp_device_group_t devices + kp_profile_data_t *profile_data +) +``` +**Parameters:** + +
+devices         [in]      a set of devices handle.
+profile_data    [out]     refer to kp_profile_data_t.
+
+**Returns:** + +refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_profile_set_enable** +> To set enable/disable debug profile. + +```c +int kp_profile_set_enable( + kp_device_group_t devices + bool enable +) +``` +**Parameters:** + +
+devices         [in]      a set of devices handle.
+enable          [in]      set enable/disable.
+
+**Returns:** + +refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_release_dbg_checkpoint_data** +> Release the debug checkpoint data + +```c +int kp_release_dbg_checkpoint_data( + void *checkpoint_buf +) +``` +**Parameters:** + +
+checkpoint_buf            checkpoint buffer to be released
+
+**Returns:** + +refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_release_fixed_node_output** +> Release the single node output data from raw output buffer + +```c +void kp_release_fixed_node_output( + kp_inf_fixed_node_output_t *fixed_node_output +) +``` +**Parameters:** + +
+fixed_node_output          kp_inf_fixed_node_output_t to be released
+
+--- +### **kp_release_float_node_output** +> Release the single node output data from raw output buffer + +```c +void kp_release_float_node_output( + kp_inf_float_node_output_t *float_node_output +) +``` +**Parameters:** + +
+fixed_node_output          kp_inf_float_node_output_t to be released
+
+--- +### **kp_release_raw_fixed_node_output** +> Release the single node output data from raw output buffer + +```c +void kp_release_raw_fixed_node_output( + kp_inf_raw_fixed_node_output_t *raw_fixed_node_output +) +``` +**Parameters:** + +
+raw_fixed_node_output          kp_inf_raw_fixed_node_output_t to be released
+
+--- diff --git a/docs/plus_c_api/api_reference_3.1.2/kp_inference_v1.h.md b/docs/plus_c_api/api_reference_3.1.2/kp_inference_v1.h.md new file mode 100644 index 0000000..ac32e82 --- /dev/null +++ b/docs/plus_c_api/api_reference_3.1.2/kp_inference_v1.h.md @@ -0,0 +1,151 @@ +# Legacy Kneron PLUS inference APIs + + +**(To be deprecated in future release)** +The inference functions provide sophisticated functionally for different applications. +Different set of inference APIs would need different models to make it work. + + + + + + +**Include Header File:** kp_inference_v1.h + +- Functions + - [kp_generic_raw_inference_bypass_pre_proc_receive](#kp_generic_raw_inference_bypass_pre_proc_receive) + - [kp_generic_raw_inference_bypass_pre_proc_send](#kp_generic_raw_inference_bypass_pre_proc_send) + - [kp_generic_raw_inference_receive](#kp_generic_raw_inference_receive) + - [kp_generic_raw_inference_send](#kp_generic_raw_inference_send) + + +--- + + + + +## **Functions** +### **kp_generic_raw_inference_bypass_pre_proc_receive** +> Generic raw inference bypass pre-processing receive. + +```c +int kp_generic_raw_inference_bypass_pre_proc_receive( + kp_device_group_t devices + kp_generic_raw_bypass_pre_proc_result_header_t *output_desc + uint8_t *raw_out_buffer + uint32_t buf_size +) +``` +When a image inference is done, this function can be used to get the results in RAW format. + +Note that the data received is in Kneron RAW format, users need kp_generic_inference_retrieve_float_node() to convert RAW format data to floating-point data. + + + +**Parameters:** + +
+devices         [in]      a set of devices handle.
+output_desc     [in]      refer to kp_generic_raw_bypass_pre_proc_result_header_t for describing some information of received data.
+raw_out_buffer  [out]     a user-allocated buffer for receiving the RAW data results, the needed buffer size can be known from the 'max_raw_out_size' in 'model_desc' through kp_load_model().
+buf_size        [in]      size of raw_out_buffer.
+
+**Returns:** + +int refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_generic_raw_inference_bypass_pre_proc_send** +> Generic raw inference bypass pre-processing send. + +```c +int kp_generic_raw_inference_bypass_pre_proc_send( + kp_device_group_t devices + kp_generic_raw_bypass_pre_proc_image_header_t *inf_desc + uint8_t *image_buffer +) +``` +This is to perform a single image inference, it is non-blocking if device buffer queue is not full. + +When this is performed, user can issue kp_generic_raw_inference_bypass_pre_proc_receive() to get the result. + +In addition, to have better performance, users can issue multiple kp_generic_raw_inference_bypass_pre_proc_receive() then start to receive results through kp_generic_raw_inference_receive(). + + + +**Parameters:** + +
+devices         [in]      a set of devices handle.
+inf_desc        [in]      needed parameters for performing inference including image buffer size, model id.
+image_buffer    [in]      the buffer contains the image.
+
+**Returns:** + +int refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_generic_raw_inference_receive** +> Generic raw inference receive. + +```c +int kp_generic_raw_inference_receive( + kp_device_group_t devices + kp_generic_raw_result_header_t *output_desc + uint8_t *raw_out_buffer + uint32_t buf_size +) +``` +When a image inference is done, this function can be used to get the results in RAW format. + +Note that the data received is in Kneron RAW format, users need kp_generic_inference_retrieve_float_node() to convert RAW format data to floating-point data. + + + +**Parameters:** + +
+devices         [in]      a set of devices handle.
+output_desc     [in]      refer to kp_generic_raw_result_header_t for describing some information of received data.
+raw_out_buffer  [out]     a user-allocated buffer for receiving the RAW data results, the needed buffer size can be known from the 'max_raw_out_size' in 'model_desc' through kp_load_model().
+buf_size        [in]      size of raw_out_buffer.
+
+**Returns:** + +int refer to KP_API_RETURN_CODE in kp_struct.h + + +--- +### **kp_generic_raw_inference_send** +> Generic raw inference send. + +```c +int kp_generic_raw_inference_send( + kp_device_group_t devices + kp_generic_raw_image_header_t *inf_desc + uint8_t *image_buffer +) +``` +This is to perform a single image inference, it is non-blocking if device buffer queue is not full. + +When this is performed, user can issue kp_generic_raw_inference_receive() to get the result. + +In addition, to have better performance, users can issue multiple kp_generic_raw_inference_send() then start to receive results through kp_generic_raw_inference_receive(). + + + +**Parameters:** + +
+devices         [in]      a set of devices handle.
+inf_desc        [in]      needed parameters for performing inference including image width, height ..etc.
+image_buffer    [in]      the buffer contains the image.
+
+**Returns:** + +int refer to KP_API_RETURN_CODE in kp_struct.h + + +--- diff --git a/docs/plus_c_api/api_reference_3.1.2/kp_struct.h.md b/docs/plus_c_api/api_reference_3.1.2/kp_struct.h.md new file mode 100644 index 0000000..cb4bb51 --- /dev/null +++ b/docs/plus_c_api/api_reference_3.1.2/kp_struct.h.md @@ -0,0 +1,1235 @@ +# Kneron PLUS data structure + + + + +**Include Header File:** kp_struct.h + +- Defines + - APP_PADDING_BYTES + - KP_MAX_INPUT_NODE_COUNT + - KP_MAX_MODEL_COUNT + - KDP2_MAGIC_TYPE_COMMAND + - KDP2_MAGIC_TYPE_INFERENCE + - KDP2_MAGIC_TYPE_INFERENCE_V2 + - KDP2_MAGIC_TYPE_CUSTOMIZED + - KDP2_MAGIC_TYPE_CHECKPOINT_DATA + - KDP2_MAGIC_TYPE_CHECKPOINT_DATA_V2 + - KDP2_MAGIC_TYPE_JSON + - MAX_CROP_BOX + - YOLO_GOOD_BOX_MAX + - LAND_MARK_POINTS + - FR_FEAT_LENGTH +- Simple Typedef + - [typedef kp_device_group_s *kp_device_group_t;](#typedef-kp_device_group_s-kp_device_group_t) +- Enumerations + - [ KP_API_RETURN_CODE](#kp_api_return_code) + - [ kp_channel_ordering_t](#kp_channel_ordering_t) + - [ kp_dbg_checkpoint_flag_t](#kp_dbg_checkpoint_flag_t) + - [ kp_dtype_t](#kp_dtype_t) + - [ kp_fixed_point_dtype_t](#kp_fixed_point_dtype_t) + - [ kp_image_format_t](#kp_image_format_t) + - [ kp_model_target_chip_t](#kp_model_target_chip_t) + - [ kp_model_tensor_data_layout_t](#kp_model_tensor_data_layout_t) + - [ kp_model_tensor_shape_info_version_t](#kp_model_tensor_shape_info_version_t) + - [ kp_normalize_mode_t](#kp_normalize_mode_t) + - [ kp_padding_mode_t](#kp_padding_mode_t) + - [ kp_product_id_t](#kp_product_id_t) + - [ kp_quantization_parameters_version_t](#kp_quantization_parameters_version_t) + - [ kp_reset_mode_t](#kp_reset_mode_t) + - [ kp_resize_mode_t](#kp_resize_mode_t) + - [ kp_usb_speed_t](#kp_usb_speed_t) +- Structs + - [kp_available_ddr_config_t](#kp_available_ddr_config_t) + - [kp_bounding_box_t](#kp_bounding_box_t) + - [kp_classification_result_t](#kp_classification_result_t) + - [kp_dbg_checkpoint_data_after_cpu_op_t](#kp_dbg_checkpoint_data_after_cpu_op_t) + - [kp_dbg_checkpoint_data_after_inference_t](#kp_dbg_checkpoint_data_after_inference_t) + - [kp_dbg_checkpoint_data_after_preprocess_t](#kp_dbg_checkpoint_data_after_preprocess_t) + - [kp_dbg_checkpoint_data_before_cpu_op_t](#kp_dbg_checkpoint_data_before_cpu_op_t) + - [kp_dbg_checkpoint_data_before_preprocess_t](#kp_dbg_checkpoint_data_before_preprocess_t) + - [kp_ddr_manage_attr_t](#kp_ddr_manage_attr_t) + - [kp_device_descriptor_t](#kp_device_descriptor_t) + - [kp_device_group_s](#kp_device_group_s) + - [kp_devices_list_t](#kp_devices_list_t) + - [kp_eye_gaze_angles_t](#kp_eye_gaze_angles_t) + - [kp_face_occlude_result_t](#kp_face_occlude_result_t) + - [kp_fifo_queue_config_t](#kp_fifo_queue_config_t) + - [kp_file_schema_version_t](#kp_file_schema_version_t) + - [kp_firmware_version_t](#kp_firmware_version_t) + - [kp_fr_result_t](#kp_fr_result_t) + - [kp_generic_data_inference_desc_t](#kp_generic_data_inference_desc_t) + - [kp_generic_data_inference_result_header_t](#kp_generic_data_inference_result_header_t) + - [kp_generic_image_inference_desc_t](#kp_generic_image_inference_desc_t) + - [kp_generic_image_inference_result_header_t](#kp_generic_image_inference_result_header_t) + - [kp_generic_input_node_data_t](#kp_generic_input_node_data_t) + - [kp_generic_input_node_image_t](#kp_generic_input_node_image_t) + - [kp_hw_pre_proc_info_t](#kp_hw_pre_proc_info_t) + - [kp_inf_configuration_t](#kp_inf_configuration_t) + - [kp_inf_crop_box_t](#kp_inf_crop_box_t) + - [kp_inf_fixed_node_output_t](#kp_inf_fixed_node_output_t) + - [kp_inf_float_node_output_t](#kp_inf_float_node_output_t) + - [kp_inf_raw_fixed_node_metadata_t](#kp_inf_raw_fixed_node_metadata_t) + - [kp_inf_raw_fixed_node_output_t](#kp_inf_raw_fixed_node_output_t) + - [kp_inference_header_stamp_t](#kp_inference_header_stamp_t) + - [kp_landmark_result_t](#kp_landmark_result_t) + - [kp_model_nef_descriptor_t](#kp_model_nef_descriptor_t) + - [kp_model_nef_metadata_t](#kp_model_nef_metadata_t) + - [kp_nef_schema_version_t](#kp_nef_schema_version_t) + - [kp_point_t](#kp_point_t) + - [kp_quantization_parameters_t](#kp_quantization_parameters_t) + - [kp_quantization_parameters_v1_t](#kp_quantization_parameters_v1_t) + - [kp_quantized_fixed_point_descriptor_t](#kp_quantized_fixed_point_descriptor_t) + - [kp_setup_bin_schema_version_t](#kp_setup_bin_schema_version_t) + - [kp_single_model_descriptor_t](#kp_single_model_descriptor_t) + - [kp_system_info_t](#kp_system_info_t) + - [kp_tensor_descriptor_t](#kp_tensor_descriptor_t) + - [kp_tensor_shape_info_t](#kp_tensor_shape_info_t) + - [kp_tensor_shape_info_v1_t](#kp_tensor_shape_info_v1_t) + - [kp_tensor_shape_info_v2_t](#kp_tensor_shape_info_v2_t) + - [kp_yolo_result_t](#kp_yolo_result_t) +- Unions + - [ fixed_node_output_data_t](#fixed_node_output_data_t) + - [ kp_quantization_parameters_data_t](#kp_quantization_parameters_data_t) + - [ kp_scale_t](#kp_scale_t) + - [ kp_tensor_shape_info_data_t](#kp_tensor_shape_info_data_t) + + +--- + + + + +## **Defines** +| Define | Value | Description | +|:---|:---|:---| +|APP_PADDING_BYTES|28 | Default padding size | +|KP_MAX_INPUT_NODE_COUNT|100 | Supported maximum number of the model input node (Note: The KL520, KL720, and KL630 only support maximum 5 inputs.) | +|KP_MAX_MODEL_COUNT|16 | Supported maximum number of the models (Note: The KL520, KL720, and KL630 only support maximum 16 models.) | +|KDP2_MAGIC_TYPE_COMMAND|0xAB67CD13 | Magic number for data check | +|KDP2_MAGIC_TYPE_INFERENCE|0x11FF22AA | Magic number for data check | +|KDP2_MAGIC_TYPE_INFERENCE_V2|0x11FF22AB | Magic number for data check | +|KDP2_MAGIC_TYPE_CUSTOMIZED|0x11FF33CC | Magic number for customized data | +|KDP2_MAGIC_TYPE_CHECKPOINT_DATA|0x34ABF977 | Magic number for debug checkpoint data | +|KDP2_MAGIC_TYPE_CHECKPOINT_DATA_V2|0x34ABF978 | Magic number for debug checkpoint data | +|KDP2_MAGIC_TYPE_JSON|0x22EE3A86 | Magic number for json file stream | +|MAX_CROP_BOX|4 | MAX crop count | +|YOLO_GOOD_BOX_MAX|500 | maximum number of bounding boxes for Yolo models | +|LAND_MARK_POINTS|5 | the number of land marks points | +|FR_FEAT_LENGTH|256 | the length of one feature map | + + +--- + + + + +## **Simple Typedefs** +### **typedef kp_device_group_s *kp_device_group_t;** +> a pointer handle represent connected Kneron device. + + +--- + + + + +## **Enumerations** +### **KP_API_RETURN_CODE** +enum **KP_API_RETURN_CODE** {...} +> return code of most APIs. + +| Enumerator | | +|:---|:--- | +|KP_SUCCESS = 0,| | +|KP_ERROR_USB_IO_N1 = -1,| | +|KP_ERROR_USB_INVALID_PARAM_N2 = -2,| | +|KP_ERROR_USB_ACCESS_N3 = -3,| | +|KP_ERROR_USB_NO_DEVICE_N4 = -4,| | +|KP_ERROR_USB_NOT_FOUND_N5 = -5,| | +|KP_ERROR_USB_BUSY_N6 = -6,| | +|KP_ERROR_USB_TIMEOUT_N7 = -7,| | +|KP_ERROR_USB_OVERFLOW_N8 = -8,| | +|KP_ERROR_USB_PIPE_N9 = -9,| | +|KP_ERROR_USB_INTERRUPTED_N10 = -10,| | +|KP_ERROR_USB_NO_MEM_N11 = -11,| | +|KP_ERROR_USB_NOT_SUPPORTED_N12 = -12,| | +|KP_ERROR_USB_OTHER_N99 = -99,| | +|KP_ERROR_WDI_BEGIN = -200,| | +|KP_ERROR_WDI_IO_N1 = -201,| | +|KP_ERROR_WDI_INVALID_PARAM_N2 = -202,| | +|KP_ERROR_WDI_ACCESS_N3 = -203,| | +|KP_ERROR_WDI_NO_DEVICE_N4 = -204,| | +|KP_ERROR_WDI_NOT_FOUND_N5 = -205,| | +|KP_ERROR_WDI_BUSY_N6 = -206,| | +|KP_ERROR_WDI_TIMEOUT_N7 = -207,| | +|KP_ERROR_WDI_OVERFLOW_N8 = -208,| | +|KP_ERROR_WDI_PENDING_INSTALLATION_N9 = -209,| | +|KP_ERROR_WDI_INTERRUPTED_N10 = -210,| | +|KP_ERROR_WDI_RESOURCE_N11 = -211,| | +|KP_ERROR_WDI_NOT_SUPPORTED_N12 = -212,| | +|KP_ERROR_WDI_EXISTS_N13 = -213,| | +|KP_ERROR_WDI_USER_CANCEL_N14 = -214,| | +|KP_ERROR_WDI_NEEDS_ADMIN_N15 = -215,| | +|KP_ERROR_WDI_WOW64_N16 = -216,| | +|KP_ERROR_WDI_INF_SYNTAX_N17 = -217,| | +|KP_ERROR_WDI_CAT_MISSING_N18 = -218,| | +|KP_ERROR_WDI_UNSIGNED_N19 = -219,| | +|KP_ERROR_WDI_OTHER_N99 = -299,| | +|KP_ERROR_MEMORY_ALLOCATION_FAILURE_9 = 9,| | +|KP_ERROR_DEVICE_NOT_EXIST_10 = 10,| | +|KP_ERROR_DEVICE_INCORRECT_RESPONSE_11 = 11,| | +|KP_ERROR_INVALID_PARAM_12 = 12,| | +|KP_ERROR_SEND_DESC_FAIL_13 = 13,| | +|KP_ERROR_SEND_DATA_FAIL_14 = 14,| | +|KP_ERROR_SEND_DATA_TOO_LARGE_15 = 15,| | +|KP_ERROR_RECV_DESC_FAIL_16 = 16,| | +|KP_ERROR_RECV_DATA_FAIL_17 = 17,| | +|KP_ERROR_RECV_DATA_TOO_LARGE_18 = 18,| | +|KP_ERROR_FW_UPDATE_FAILED_19 = 19,| | +|KP_ERROR_FILE_OPEN_FAILED_20 = 20,| | +|KP_ERROR_INVALID_MODEL_21 = 21,| | +|KP_ERROR_IMAGE_RESOLUTION_TOO_SMALL_22 = 22,| | +|KP_ERROR_IMAGE_INVALID_WIDTH_23 = 23,| | +|KP_ERROR_INVALID_FIRMWARE_24 = 24,| | +|KP_ERROR_RESET_FAILED_25 = 25,| | +|KP_ERROR_DEVICES_NUMBER_26 = 26,| | +|KP_ERROR_CONFIGURE_DEVICE_27 = 27,| | +|KP_ERROR_CONNECT_FAILED_28 = 28,| | +|KP_ERROR_DEVICE_GROUP_MIX_PRODUCT_29 = 29,| | +|KP_ERROR_RECEIVE_INCORRECT_HEADER_STAMP_30 = 30,| | +|KP_ERROR_RECEIVE_SIZE_MISMATCH_31 = 31,| | +|KP_ERROR_RECEIVE_JOB_ID_MISMATCH_32 = 32,| | +|KP_ERROR_INVALID_CUSTOMIZED_JOB_ID_33 = 33,| | +|KP_ERROR_FW_LOAD_FAILED_34 = 34,| | +|KP_ERROR_MODEL_NOT_LOADED_35 = 35,| | +|KP_ERROR_INVALID_CHECKPOINT_DATA_36 = 36,| | +|KP_DBG_CHECKPOINT_END_37 = 37,| | +|KP_ERROR_INVALID_HOST_38 = 38,| | +|KP_ERROR_MEMORY_FREE_FAILURE_39 = 39,| | +|KP_ERROR_USB_BOOT_LOAD_SECOND_MODEL_40 = 40,| | +|KP_ERROR_CHECK_FW_VERSION_FAILED_41 = 41,| | +|KP_ERROR_FIFOQ_INPUT_BUFF_COUNT_NOT_ENOUGH_42 = 42,| | +|KP_ERROR_FIFOQ_SETTING_FAILED_43 = 43,| | +|KP_ERROR_UNSUPPORTED_DEVICE_44 = 44,| | +|KP_ERROR_IMAGE_INVALID_HEIGHT_45 = 45,| | +|KP_ERROR_ADJUST_DDR_HEAP_FAILED_46 = 46,| | +|KP_ERROR_DEVICE_NOT_ACCESSIBLE_47 = 47,| | +|KP_ERROR_INVALID_INPUT_NODE_DATA_NUMBER_48 = 48,| | +|KP_ERROR_OTHER_99 = 99,| | +|KP_FW_ERROR_UNKNOWN_APP = 100,| | +|KP_FW_INFERENCE_ERROR_101 = 101,| | +|KP_FW_DDR_MALLOC_FAILED_102 = 102,| | +|KP_FW_INFERENCE_TIMEOUT_103 = 103,| | +|KP_FW_LOAD_MODEL_FAILED_104 = 104,| | +|KP_FW_CONFIG_POST_PROC_ERROR_MALLOC_FAILED_105 = 105,| | +|KP_FW_CONFIG_POST_PROC_ERROR_NO_SPACE_106 = 106,| | +|KP_FW_IMAGE_SIZE_NOT_MATCH_MODEL_INPUT_107 = 107,| | +|KP_FW_NOT_SUPPORT_PREPROCESSING_108 = 108,| | +|KP_FW_GET_MODEL_INFO_FAILED_109 = 109,| | +|KP_FW_WRONG_INPUT_BUFFER_COUNT_110 = 110,| | +|KP_FW_INVALID_PRE_PROC_MODEL_INPUT_SIZE_111 = 111,| | +|KP_FW_INVALID_INPUT_CROP_PARAM_112 = 112,| | +|KP_FW_ERROR_FILE_OPEN_FAILED_113 = 113,| | +|KP_FW_ERROR_FILE_STATE_FAILED_114 = 114,| | +|KP_FW_ERROR_FILE_READ_FAILED_115 = 115,| | +|KP_FW_ERROR_FILE_WRITE_FAILED_116 = 116,| | +|KP_FW_ERROR_FILE_CHMOD_FAILED_117 = 117,| | +|KP_FW_ERROR_FILE_FAILED_OTHER_118 = 118,| | +|KP_FW_ERROR_INVALID_BOOT_CONFIG_119 = 119,| | +|KP_FW_ERROR_LOADER_ERROR_120 = 120,| | +|KP_FW_ERROR_POSIX_SPAWN_FAILED_121 = 121,| | +|KP_FW_ERROR_USB_SEND_FAILED_122 = 122,| | +|KP_FW_ERROR_USB_RECEIVE_FAILED_123 = 123,| | +|KP_FW_ERROR_HANDLE_NOT_READY_124 = 124,| | +|KP_FW_FIFOQ_ACCESS_FAILED_125 = 125,| | +|KP_FW_FIFOQ_NOT_READY_126 = 126,| | +|KP_FW_ERROR_FILE_SEEK_FAILED_127 = 127,| | +|KP_FW_ERROR_FILE_FLUSH_FAILED_128 = 128,| | +|KP_FW_ERROR_FILE_SYNC_FAILED_129 = 129,| | +|KP_FW_ERROR_FILE_CLOSE_FAILED_130 = 130,| | +|KP_FW_ERROR_MODEL_EXIST_CPU_NODE_131 = 131,| | +|KP_FW_ERROR_MODEL_EXIST_CONST_INPUT_NODE_132 = 132,| | +|KP_FW_ERROR_GET_MSG_QUEUE_FAILED_133 = 133,| | +|KP_FW_ERROR_SEND_MSG_QUEUE_FAILED_134 = 134,| | +|KP_FW_ERROR_RECV_MSG_QUEUE_FAILED_135 = 135,| | +|KP_FW_ERROR_UNSUPPORT_TOOLCHAIN_VERSION_136 = 136,| | +|KP_FW_ERROR_SET_IE_TIMEOUT_FAIL_137 = 137,| | +|KP_FW_ERROR_SET_NPU_TIMEOUT_FAIL_138 = 138,| | +|KP_FW_NCPU_ERR_BEGIN = 200,| | +|KP_FW_NCPU_INVALID_IMAGE_201 = 201,| | +|KP_FW_NCPU_INPROC_FAILED_202 = 202,| | +|KP_FW_NCPU_CPU_OP_NOT_FOUND_203 = 203,| | +|KP_FW_NCPU_MYSTERY_OP_NOT_FOUND_204 = 204,| | +|KP_FW_EFUSE_CAN_NOT_BURN_300 = 300,| | +|KP_FW_EFUSE_PROTECTED_301 = 301,| | +|KP_FW_EFUSE_OTHER_302 = 302,| | +|KP_FW_APP_MASK_FDFR_ENROLL_WITH_MASKED_FACE_10000 = 10000,| | +|KP_FW_APP_SEG_INSUFFICIENT_RESULT_BUFFER_SIZE_10001 = 10001,| | +|KP_FW_APP_STEREO_DEPTH_INSUFFICIENT_RESULT_BUFFER_SIZE_10100 = 10100,| | +|KP_FW_APP_STEREO_DEPTH_INSUFFICIENT_INPUT_IMAGE_10101 = 10101,| | +|KP_FW_APP_RGBD_SEG_INSUFFICIENT_RESULT_BUFFER_SIZE_10200 = 10200,| | +|KP_FW_APP_RGBD_SEG_INSUFFICIENT_INPUT_IMAGE_10201 = 10201,| | +|KP_FW_APP_RGBD_TRIPLE_CAM_SEG_INSUFFICIENT_RESULT_BUFFER_SIZE_10300 = 10300,| | +|KP_FW_APP_RGBD_TRIPLE_CAM_SEG_INSUFFICIENT_INPUT_IMAGE_10301 = 10301,| | +|KP_FW_APP_RGBD_TRIPLE_CAM_SEG_INVALID_DEPTH_DIRECTION_10302 = 10302,| | +|KP_FW_APP_AUDIO_DETECT_INVALID_INPUT_DATA_SIZE_10400 = 10400,| | +|KP_FW_APP_RGBD_TRIPLE_CAM_INSUFFICIENT_RESULT_BUFFER_SIZE_10500 = 10500,| | +|KP_FW_APP_RGBD_TRIPLE_CAM_INSUFFICIENT_INPUT_IMAGE_10501 = 10501,| | +|KP_FW_APP_RGBD_TRIPLE_CAM_INVALID_DEPTH_DIRECTION_10502 = 10502,| | +|KP_FW_APP_UNIFIED_VIDEO_CONFERENCE_PERSON_HEAD_MATCHING_FAILED_10600 = 10600,| | +|KP_FW_APP_UNIFIED_VIDEO_CONFERENCE_COMBINE_INPUT_FAILED_10601 = 10601,| | +|KP_FW_APP_TINY_VD_PERSON_HEAD_MATCHING_FAILED_10700 = 10700,| | +|KP_FW_APP_PD_FORKLIFT_PERSON_HEAD_MATCHING_FAILED_10800 = 10800,| | + + +--- +### **kp_channel_ordering_t** +typedef enum **kp_channel_ordering_t** {...} +> enum for generic raw data channel ordering + +| Enumerator | | +|:---|:--- | +|KP_CHANNEL_ORDERING_HCW = 0, | KL520 default, height/channel/width in order | +|KP_CHANNEL_ORDERING_CHW = 1, | KL720, KL630 default, channel/height/width in order | +|KP_CHANNEL_ORDERING_HWC = 2, | TensorFlow style, height/width/channel in order | +|KP_CHANNEL_ORDERING_DEFAULT = 3, | KL520, KL630, KL720 use their default, others use onnx shape order | + + +--- +### **kp_dbg_checkpoint_flag_t** +typedef enum **kp_dbg_checkpoint_flag_t** {...} +> Inference debug checkpoints in bit-fields format + +| Enumerator | | +|:---|:--- | +|KP_DBG_CHECKPOINT_BEFORE_PREPROCESS = 0x1 << 0, | Checkpoint data(image) at before-pre_processing stage | +|KP_DBG_CHECKPOINT_AFTER_PREPROCESS = 0x1 << 1, | Checkpoint data(image) at after-pre_processing stage | +|KP_DBG_CHECKPOINT_AFTER_INFERENCE = 0x1 << 2, | Checkpoint data(fixed-point raw) at after-inference stage | +|KP_DBG_CHECKPOINT_BEFORE_CPU_OP = 0x1 << 3, | Checkpoint data(cpu operation) at before-cpu operation stage | +|KP_DBG_CHECKPOINT_AFTER_CPU_OP = 0x1 << 4, | Checkpoint data(cpu operation) at after-cpu operation stage | + + +--- +### **kp_dtype_t** +typedef enum **kp_dtype_t** {...} +> enum for kneron data type + +| Enumerator | | +|:---|:--- | +|KP_DTYPE_UNKNOWN = 0, | unknown data type | +|KP_DTYPE_INT8 = 1, | represent one scalar value by int8_t data type | +|KP_DTYPE_INT16 = 2, | represent one scalar value by int16_t data type | +|KP_DTYPE_INT32 = 3, | represent one scalar value by int32_t data type | +|KP_DTYPE_INT64 = 4, | represent one scalar value by int64_t data type | +|KP_DTYPE_UINT8 = 5, | represent one scalar value by uint8_t data type | +|KP_DTYPE_UINT16 = 6, | represent one scalar value by uint16_t data type | +|KP_DTYPE_UINT32 = 7, | represent one scalar value by uint32_t data type | +|KP_DTYPE_UINT64 = 8, | represent one scalar value by uint64_t data type | +|KP_DTYPE_FLOAT32 = 9, | represent one scalar value by float32 data type | +|KP_DTYPE_BFLOAT16 = 10, | represent one scalar value by bfloat16 data type (store in uint16_t 2 bytes) | +|KP_DTYPE_DOUBLE64 = 11 | represent one scalar value by double64 data type | + + +--- +### **kp_fixed_point_dtype_t** +typedef enum **kp_fixed_point_dtype_t** {...} +> enum for fixed-point data type + +| Enumerator | | +|:---|:--- | +|KP_FIXED_POINT_DTYPE_UNKNOWN = 0, | unknown data type | +|KP_FIXED_POINT_DTYPE_INT8 = 1, | represent one fixed-point value by 8-bit data type | +|KP_FIXED_POINT_DTYPE_INT16 = 2, | represent one fixed-point value by 16-bit data type | + + +--- +### **kp_image_format_t** +typedef enum **kp_image_format_t** {...} +> image format supported for inference. + +| Enumerator | | +|:---|:--- | +|KP_IMAGE_FORMAT_UNKNOWN = 0x0,| | +|KP_IMAGE_FORMAT_RGB565 = 0x60, | RGB565 16bits (order: BGR) | +|KP_IMAGE_FORMAT_RGBA8888 = 0x0D, | RGBA8888 32bits | +|KP_IMAGE_FORMAT_YUYV = 0x2F, | YUYV 16bits | +|KP_IMAGE_FORMAT_YCBCR422_CRY1CBY0 = 0x30, | YCbCr422 (order: CrY1CbY0) 16bits | +|KP_IMAGE_FORMAT_YCBCR422_CBY1CRY0 = 0x31, | YCbCr422 (order: CbY1CrY0) 16bits | +|KP_IMAGE_FORMAT_YCBCR422_Y1CRY0CB = 0x32, | YCbCr422 (order: Y1CrY0Cb) 16bits | +|KP_IMAGE_FORMAT_YCBCR422_Y1CBY0CR = 0x33, | YCbCr422 (order: Y1CbY0Cr) 16bits | +|KP_IMAGE_FORMAT_YCBCR422_CRY0CBY1 = 0x34, | YCbCr422 (order: CrY0CbY1) 16bits | +|KP_IMAGE_FORMAT_YCBCR422_CBY0CRY1 = 0x35, | YCbCr422 (order: CbY0CrY1) 16bits | +|KP_IMAGE_FORMAT_YCBCR422_Y0CRY1CB = 0x36, | YCbCr422 (order: Y0CrY1Cb) 16bits | +|KP_IMAGE_FORMAT_YCBCR422_Y0CBY1CR = 0x37, | YCbCr422 (order: Y0CbY1Cr) 16bits | +|KP_IMAGE_FORMAT_RAW8 = 0x20, | RAW 8bits | +|KP_IMAGE_FORMAT_YUV420 = 0x70, | YUV420 (planar) 12bits (KL630 only) | + + +--- +### **kp_model_target_chip_t** +typedef enum **kp_model_target_chip_t** {...} +> model target chip. + +| Enumerator | | +|:---|:--- | +|KP_MODEL_TARGET_CHIP_UNKNOWN = 0,| | +|KP_MODEL_TARGET_CHIP_KL520 = 1, | model for kl520 | +|KP_MODEL_TARGET_CHIP_KL720 = 2, | model for kl720 | +|KP_MODEL_TARGET_CHIP_KL530 = 3, | model for kl530 | +|KP_MODEL_TARGET_CHIP_KL730 = 4, | model for kl730 | +|KP_MODEL_TARGET_CHIP_KL630 = 5, | model for kl630 | +|KP_MODEL_TARGET_CHIP_KL540 = 6, | model for kl540 | + + +--- +### **kp_model_tensor_data_layout_t** +typedef enum **kp_model_tensor_data_layout_t** {...} +> npu raw data layout format for tensors. + +| Enumerator | | +|:---|:--- | +|KP_MODEL_TENSOR_DATA_LAYOUT_UNKNOWN = 0,| | +|KP_MODEL_TENSOR_DATA_LAYOUT_4W4C8B = 1, | width: 4 scalars, channel: 4 scalars, depth: 8 bits | +|KP_MODEL_TENSOR_DATA_LAYOUT_1W16C8B = 2, | width: 1 scalars, channel: 16 scalars, depth: 8 bits | +|KP_MODEL_TENSOR_DATA_LAYOUT_16W1C8B = 3, | width: 16 scalars, channel: 1 scalars, depth: 8 bits | +|KP_MODEL_TENSOR_DATA_LAYOUT_8W1C16B = 4, | width: 8 scalars, channel: 1 scalars, depth: 16 bits | +|KP_MODEL_TENSOR_DATA_LAYOUT_4W4C8BHL = 5, | width: 4 scalars, channel: 4 scalars, depth: 16 bits, and store scalar into 2 entries with "High 8-bit" and "Low 8-bit" | +|KP_MODEL_TENSOR_DATA_LAYOUT_1W16C8BHL = 6, | width: 1 scalars, channel: 16 scalars, depth: 16 bits, and store scalar into 2 entries with "High 8-bit" and "Low 8-bit" | +|KP_MODEL_TENSOR_DATA_LAYOUT_16W1C8BHL = 7, | width: 16 scalars, channel: 1 scalars, depth: 16 bits, and store scalar into 2 entries with "High 8-bit" and "Low 8-bit" | +|KP_MODEL_TENSOR_DATA_LAYOUT_RAW_8B = 8, | packed int8_t data, depth: 8 bits | +|KP_MODEL_TENSOR_DATA_LAYOUT_RAW_16B = 9, | packed int16_t data, depth: 16 bits | +|KP_MODEL_TENSOR_DATA_LAYOUT_RAW_FLOAT = 10, | packed float data, depth: 32 bits | +|KP_MODEL_TENSOR_DATA_LAYOUT_1W16C8B_CH_COMPACT = 11, | width: 1 scalars, channel: 16 scalars, depth: 8 bits (channel compact mode) | +|KP_MODEL_TENSOR_DATA_LAYOUT_1W16C8BHL_CH_COMPACT = 12, | width: 1 scalars, channel: 16 scalars, depth: 16 bits, and store scalar into 2 entries with "High 8-bit" and "Low 8-bit" (channel compact mode) | +|KP_MODEL_TENSOR_DATA_LAYOUT_HW4C8B_KEEP_A = 13, | packed int8_t data, channel: 4 scalars, depth: 8 bits (NPU keeping alpha channel data in vision model, e.g. model input shape is 1x4xHxW) | +|KP_MODEL_TENSOR_DATA_LAYOUT_HW4C8B_DROP_A = 14, | packed int8_t data, channel: 4 scalars, depth: 8 bits (NPU ignore alpha channel data in vision model, e.g. model input shape is 1x3xHxW) | +|KP_MODEL_TENSOR_DATA_LAYOUT_HW1C8B = 15, | packed int8_t data, channel: 1 scalars, depth: 8 bits | +|KP_MODEL_TENSOR_DATA_LAYOUT_HW1C16B_LE = 16, | packed int16_t data, channel: 1 scalars, depth: 16 bits (16-bit data arranged in little-endian order) | +|KP_MODEL_TENSOR_DATA_LAYOUT_HW1C16B_BE = 17 | packed int16_t data, channel: 1 scalars, depth: 16 bits (16-bit data arranged in big-endian order) | + + +--- +### **kp_model_tensor_shape_info_version_t** +typedef enum **kp_model_tensor_shape_info_version_t** {...} +> shape information version for tensors. + +| Enumerator | | +|:---|:--- | +|KP_MODEL_TENSOR_SHAPE_INFO_VERSION_UNKNOWN = 0, | unknow version | +|KP_MODEL_TENSOR_SHAPE_INFO_VERSION_1 = 1, | version 1 - for KL520, KL720 and KL630 | +|KP_MODEL_TENSOR_SHAPE_INFO_VERSION_2 = 2 | version 2 - for KL730 | + + +--- +### **kp_normalize_mode_t** +typedef enum **kp_normalize_mode_t** {...} +> normalization mode + +| Enumerator | | +|:---|:--- | +|KP_NORMALIZE_DISABLE = 0xFF, | disable normalize | +|KP_NORMALIZE_KNERON = 0x1, | RGB/256 - 0.5, refer to the toolchain manual | +|KP_NORMALIZE_TENSOR_FLOW = 0x2, | RGB/127.5 - 1.0, refer to the toolchain manual | +|KP_NORMALIZE_YOLO = 0x3, | RGB/255.0, refer to the toolchain manual | +|KP_NORMALIZE_CUSTOMIZED_DEFAULT = 0x4, | customized, default, refer to the toolchain manual | +|KP_NORMALIZE_CUSTOMIZED_SUB128 = 0x5, | customized, subtract 128, refer to the toolchain manual | +|KP_NORMALIZE_CUSTOMIZED_DIV2 = 0x6, | customized, divide by 2, refer to the toolchain manual | +|KP_NORMALIZE_CUSTOMIZED_SUB128_DIV2 = 0x7, | customized, subtract 128 and divide by 2, refer to the toolchain manual | + + +--- +### **kp_padding_mode_t** +typedef enum **kp_padding_mode_t** {...} +> padding mode + +| Enumerator | | +|:---|:--- | +|KP_PADDING_DISABLE = 0x1, | Disable Padding in Pre-process | +|KP_PADDING_CORNER = 0x2, | Using Corner Padding in Pre-process | +|KP_PADDING_SYMMETRIC = 0x3, | Using Symmetric Padding in Pre-process | + + +--- +### **kp_product_id_t** +typedef enum **kp_product_id_t** {...} +> enum for USB PID(Product ID) + +| Enumerator | | +|:---|:--- | +|KP_DEVICE_KL520 = 0x100, | KL520 USB PID | +|KP_DEVICE_KL720 = 0x720, | KL720 USB PID | +|KP_DEVICE_KL720_LEGACY = 0x200, | KL720 Legacy USB PID | +|KP_DEVICE_KL530 = 0x530, | KL530 USB PID | +|KP_DEVICE_KL830 = 0x832, | KL830 USB PID | +|KP_DEVICE_KL730 = 0x732, | KL730 USB PID | +|KP_DEVICE_KL630 = 0x630, | KL630 USB PID | +|KP_DEVICE_KL540 = 0x540, | KL540 USB PID | + + +--- +### **kp_quantization_parameters_version_t** +typedef enum **kp_quantization_parameters_version_t** {...} +> quantization parameters version for tensors. + +| Enumerator | | +|:---|:--- | +|KP_MODEL_QUANTIZATION_PARAMS_VERSION_UNKNOWN = 0, | unknow version | +|KP_MODEL_QUANTIZATION_PARAMS_VERSION_1 = 1, | version 1 - for KL520, KL720, KL630 and KL730 | + + +--- +### **kp_reset_mode_t** +typedef enum **kp_reset_mode_t** {...} +> reset mode + +| Enumerator | | +|:---|:--- | +|KP_RESET_REBOOT = 0, | Highest level to reset Kneron device. Kneron device would disconnect after this reset. | +|KP_RESET_INFERENCE = 1, | Soft reset: reset inference FIFO queue. | +|KP_RESET_SHUTDOWN = 2, | Shut down Kneron device. For KL520, only useful if HW circuit supports (ex. 96 board), dongle is not supported. For KL720, this function is not supported. | +|KP_RESET_REBOOT_SYSTEM = 3, | Reboot entire system | + + +--- +### **kp_resize_mode_t** +typedef enum **kp_resize_mode_t** {...} +> resize mode + +| Enumerator | | +|:---|:--- | +|KP_RESIZE_DISABLE = 0x1, | Disable Resize in Pre-process | +|KP_RESIZE_ENABLE = 0x2, | Enable Resize in Pre-process | + + +--- +### **kp_usb_speed_t** +typedef enum **kp_usb_speed_t** {...} +> enum for USB speed mode + +| Enumerator | | +|:---|:--- | +|KP_USB_SPEED_UNKNOWN = 0,| | +|KP_USB_SPEED_LOW = 1,| | +|KP_USB_SPEED_FULL = 2,| | +|KP_USB_SPEED_HIGH = 3,| | +|KP_USB_SPEED_SUPER = 4,| | + + +--- + + + + +## **Structs** +### **kp_available_ddr_config_t** +typedef struct **kp_available_ddr_config_t** {...} +> Describe DDR memory space current configuration + +|Members| | +|:---|:--- | +|uint32_t ddr_available_begin;| Available DDR space begin address | +|uint32_t ddr_available_end;| Available DDR space end address | +|uint32_t ddr_model_end;| Model used DDR space end address | +|uint32_t ddr_fifoq_allocated;| Whether FIFO queue has been configured | + + +--- +### **kp_bounding_box_t** +typedef struct **kp_bounding_box_t** {...} +> describe a bounding box + +|Members| | +|:---|:--- | +|float x1;| top-left corner: x | +|float y1;| top-left corner: y | +|float x2;| bottom-right corner: x | +|float y2;| bottom-right corner: y | +|float score;| probability score | +|int32_t class_num;| class # (of many) with highest probability | + + +--- +### **kp_classification_result_t** +typedef struct **kp_classification_result_t** {...} +> describe a classification result + +|Members| | +|:---|:--- | +|int32_t class_num;| class # (of many) with highest probability | +|float score;| probability score | + + +--- +### **kp_dbg_checkpoint_data_after_cpu_op_t** +typedef struct **kp_dbg_checkpoint_data_after_cpu_op_t** {...} +> Inference debug data structure represents for "after-cpu operation" + +|Members| | +|:---|:--- | +|kp_inference_header_stamp_t header_stamp;| magic_type = 'KDP2_MAGIC_TYPE_CHECKPOINT_DATA' | +|uint32_t checkpoint_tag;| refer to kp_dbg_checkpoint_flag_t | +|int target_inf_model;| inferencing model | +|uint32_t num_nodes;| number of output nodes | +|kp_tensor_descriptor_t *node_metadata;| array of model output node metada | +|uint32_t total_output_size;| total raw output size in bytes | +|uint8_t *raw_output;| truly raw output from NPU | + + +--- +### **kp_dbg_checkpoint_data_after_inference_t** +typedef struct **kp_dbg_checkpoint_data_after_inference_t** {...} +> Inference debug data structure represents for "after-inference" + +|Members| | +|:---|:--- | +|kp_inference_header_stamp_t header_stamp;| magic_type = 'KDP2_MAGIC_TYPE_CHECKPOINT_DATA' | +|uint32_t checkpoint_tag;| refer to kp_dbg_checkpoint_flag_t | +|int target_inf_model;| inferencing model | +|uint32_t num_nodes;| number of output nodes | +|kp_tensor_descriptor_t *node_metadata;| array of model output node metada | +|uint32_t total_output_size;| total raw output size in bytes | +|uint8_t *raw_output;| truly raw output from NPU | + + +--- +### **kp_dbg_checkpoint_data_after_preprocess_t** +typedef struct **kp_dbg_checkpoint_data_after_preprocess_t** {...} +> Inference debug data structure represents for "after-pre_process" + +|Members| | +|:---|:--- | +|kp_inference_header_stamp_t header_stamp;| magic_type = 'KDP2_MAGIC_TYPE_CHECKPOINT_DATA' | +|uint32_t checkpoint_tag;| refer to kp_dbg_checkpoint_flag_t | +|uint32_t img_width;| image width in pixels | +|uint32_t img_height;| image height in pixels | +|uint32_t img_format;| image format, refer to kp_image_format_t | +|int target_inf_model;| inferencing model | +|uint32_t img_index;| index of input image | +|uint8_t image[];| image raw data | + + +--- +### **kp_dbg_checkpoint_data_before_cpu_op_t** +typedef struct **kp_dbg_checkpoint_data_before_cpu_op_t** {...} +> Inference debug data structure represents for "before-cpu operation" + +|Members| | +|:---|:--- | +|kp_inference_header_stamp_t header_stamp;| magic_type = 'KDP2_MAGIC_TYPE_CHECKPOINT_DATA' | +|uint32_t checkpoint_tag;| refer to kp_dbg_checkpoint_flag_t | +|int target_inf_model;| inferencing model | +|uint32_t num_nodes;| number of output nodes | +|kp_tensor_descriptor_t *node_metadata;| array of model output node metada | +|uint32_t total_output_size;| total raw output size in bytes | +|uint8_t *raw_output;| truly raw output from NPU | + + +--- +### **kp_dbg_checkpoint_data_before_preprocess_t** +typedef struct **kp_dbg_checkpoint_data_before_preprocess_t** {...} +> Inference debug data structure represents for "before-pre_process" + +|Members| | +|:---|:--- | +|kp_inference_header_stamp_t header_stamp;| magic_type = 'KDP2_MAGIC_TYPE_CHECKPOINT_DATA' | +|uint32_t checkpoint_tag;| refer to kp_dbg_checkpoint_flag_t | +|uint32_t img_x;| image position X | +|uint32_t img_y;| image position Y | +|uint32_t img_width;| image width in pixels | +|uint32_t img_height;| image height in pixels | +|uint32_t img_format;| image format, refer to kp_image_format_t | +|int target_inf_model;| inferencing model | +|uint32_t img_index;| index of input image | +|uint8_t image[];| image raw data | + + +--- +### **kp_ddr_manage_attr_t** +typedef struct **kp_ddr_manage_attr_t** {...} +> attribute for configuring ddr + +|Members| | +|:---|:--- | +|uint32_t model_size;| DDR space for model | +|uint32_t input_buffer_size;| input buffer size for FIFO queue | +|uint32_t input_buffer_count;| input buffer count for FIFO queue | +|uint32_t result_buffer_size;| result buffer size for FIFO queue | +|uint32_t result_buffer_count;| result buffer count for FIFO queue | + + +--- +### **kp_device_descriptor_t** +typedef struct **kp_device_descriptor_t** {...} +> information of device (USB) + +|Members| | +|:---|:--- | +|uint32_t port_id;| an unique ID representing for a Kneron device, can be used as input while connecting devices | +|uint16_t vendor_id;| supposed to be 0x3231. | +|uint16_t product_id;| enum kp_product_id_t. | +|int link_speed;| enum kp_usb_speed_t. | +|uint32_t kn_number;| KN number. | +|bool isConnectable;| indicate if this device is connectable. | +|char port_path[20];| "busNo-hub_portNo-device_portNo"
ex: "1-2-3", means bus 1 - (hub) port 2 - (device) port 3 | +|char firmware[30];| Firmware description. | + + +--- +### **kp_device_group_s** +typedef struct **kp_device_group_s** {...} +> a handle represent connected Kneron device. + +|Members| | +|:---|:--- | +|int timeout;| global timeout value for all USB communications with the device | +|int num_device;| number of devices in device group | +|kp_product_id_t product_id;| enum kp_product_id_t | +|kp_model_nef_descriptor_t loaded_model_desc;| a basic descriptor for a NEF | +|kp_ddr_manage_attr_t ddr_attr;| attribute for configuring ddr | + + +--- +### **kp_devices_list_t** +typedef struct **kp_devices_list_t** {...} +> information of connected devices from USB perspectives. + +|Members| | +|:---|:--- | +|int num_dev;| connected devices | +|kp_device_descriptor_t device[];| real index range from 0 ~ (num_dev-1) | + + +--- +### **kp_eye_gaze_angles_t** +typedef struct **kp_eye_gaze_angles_t** {...} +> describe an eye gaze result + +|Members| | +|:---|:--- | +|float theta;| value of theta | +|float phi;| value of phi | + + +--- +### **kp_face_occlude_result_t** +typedef struct **kp_face_occlude_result_t** {...} +> describe a face occlusion output result after post-processing + +|Members| | +|:---|:--- | +|float yaw;| value of yaw | +|float pitch;| value of pitch | +|float roll;| value of roll | +|float occ;| occlusion score | + + +--- +### **kp_fifo_queue_config_t** +typedef struct **kp_fifo_queue_config_t** {...} +> Describe FIFO Queue current configuration + +|Members| | +|:---|:--- | +|uint32_t fifoq_input_buf_count;| Input buffer count for FIFO queue, 0 if FIFO queue has not been set | +|uint32_t fifoq_input_buf_size;| Input buffer size for FIFO queue, 0 if FIFO queue has not been set | +|uint32_t fifoq_result_buf_count;| Input buffer count for FIFO queue, 0 if FIFO queue has not been set | +|uint32_t fifoq_result_buf_size;| Input buffer size for FIFO queue, 0 if FIFO queue has not been set | + + +--- +### **kp_file_schema_version_t** +typedef struct **kp_file_schema_version_t** {...} +> a basic descriptor for setup.bin file schema version + +|Members| | +|:---|:--- | +|uint32_t major;| major number | +|uint32_t minor;| minor number | +|uint32_t revision;| revision number | + + +--- +### **kp_firmware_version_t** +typedef struct **kp_firmware_version_t** {...} +> describe version string + +|Members| | +|:---|:--- | +|uint8_t reserved;| for backward compatibility | +|uint8_t major;| major number | +|uint8_t minor;| minor number | +|uint8_t update;| update number | +|uint32_t build;| build number | + + +--- +### **kp_fr_result_t** +typedef struct **kp_fr_result_t** {...} +> describe a feature map + +|Members| | +|:---|:--- | +|float feature_map[FR_FEAT_LENGTH];| feature map in floating point | +|int8_t feature_map_fixed[FR_FEAT_LENGTH];| feature map in fixed point | + + +--- +### **kp_generic_data_inference_desc_t** +typedef struct **kp_generic_data_inference_desc_t** {...} +> inference descriptor for multiple input images bypass pre-processing + +|Members| | +|:---|:--- | +|uint32_t inference_number;| inference sequence number | +|uint32_t model_id;| target inference model ID | +|uint32_t num_input_node_data;| number of data for input nodes | +|kp_generic_input_node_data_t input_node_data_list[KP_MAX_INPUT_NODE_COUNT];| list of data for each input node(maps to input nodes order of model) | + + +--- +### **kp_generic_data_inference_result_header_t** +typedef struct **kp_generic_data_inference_result_header_t** {...} +> inference RAW output descriptor for multiple input and bypass pre-processing + +|Members| | +|:---|:--- | +|uint32_t inference_number;| inference sequence number | +|uint32_t crop_number;| crop box sequence number | +|uint32_t num_output_node;| total number of output nodes | +|uint32_t product_id;| product id, refer to kp_product_id_t | + + +--- +### **kp_generic_image_inference_desc_t** +typedef struct **kp_generic_image_inference_desc_t** {...} +> inference descriptor for images + +|Members| | +|:---|:--- | +|uint32_t inference_number;| inference sequence number | +|uint32_t model_id;| target inference model ID | +|uint32_t num_input_node_image;| number of images for input nodes | +|kp_generic_input_node_image_t input_node_image_list[KP_MAX_INPUT_NODE_COUNT];| list of image data for each input node(maps to input nodes order of model) | + + +--- +### **kp_generic_image_inference_result_header_t** +typedef struct **kp_generic_image_inference_result_header_t** {...} +> inference RAW output descriptor + +|Members| | +|:---|:--- | +|uint32_t inference_number;| inference sequence number | +|uint32_t crop_number;| crop box sequence number | +|uint32_t num_output_node;| total number of output nodes | +|uint32_t product_id;| product id, refer to kp_product_id_t | +|uint32_t num_pre_proc_info;| number of pre_proc_info is available | +|kp_hw_pre_proc_info_t pre_proc_info[KP_MAX_INPUT_NODE_COUNT];| hardware pre-process related value | + + +--- +### **kp_generic_input_node_data_t** +typedef struct **kp_generic_input_node_data_t** {...} +> inference RAW descriptor for one image under bypass pre process + +|Members| | +|:---|:--- | +|uint32_t buffer_size;| buffer size | +|uint8_t *buffer;| buffer of input data| + + +--- +### **kp_generic_input_node_image_t** +typedef struct **kp_generic_input_node_image_t** {...} +> inference RAW descriptor for one image + +|Members| | +|:---|:--- | +|uint32_t width;| image width | +|uint32_t height;| image height | +|uint32_t resize_mode;| resize mode, refer to kp_resize_mode_t | +|uint32_t padding_mode;| padding mode, refer to kp_resize_mode_t | +|uint32_t image_format;| image format, refer to kp_image_format_t | +|uint32_t normalize_mode;| inference normalization, refer to kp_normalize_mode_t | +|uint32_t crop_count;| crop count | +|kp_inf_crop_box_t inf_crop[MAX_CROP_BOX];| box information to crop | +|uint8_t *image_buffer;| image buffer | + + +--- +### **kp_hw_pre_proc_info_t** +typedef struct **kp_hw_pre_proc_info_t** {...} +> hardware pre-process related value for raw output result + +|Members| | +|:---|:--- | +|uint32_t img_width;| image width before hardware pre-process | +|uint32_t img_height;| image height before hardware pre-process | +|uint32_t resized_img_width;| image width after resize | +|uint32_t resized_img_height;| image height after resize | +|uint32_t pad_top;| pixels padding on top | +|uint32_t pad_bottom;| pixels padding on bottom | +|uint32_t pad_left;| pixels padding on left | +|uint32_t pad_right;| pixels padding on right | +|uint32_t model_input_width;| model required input width | +|uint32_t model_input_height;| model required input height | +|kp_inf_crop_box_t crop_area;| info of crop area (may not be the same as input due to hw limit) | + + +--- +### **kp_inf_configuration_t** +typedef struct **kp_inf_configuration_t** {...} +> data structure for inference configurations + +|Members| | +|:---|:--- | +|bool enable_frame_drop;| enable this to keep inference non-blocking by dropping oldest and unprocessed frames | + + +--- +### **kp_inf_crop_box_t** +typedef struct **kp_inf_crop_box_t** {...} +> data structure for a crop + +|Members| | +|:---|:--- | +|uint32_t crop_number;| index number | +|uint32_t x1;| top-left corner: x | +|uint32_t y1;| top-left corner: y | +|uint32_t width;| width | +|uint32_t height;| height | + + +--- +### **kp_inf_fixed_node_output_t** +typedef struct **kp_inf_fixed_node_output_t** {...} +> RAW node output in fixed-point format + +|Members| | +|:---|:--- | +|char* name;| name of node | +|uint32_t shape_len;| length of shape | +|int32_t* shape;| shape | +|kp_quantization_parameters_t quantization_parameters;| quantization parameters | +|uint32_t fixed_point_dtype;| enum kp_fixed_point_dtype_t | +|uint32_t num_data;| total number of fixed-point values | +|fixed_node_output_data_t data;| data of fixed-point values in 8-bits/16-bits (depended on fixed_point_dtype) ref. fixed_node_output_data_t | + + +--- +### **kp_inf_float_node_output_t** +typedef struct **kp_inf_float_node_output_t** {...} +> RAW node output in floating-point format + +|Members| | +|:---|:--- | +|char* name;| name of node | +|uint32_t shape_len;| length of shape | +|int32_t* shape;| shape | +|uint32_t num_data;| total number of floating-point values | +|float data[];| array of floating-point values | + + +--- +### **kp_inf_raw_fixed_node_metadata_t** +typedef struct **kp_inf_raw_fixed_node_metadata_t** {...} +> Metadata of RAW node output in fixed-point format + +|Members| | +|:---|:--- | +|kp_tensor_descriptor_t tensor_descriptor;| tensor information | + + +--- +### **kp_inf_raw_fixed_node_output_t** +typedef struct **kp_inf_raw_fixed_node_output_t** {...} +> RAW node output in raw fixed-point format (with width padding and device channel ordering) + +|Members| | +|:---|:--- | +|kp_inf_raw_fixed_node_metadata_t metadata;| metadata of RAW node output in fixed-point format | +|uint32_t num_data;| total number of NPU raw data | +|int8_t *data;| array of NPU raw data | + + +--- +### **kp_inference_header_stamp_t** +typedef struct **kp_inference_header_stamp_t** {...} +> header stamp for user-defined data transfer + +|Members| | +|:---|:--- | +|uint32_t magic_type;| must be 'KDP2_MAGIC_TYPE_XXXXXX' | +|uint32_t total_size;| total size of user-defined header data struct and data (image) | +|uint32_t job_id;| user-defined ID to synchronize with firmware side, must >= 1000 | +|uint32_t status_code;| this field is valid only for result data, refer to KP_API_RETURN_CODE | +|uint32_t total_image;| total number of images for this inference | +|uint32_t image_index;| the index of the image in this transmission | + + +--- +### **kp_landmark_result_t** +typedef struct **kp_landmark_result_t** {...} +> describe a landmark + +|Members| | +|:---|:--- | +|kp_point_t marks[LAND_MARK_POINTS];| landmark points | +|float score;| score of this landmark | +|float blur;| blur score of this landmark | +|int32_t class_num;| class number | + + +--- +### **kp_model_nef_descriptor_t** +typedef struct **kp_model_nef_descriptor_t** {...} +> a basic descriptor for a NEF + +|Members| | +|:---|:--- | +|uint32_t magic;| magic number for model_nef_descriptor (0x5AA55AA5) | +|kp_model_nef_metadata_t metadata;| nef metadata | +|uint32_t target;| target chip of all models (1: KL520, 2: KL720, etc.) | +|uint32_t crc;| crc of all models | +|uint32_t num_models;| number of models | +|kp_single_model_descriptor_t* models;| model descriptors | + + +--- +### **kp_model_nef_metadata_t** +typedef struct **kp_model_nef_metadata_t** {...} +> a basic descriptor for a NEF metadata + +|Members| | +|:---|:--- | +|uint32_t kn_num;| target KN number device of encrypted all models | +|char* toolchain_version;| toolchain version of all models | +|char* compiler_version;| compiler version of all models | +|kp_nef_schema_version_t nef_schema_version;| schema version of nef | +|char* platform;| usb dongle, 96 board, etc. | + + +--- +### **kp_nef_schema_version_t** +typedef struct **kp_nef_schema_version_t** {...} +> a basic descriptor for nef schema version + +|Members| | +|:---|:--- | +|uint32_t major;| major number | +|uint32_t minor;| minor number | +|uint32_t revision;| revision number | + + +--- +### **kp_point_t** +typedef struct **kp_point_t** {...} +> decribe a point + +|Members| | +|:---|:--- | +|uint32_t x;| x value | +|uint32_t y;| y value | + + +--- +### **kp_quantization_parameters_t** +typedef struct **kp_quantization_parameters_t** {...} +> a basic descriptor for quantization parameters + +|Members| | +|:---|:--- | +|uint32_t version;| quantization parameters version (ref. kp_model_tensor_shape_info_version_t) | +|kp_quantization_parameters_data_t quantization_parameters_data;| quantization parameters data | + + +--- +### **kp_quantization_parameters_v1_t** +typedef struct **kp_quantization_parameters_v1_t** {...} +> a basic descriptor for quantization parameters (version 1) + +|Members| | +|:---|:--- | +|uint32_t quantized_axis;| the axis along which the fixed-point quantization information performed | +|uint32_t quantized_fixed_point_descriptor_num;| numbers of fixed-point quantization information | +|kp_quantized_fixed_point_descriptor_t* quantized_fixed_point_descriptor;| array of fixed-point quantization information | + + +--- +### **kp_quantized_fixed_point_descriptor_t** +typedef struct **kp_quantized_fixed_point_descriptor_t** {...} +> a basic descriptor for a fixed-point quantization information + +|Members| | +|:---|:--- | +|int32_t radix;| radix of node | +|uint32_t scale_dtype;| datatype of scale (ref. kp_dtype_t) | +|kp_scale_t scale;| scale of node | + + +--- +### **kp_setup_bin_schema_version_t** +typedef struct **kp_setup_bin_schema_version_t** {...} +> a basic descriptor for setup.bin schema version + +|Members| | +|:---|:--- | +|uint32_t major;| major number | +|uint32_t minor;| minor number | +|uint32_t revision;| revision number | + + +--- +### **kp_single_model_descriptor_t** +typedef struct **kp_single_model_descriptor_t** {...} +> a basic descriptor for a model + +|Members| | +|:---|:--- | +|uint32_t target;| target chip of model | +|uint32_t version;| version of model | +|uint32_t id;| id of model | +|uint32_t input_nodes_num;| number of model input nodes | +|kp_tensor_descriptor_t* input_nodes;| array of model output node information | +|uint32_t output_nodes_num;| number of model output nodes | +|kp_tensor_descriptor_t* output_nodes;| array of model output node information | +|kp_setup_bin_schema_version_t setup_bin_schema_version;| schema version of setup.bin | +|kp_file_schema_version_t file_schema_version;| file schema version of setup.bin | +|uint32_t max_raw_out_size;| needed raw output buffer size for this model | + + +--- +### **kp_system_info_t** +typedef struct **kp_system_info_t** {...} +> describe system information + +|Members| | +|:---|:--- | +|uint32_t kn_number;| Chip K/N number | +|kp_firmware_version_t firmware_version;| FW version | + + +--- +### **kp_tensor_descriptor_t** +typedef struct **kp_tensor_descriptor_t** {...} +> a basic descriptor for a node in model + +|Members| | +|:---|:--- | +|uint32_t index;| index of node | +|char* name;| name of node | +|uint32_t data_layout;| npu memory layout (ref. kp_model_tensor_data_layout_t) | +|kp_tensor_shape_info_t tensor_shape_info;| shape information | +|kp_quantization_parameters_t quantization_parameters;| quantization parameters | + + +--- +### **kp_tensor_shape_info_t** +typedef struct **kp_tensor_shape_info_t** {...} +> a basic descriptor for a node in model + +|Members| | +|:---|:--- | +|uint32_t version;| shape information version (ref. kp_model_tensor_shape_info_version_t) | +|kp_tensor_shape_info_data_t tensor_shape_info_data;| shape information data | + + +--- +### **kp_tensor_shape_info_v1_t** +typedef struct **kp_tensor_shape_info_v1_t** {...} +> a shape descriptor for a tensor (version 1) + +|Members| | +|:---|:--- | +|uint32_t shape_npu_len;| length of npu shape (Default value: 4) | +|int32_t* shape_npu;| npu shape (Default dimension order: BxCxHxW) | +|uint32_t shape_onnx_len;| length of onnx shape | +|int32_t* shape_onnx;| onnx shape | +|uint32_t axis_permutation_len;| length of remap axis permutation | +|int32_t* axis_permutation_onnx_to_npu;| remap axis permutation from onnx to npu shape (shape_intrp_dim) | + + +--- +### **kp_tensor_shape_info_v2_t** +typedef struct **kp_tensor_shape_info_v2_t** {...} +> a shape descriptor for a tensor (version 2) + +|Members| | +|:---|:--- | +|uint32_t shape_len;| length of shape | +|int32_t* shape;| shape | +|uint32_t* stride_onnx;| data access stride of ONNX (in scalar) | +|uint32_t* stride_npu;| data access stride of NPU (in scalar) | + + +--- +### **kp_yolo_result_t** +typedef struct **kp_yolo_result_t** {...} +> describe a yolo output result after post-processing + +|Members| | +|:---|:--- | +|uint32_t class_count;| total class count detectable by model | +|uint32_t box_count;| boxes of all classes | +|kp_bounding_box_t boxes[YOLO_GOOD_BOX_MAX];| box information | + + +--- + + + + +## **Unions** +### **fixed_node_output_data_t** +typedef union **fixed_node_output_data_t** {...} +> data of fixed-point values in 8-bits/16-bits (depended on fixed_point_dtype) + +|Members| | +|:---|:--- | +|int8_t int8[1];| array of fixed-point values in 8-bits | +|int16_t int16[1];| array of fixed-point values in 16-bits | + + +--- +### **kp_quantization_parameters_data_t** +typedef union **kp_quantization_parameters_data_t** {...} +> a basic descriptor for quantization parameters (version 1) + +|Members| | +|:---|:--- | +|kp_quantization_parameters_v1_t v1;| quantization parameters - version 1 | + + +--- +### **kp_scale_t** +typedef union **kp_scale_t** {...} +> a scale of node + +|Members| | +|:---|:--- | +|int8_t scale_int8;| scale of node in data type int8 | +|int16_t scale_int16;| scale of node in data type int16 | +|int32_t scale_int32;| scale of node in data type int32 | +|int64_t scale_int64;| scale of node in data type int64 | +|uint8_t scale_uint8;| scale of node in data type uint8 | +|uint16_t scale_uint16;| scale of node in data type uint16 | +|uint32_t scale_uint32;| scale of node in data type uint32 | +|uint64_t scale_uint64;| scale of node in data type uint64 | +|uint16_t scale_bfloat16;| scale of node in data type bfloat16 (store in uint16_t 2 bytes) | +|float scale_float32;| scale of node in data type float32 | +|double scale_double64;| scale of node in data type double64 | + + +--- +### **kp_tensor_shape_info_data_t** +typedef union **kp_tensor_shape_info_data_t** {...} +> a shape descriptor data for a tensor + +|Members| | +|:---|:--- | +|kp_tensor_shape_info_v1_t v1;| shape information - version 1 | +|kp_tensor_shape_info_v2_t v2;| shape information - version 2 | + + +--- diff --git a/docs/plus_c_api/api_reference_3.1.2/kp_struct_v1.h.md b/docs/plus_c_api/api_reference_3.1.2/kp_struct_v1.h.md new file mode 100644 index 0000000..4814859 --- /dev/null +++ b/docs/plus_c_api/api_reference_3.1.2/kp_struct_v1.h.md @@ -0,0 +1,83 @@ +# Legacy Kneron PLUS data structure + + +**(To be deprecated in future release)** + + + + + + +**Include Header File:** kp_struct_v1.h + +- Structs + - [kp_generic_raw_bypass_pre_proc_image_header_t](#kp_generic_raw_bypass_pre_proc_image_header_t) + - [kp_generic_raw_bypass_pre_proc_result_header_t](#kp_generic_raw_bypass_pre_proc_result_header_t) + - [kp_generic_raw_image_header_t](#kp_generic_raw_image_header_t) + - [kp_generic_raw_result_header_t](#kp_generic_raw_result_header_t) + + +--- + + + + +## **Structs** +### **kp_generic_raw_bypass_pre_proc_image_header_t** +typedef struct **kp_generic_raw_bypass_pre_proc_image_header_t** {...} +> inference descriptor for images bypass pre-processing + +|Members| | +|:---|:--- | +|uint32_t inference_number;| inference sequence number | +|uint32_t model_id;| target inference model ID | +|uint32_t image_buffer_size;| image buffer size | + + +--- +### **kp_generic_raw_bypass_pre_proc_result_header_t** +typedef struct **kp_generic_raw_bypass_pre_proc_result_header_t** {...} +> inference RAW output descriptor for bypass pre-processing + +|Members| | +|:---|:--- | +|uint32_t inference_number;| inference sequence number | +|uint32_t crop_number;| crop box sequence number | +|uint32_t num_output_node;| total number of output nodes | +|uint32_t product_id;| product id, refer to kp_product_id_t | + + +--- +### **kp_generic_raw_image_header_t** +typedef struct **kp_generic_raw_image_header_t** {...} +> inference descriptor for images + +|Members| | +|:---|:--- | +|uint32_t inference_number;| inference sequence number | +|uint32_t model_id;| target inference model ID | +|uint32_t width;| image width | +|uint32_t height;| image height | +|uint32_t resize_mode;| resize mode, refer to kp_resize_mode_t | +|uint32_t padding_mode;| padding mode, refer to kp_resize_mode_t | +|uint32_t image_format;| image format, refer to kp_image_format_t | +|uint32_t normalize_mode;| inference normalization, refer to kp_normalize_mode_t | +|uint32_t crop_count;| crop count | +|kp_inf_crop_box_t inf_crop[MAX_CROP_BOX];| box information to crop | + + +--- +### **kp_generic_raw_result_header_t** +typedef struct **kp_generic_raw_result_header_t** {...} +> inference RAW output descriptor + +|Members| | +|:---|:--- | +|uint32_t inference_number;| inference sequence number | +|uint32_t crop_number;| crop box sequence number | +|uint32_t num_output_node;| total number of output nodes | +|uint32_t product_id;| product id, refer to kp_product_id_t | +|kp_hw_pre_proc_info_t pre_proc_info;| hardware pre-process related value | + + +--- diff --git a/docs/plus_c_api/api_reference_3.1.2/kp_version.h.md b/docs/plus_c_api/api_reference_3.1.2/kp_version.h.md new file mode 100644 index 0000000..b8aa205 --- /dev/null +++ b/docs/plus_c_api/api_reference_3.1.2/kp_version.h.md @@ -0,0 +1,30 @@ +# Kneron PLUS version + + + + +**Include Header File:** kp_version.h + +- Enumerations + - [ fw_version_index_t](#fw_version_index_t) + + +--- + + + + +## **Enumerations** +### **fw_version_index_t** +typedef enum **fw_version_index_t** {...} +> firmware version index. + +| Enumerator | | +|:---|:--- | +|VERSION_INDEX_MAJOR = 0,| | +|VERSION_INDEX_MINOR = 1,| | +|VERSION_INDEX_REVISION = 2,| | +|VERSION_INDEX_BUILD = 3,| | + + +--- diff --git a/docs/plus_python/api_document/V3.1.2/index.md b/docs/plus_python/api_document/V3.1.2/index.md new file mode 100644 index 0000000..fc5922a --- /dev/null +++ b/docs/plus_python/api_document/V3.1.2/index.md @@ -0,0 +1,347 @@ + +# KneronPLUS python API documentation + +## **KneronPLUS Core API** + +### kp.core + +The kp.core functions provide fundamental functionality like connection and firmware update. + +### kp.inference + +The kp.inference functions provide sophisticated functionally for different applications. Different set of inference APIs would need different models to make it work. + +### kp value + +Kneron PLUS objects. + +### kp enum + +Kneron PLUS enum values. + +### kp exception + +Kneron PLUS exception handler. + +### kp.KPConstant + +Kneron PLUS constant value. + +### kp.v1 (Legacy Module) + +Kneron PLUS V1.x legacy modules (inference, kp value). + +### API Reference + + +* [kp.core](kp/core.md) + + + * [`connect_devices()`](kp/core.md#kp.core.connect_devices) + + + * [`connect_devices_without_check()`](kp/core.md#kp.core.connect_devices_without_check) + + + * [`disable_firmware_log()`](kp/core.md#kp.core.disable_firmware_log) + + + * [`disconnect_devices()`](kp/core.md#kp.core.disconnect_devices) + + + * [`enable_firmware_log()`](kp/core.md#kp.core.enable_firmware_log) + + + * [`get_model_info()`](kp/core.md#kp.core.get_model_info) + + + * [`get_system_info()`](kp/core.md#kp.core.get_system_info) + + + * [`get_version()`](kp/core.md#kp.core.get_version) + + + * [`install_driver_for_windows()`](kp/core.md#kp.core.install_driver_for_windows) + + + * [`load_encrypted_models()`](kp/core.md#kp.core.load_encrypted_models) + + + * [`load_encrypted_models_from_file()`](kp/core.md#kp.core.load_encrypted_models_from_file) + + + * [`load_firmware()`](kp/core.md#kp.core.load_firmware) + + + * [`load_firmware_from_file()`](kp/core.md#kp.core.load_firmware_from_file) + + + * [`load_model()`](kp/core.md#kp.core.load_model) + + + * [`load_model_from_file()`](kp/core.md#kp.core.load_model_from_file) + + + * [`load_model_from_flash()`](kp/core.md#kp.core.load_model_from_flash) + + + * [`reset_device()`](kp/core.md#kp.core.reset_device) + + + * [`scan_devices()`](kp/core.md#kp.core.scan_devices) + + + * [`set_npu_timeout()`](kp/core.md#kp.core.set_npu_timeout) + + + * [`set_timeout()`](kp/core.md#kp.core.set_timeout) + + + * [`store_ddr_management_attributes()`](kp/core.md#kp.core.store_ddr_management_attributes) + + +* [kp.inference](kp/inference.md) + + + * [`generic_data_inference_receive()`](kp/inference.md#kp.inference.generic_data_inference_receive) + + + * [`generic_data_inference_send()`](kp/inference.md#kp.inference.generic_data_inference_send) + + + * [`generic_image_inference_receive()`](kp/inference.md#kp.inference.generic_image_inference_receive) + + + * [`generic_image_inference_send()`](kp/inference.md#kp.inference.generic_image_inference_send) + + + * [`generic_inference_retrieve_fixed_node()`](kp/inference.md#kp.inference.generic_inference_retrieve_fixed_node) + + + * [`generic_inference_retrieve_float_node()`](kp/inference.md#kp.inference.generic_inference_retrieve_float_node) + + + * [`profile_get_statistics()`](kp/inference.md#kp.inference.profile_get_statistics) + + + * [`profile_set_enable()`](kp/inference.md#kp.inference.profile_set_enable) + + + * [`set_inference_configuration()`](kp/inference.md#kp.inference.set_inference_configuration) + + +* [kp value](kp/value.md) + + + * [`DdrManageAttributes`](kp/value.md#kp.DdrManageAttributes) + + + * [`DeviceDescriptor`](kp/value.md#kp.DeviceDescriptor) + + + * [`DeviceDescriptorList`](kp/value.md#kp.DeviceDescriptorList) + + + * [`DeviceGroup`](kp/value.md#kp.DeviceGroup) + + + * [`FirmwareVersion`](kp/value.md#kp.FirmwareVersion) + + + * [`GenericDataInferenceDescriptor`](kp/value.md#kp.GenericDataInferenceDescriptor) + + + * [`GenericDataInferenceResult`](kp/value.md#kp.GenericDataInferenceResult) + + + * [`GenericDataInferenceResultHeader`](kp/value.md#kp.GenericDataInferenceResultHeader) + + + * [`GenericImageInferenceDescriptor`](kp/value.md#kp.GenericImageInferenceDescriptor) + + + * [`GenericImageInferenceResult`](kp/value.md#kp.GenericImageInferenceResult) + + + * [`GenericImageInferenceResultHeader`](kp/value.md#kp.GenericImageInferenceResultHeader) + + + * [`GenericInputNodeData`](kp/value.md#kp.GenericInputNodeData) + + + * [`GenericInputNodeImage`](kp/value.md#kp.GenericInputNodeImage) + + + * [`GenericRawResultNDArray`](kp/value.md#kp.GenericRawResultNDArray) + + + * [`HwPreProcInfo`](kp/value.md#kp.HwPreProcInfo) + + + * [`InferenceConfiguration`](kp/value.md#kp.InferenceConfiguration) + + + * [`InferenceCropBox`](kp/value.md#kp.InferenceCropBox) + + + * [`InferenceFixedNodeOutput`](kp/value.md#kp.InferenceFixedNodeOutput) + + + * [`InferenceFloatNodeOutput`](kp/value.md#kp.InferenceFloatNodeOutput) + + + * [`ModelNefDescriptor`](kp/value.md#kp.ModelNefDescriptor) + + + * [`ModelNefMetadata`](kp/value.md#kp.ModelNefMetadata) + + + * [`NefSchemaVersion`](kp/value.md#kp.NefSchemaVersion) + + + * [`NpuPerformanceMonitorStatistics`](kp/value.md#kp.NpuPerformanceMonitorStatistics) + + + * [`PerformanceMonitorData`](kp/value.md#kp.PerformanceMonitorData) + + + * [`ProfileData`](kp/value.md#kp.ProfileData) + + + * [`ProfileModelStatistics`](kp/value.md#kp.ProfileModelStatistics) + + + * [`QuantizationParameters`](kp/value.md#kp.QuantizationParameters) + + + * [`QuantizationParametersV1`](kp/value.md#kp.QuantizationParametersV1) + + + * [`QuantizedFixedPointDescriptor`](kp/value.md#kp.QuantizedFixedPointDescriptor) + + + * [`Scale`](kp/value.md#kp.Scale) + + + * [`SetupFileSchemaVersion`](kp/value.md#kp.SetupFileSchemaVersion) + + + * [`SetupSchemaVersion`](kp/value.md#kp.SetupSchemaVersion) + + + * [`SingleModelDescriptor`](kp/value.md#kp.SingleModelDescriptor) + + + * [`SystemInfo`](kp/value.md#kp.SystemInfo) + + + * [`TensorDescriptor`](kp/value.md#kp.TensorDescriptor) + + + * [`TensorShapeInfo`](kp/value.md#kp.TensorShapeInfo) + + + * [`TensorShapeInfoV1`](kp/value.md#kp.TensorShapeInfoV1) + + + * [`TensorShapeInfoV2`](kp/value.md#kp.TensorShapeInfoV2) + + +* [kp enum](kp/enum.md) + + + * [`ApiReturnCode`](kp/enum.md#kp.ApiReturnCode) + + + * [`ChannelOrdering`](kp/enum.md#kp.ChannelOrdering) + + + * [`DataType`](kp/enum.md#kp.DataType) + + + * [`FixedPointDType`](kp/enum.md#kp.FixedPointDType) + + + * [`ImageFormat`](kp/enum.md#kp.ImageFormat) + + + * [`ModelTargetChip`](kp/enum.md#kp.ModelTargetChip) + + + * [`ModelTensorDataLayout`](kp/enum.md#kp.ModelTensorDataLayout) + + + * [`ModelTensorShapeInformationVersion`](kp/enum.md#kp.ModelTensorShapeInformationVersion) + + + * [`NormalizeMode`](kp/enum.md#kp.NormalizeMode) + + + * [`PaddingMode`](kp/enum.md#kp.PaddingMode) + + + * [`ProductId`](kp/enum.md#kp.ProductId) + + + * [`QuantizationParametersVersion`](kp/enum.md#kp.QuantizationParametersVersion) + + + * [`ResetMode`](kp/enum.md#kp.ResetMode) + + + * [`ResizeMode`](kp/enum.md#kp.ResizeMode) + + + * [`UsbSpeed`](kp/enum.md#kp.UsbSpeed) + + +* [kp exception](kp/exception.md) + + + * [`ApiKPException`](kp/exception.md#kp.ApiKPException) + + +* [kp.KPConstant](kp/const.md) + + + * [`Const`](kp/const.md#kp.KPConstant.Const) + + +* [kp.v1.inference (Legacy Module)](kp/v1/inference.md) + + + * [`generic_raw_inference_bypass_pre_proc_receive()`](kp/v1/inference.md#kp.v1.inference.generic_raw_inference_bypass_pre_proc_receive) + + + * [`generic_raw_inference_bypass_pre_proc_send()`](kp/v1/inference.md#kp.v1.inference.generic_raw_inference_bypass_pre_proc_send) + + + * [`generic_raw_inference_receive()`](kp/v1/inference.md#kp.v1.inference.generic_raw_inference_receive) + + + * [`generic_raw_inference_send()`](kp/v1/inference.md#kp.v1.inference.generic_raw_inference_send) + + +* [kp.v1 value (Legacy Module)](kp/v1/value.md) + + + * [`GenericRawBypassPreProcImageHeader`](kp/v1/value.md#kp.v1.GenericRawBypassPreProcImageHeader) + + + * [`GenericRawBypassPreProcResult`](kp/v1/value.md#kp.v1.GenericRawBypassPreProcResult) + + + * [`GenericRawBypassPreProcResultHeader`](kp/v1/value.md#kp.v1.GenericRawBypassPreProcResultHeader) + + + * [`GenericRawImageHeader`](kp/v1/value.md#kp.v1.GenericRawImageHeader) + + + * [`GenericRawResult`](kp/v1/value.md#kp.v1.GenericRawResult) + + + * [`GenericRawResultHeader`](kp/v1/value.md#kp.v1.GenericRawResultHeader) + diff --git a/docs/plus_python/api_document/V3.1.2/kp/const.md b/docs/plus_python/api_document/V3.1.2/kp/const.md new file mode 100644 index 0000000..8060284 --- /dev/null +++ b/docs/plus_python/api_document/V3.1.2/kp/const.md @@ -0,0 +1,58 @@ +# kp.KPConstant + + + +--- + +### **class** kp.KPConstant.Const(value) +Kneron PLUS constant value. + + +* **Attributes** + + * **MAX_CROP_BOX** : [`int`](https://docs.python.org/3/library/functions.html#int), default=4 + + Maximum number of crop boxes. + + * **FD_MAX** : [`int`](https://docs.python.org/3/library/functions.html#int), default=10 + + Maximum number of face detection bounding boxes. + + * **LAND_MARK_POINTS** : [`int`](https://docs.python.org/3/library/functions.html#int), default=5 + + Number of land marks points. + + * **FR_FEAT_LENGTH** : [`int`](https://docs.python.org/3/library/functions.html#int), default=256 + + The length of one feature map. + + * **YOLO_GOOD_BOX_MAX** : [`int`](https://docs.python.org/3/library/functions.html#int), default=500 + + Maximum number of bounding boxes for Yolo models. + + * **APP_PADDING_BYTES** : [`int`](https://docs.python.org/3/library/functions.html#int), default=28 + + Reserved padding bytes for C structure. + + * **KP_MAX_INPUT_NODE_COUNT** : [`int`](https://docs.python.org/3/library/functions.html#int), default=100 + + Maximum number of the model input node (Note: The KL520, KL720, KL630 and KL730 only support maximum 5 input number.) + + * **MAX_MODEL_NUM_IN_NEF** : [`int`](https://docs.python.org/3/library/functions.html#int), default=16 + + Maximum number of model in NEF file. + + * **CHANNEL_NUM_RGBA8888** : [`int`](https://docs.python.org/3/library/functions.html#int), default=4 + + channel number of image format KP_IMAGE_FORMAT_RGBA8888. + + * **CHANNEL_NUM_RAW8** : [`int`](https://docs.python.org/3/library/functions.html#int), default=1 + + channel number of image format KP_IMAGE_FORMAT_RAW8. + + * **CHANNEL_NUM_OTHER_FORMAT** : [`int`](https://docs.python.org/3/library/functions.html#int), default=2 + + channel number of other image format (exclude: KP_IMAGE_FORMAT_RGBA8888, KP_IMAGE_FORMAT_RAW8). + + + diff --git a/docs/plus_python/api_document/V3.1.2/kp/core.md b/docs/plus_python/api_document/V3.1.2/kp/core.md new file mode 100644 index 0000000..7d876ec --- /dev/null +++ b/docs/plus_python/api_document/V3.1.2/kp/core.md @@ -0,0 +1,699 @@ +# kp.core + + + +--- + +### kp.core.connect_devices(usb_port_ids) +To connect multiple (including one) Kneron devices. + + +* **Parameters** + + * **usb_port_ids** : `List`[[`int`](https://docs.python.org/3/library/functions.html#int)] + + An list contains device’s port ID which can be known from scan_devices(), if [0] is given then it will + try to connect first connectable device. + + + +* **Returns** + + * **device_group** : [`kp.DeviceGroup`](value.md#kp.DeviceGroup) + + Represents a set of devices handle. + + + +* **Raises** + + * [`kp.ApiKPException`](exception.md#kp.ApiKPException) + + + +* **Return type** + + [`DeviceGroup`](value.md#kp.DeviceGroup) + + + + +--- + +### kp.core.connect_devices_without_check(usb_port_ids) +To connect multiple (including one) Kneron devices without any examinations of system info. + + +* **Parameters** + + * **usb_port_ids** : `List`[[`int`](https://docs.python.org/3/library/functions.html#int)] + + An list contains device’s port ID which can be known from scan_devices(), if [0] is given then it will + try to connect first connectable device. + + + +* **Returns** + + * **device_group** : [`kp.DeviceGroup`](value.md#kp.DeviceGroup) + + Represents a set of devices handle. + + + +* **Raises** + + * [`kp.ApiKPException`](exception.md#kp.ApiKPException) + + + +* **Return type** + + [`DeviceGroup`](value.md#kp.DeviceGroup) + + + + +--- + +### kp.core.disable_firmware_log(device_group) +Disable firmware log of all devices with firmware log enabled. + + +* **Parameters** + + * **device_group** : [`kp.DeviceGroup`](value.md#kp.DeviceGroup) + + A set of devices handle. + + + +* **Raises** + + * [`kp.ApiKPException`](exception.md#kp.ApiKPException) + + + +* **Return type** + + [`None`](https://docs.python.org/3/library/constants.html#None) + + + + +--- + +### kp.core.disconnect_devices(device_group) +To disconnect a Kneron device. + + +* **Parameters** + + * **device_group** : [`kp.DeviceGroup`](value.md#kp.DeviceGroup) + + A set of devices handle. + + + +* **Raises** + + * [`kp.ApiKPException`](exception.md#kp.ApiKPException) + + + +* **Return type** + + [`None`](https://docs.python.org/3/library/constants.html#None) + + + + +--- + +### kp.core.enable_firmware_log(device_group, usb_port_id, log_file_path) +Enable firmware log from certain device. + + +* **Parameters** + + * **device_group** : [`kp.DeviceGroup`](value.md#kp.DeviceGroup) + + A set of devices handle. + + * **usb_port_id** : [`int`](https://docs.python.org/3/library/functions.html#int) + + The device port ID to enable firmware log. + + * **log_file_path** : [`str`](https://docs.python.org/3/library/stdtypes.html#str) + + The log file output path. + + + +* **Raises** + + * [`kp.ApiKPException`](exception.md#kp.ApiKPException) + + + +* **Return type** + + [`None`](https://docs.python.org/3/library/constants.html#None) + + + + +--- + +### kp.core.get_model_info(device_group, usb_port_id) +Get model information (crc, model id, etc.). + + +* **Parameters** + + * **device_group** : [`kp.DeviceGroup`](value.md#kp.DeviceGroup) + + A set of devices handle. + + * **usb_port_id** : [`int`](https://docs.python.org/3/library/functions.html#int) + + Specific device port ID. + + + +* **Returns** + + * **model_nef_descriptor** : [`kp.ModelNefDescriptor`](value.md#kp.ModelNefDescriptor) + + ModelNefDescriptor object for describing the uploaded models. + + + +* **Raises** + + * [`kp.ApiKPException`](exception.md#kp.ApiKPException) + + + +* **Return type** + + [`ModelNefDescriptor`](value.md#kp.ModelNefDescriptor) + + + + +--- + +### kp.core.get_system_info(device_group, usb_port_id) +Get system information (kn number and firmware version). + + +* **Parameters** + + * **device_group** : [`kp.DeviceGroup`](value.md#kp.DeviceGroup) + + A set of devices handle. + + * **usb_port_id** : [`int`](https://docs.python.org/3/library/functions.html#int) + + Specific device port ID. + + + +* **Returns** + + * **system_info** : [`kp.SystemInfo`](value.md#kp.SystemInfo) + + SystemInfo object for describing the system information of specific device. + + + +* **Raises** + + * [`kp.ApiKPException`](exception.md#kp.ApiKPException) + + + +* **Return type** + + [`SystemInfo`](value.md#kp.SystemInfo) + + + + +--- + +### kp.core.get_version() +Get Kneron PLUS version + + +* **Returns** + + * **plus_version_string** : [`str`](https://docs.python.org/3/library/stdtypes.html#str) + + Kneron PLUS version string. + + + +* **Return type** + + [`str`](https://docs.python.org/3/library/stdtypes.html#str) + + + + +--- + +### kp.core.install_driver_for_windows(product_id) +Install device driver on Windows + + +* **Parameters** + + * **product_id** : [`kp.ProductId`](enum.md#kp.ProductId) + + enum for USB PID(Product ID). + + + +* **Raises** + + * [`kp.ApiKPException`](exception.md#kp.ApiKPException) + + + +* **Return type** + + [`None`](https://docs.python.org/3/library/constants.html#None) + + + + +--- + +### kp.core.load_encrypted_models(device_group, nef_buffer_list) +Upload encrypted NEF models data bytes to device through USB. + + +* **Parameters** + + * **device_group** : [`kp.DeviceGroup`](value.md#kp.DeviceGroup) + + A set of devices handle. + + * **nef_buffer_list** : `List`[[`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes)] + + A list of byte buffer that contains the content of encrypted NEF file(s). + + + +* **Returns** + + * **model_nef_descriptor** : [`kp.ModelNefDescriptor`](value.md#kp.ModelNefDescriptor) + + ModelNefDescriptor object for describing the uploaded models. + + + +* **Raises** + + * [`kp.ApiKPException`](exception.md#kp.ApiKPException) + + + +* **Return type** + + [`ModelNefDescriptor`](value.md#kp.ModelNefDescriptor) + + + + +--- + +### kp.core.load_encrypted_models_from_file(device_group, file_path_list) +Upload encrypted NEF Models to device through USB by encrypted NEF file path(s). + + +* **Parameters** + + * **device_group** : [`kp.DeviceGroup`](value.md#kp.DeviceGroup) + + A set of devices handle. + + * **file_path_list** : `List`[[`str`](https://docs.python.org/3/library/stdtypes.html#str)] + + A list of encrypted NEF model file path(s). + + + +* **Returns** + + * **model_nef_descriptor** : [`kp.ModelNefDescriptor`](value.md#kp.ModelNefDescriptor) + + ModelNefDescriptor object for describing the uploaded models. + + + +* **Raises** + + * `ApiKPException` + + + +* **Return type** + + [`ModelNefDescriptor`](value.md#kp.ModelNefDescriptor) + + + + +--- + +### kp.core.load_firmware(device_group, scpu_fw_buffer, ncpu_fw_buffer) +Upload firmware data bytes to device through USB. + + +* **Parameters** + + * **device_group** : [`kp.DeviceGroup`](value.md#kp.DeviceGroup) + + A set of devices handle. + + * **scpu_fw_buffer** : [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes) + + A bytes buffer contains the content of SCPU firmware file. + + * **ncpu_fw_buffer** : [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes) + + A bytes buffer contains the content of NCPU firmware file. + + + +* **Raises** + + * [`kp.ApiKPException`](exception.md#kp.ApiKPException) + + + +* **Return type** + + [`None`](https://docs.python.org/3/library/constants.html#None) + + + + +--- + +### kp.core.load_firmware_from_file(device_group, scpu_fw_path, ncpu_fw_path) +Upload firmware to device through USB by firmware file path. + + +* **Parameters** + + * **device_group** : [`kp.DeviceGroup`](value.md#kp.DeviceGroup) + + A set of devices handle. + + * **scpu_fw_path** : [`str`](https://docs.python.org/3/library/stdtypes.html#str) + + SCPU firmware file path. + + * **ncpu_fw_path** : [`str`](https://docs.python.org/3/library/stdtypes.html#str) + + NCPU firmware file path. + + + +* **Raises** + + * [`kp.ApiKPException`](exception.md#kp.ApiKPException) + + + +* **Return type** + + [`None`](https://docs.python.org/3/library/constants.html#None) + + + + +--- + +### kp.core.load_model(device_group, nef_buffer) +Upload NEF models data bytes to device through USB. + + +* **Parameters** + + * **device_group** : [`kp.DeviceGroup`](value.md#kp.DeviceGroup) + + A set of devices handle. + + * **nef_buffer** : [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes) + + A bytes buffer contains the content of NEF file. + + + +* **Returns** + + * **model_nef_descriptor** : [`kp.ModelNefDescriptor`](value.md#kp.ModelNefDescriptor) + + ModelNefDescriptor object for describing the uploaded models. + + + +* **Raises** + + * [`kp.ApiKPException`](exception.md#kp.ApiKPException) + + + +* **Return type** + + [`ModelNefDescriptor`](value.md#kp.ModelNefDescriptor) + + + + +--- + +### kp.core.load_model_from_file(device_group, file_path) +Upload NEF Model to device through USB by NEF file path. + + +* **Parameters** + + * **device_group** : [`kp.DeviceGroup`](value.md#kp.DeviceGroup) + + A set of devices handle. + + * **file_path** : [`str`](https://docs.python.org/3/library/stdtypes.html#str) + + NEF model file path. + + + +* **Returns** + + * **model_nef_descriptor** : [`kp.ModelNefDescriptor`](value.md#kp.ModelNefDescriptor) + + ModelNefDescriptor object for describing the uploaded models. + + + +* **Raises** + + * `ApiKPException` + + + +* **Return type** + + [`ModelNefDescriptor`](value.md#kp.ModelNefDescriptor) + + + + +--- + +### kp.core.load_model_from_flash(device_group) +Load model from device flash (Please update NEF model in flash by Kneron DFUT). + + +* **Parameters** + + * **device_group** : [`kp.DeviceGroup`](value.md#kp.DeviceGroup) + + A set of devices handle. + + + +* **Returns** + + * **model_nef_descriptor** : [`kp.ModelNefDescriptor`](value.md#kp.ModelNefDescriptor) + + ModelNefDescriptor object for describing the uploaded models. + + + +* **Raises** + + * [`kp.ApiKPException`](exception.md#kp.ApiKPException) + + + +* **Return type** + + [`ModelNefDescriptor`](value.md#kp.ModelNefDescriptor) + + + + +--- + +### kp.core.reset_device(device_group, reset_mode, sleep_secs=0) +Reset the device in hardware mode or software mode. + + +* **Parameters** + + * **device_group** : [`kp.DeviceGroup`](value.md#kp.DeviceGroup) + + A set of devices handle. + + * **reset_mode** : [`kp.ResetMode`](enum.md#kp.ResetMode) + + Refer to ResetMode. + + * **sleep_secs** : [`float`](https://docs.python.org/3/library/functions.html#float) + + Set sleep time in seconds for reboot device. + + + +* **Raises** + + * [`kp.ApiKPException`](exception.md#kp.ApiKPException) + + + +* **Return type** + + [`None`](https://docs.python.org/3/library/constants.html#None) + + + + +--- + +### kp.core.scan_devices() +Scan all Kneron devices and report a list. +This function can get devices connectivity information at runtime. + + +* **Returns** + + * **device_descriptor_list** : [`kp.DeviceDescriptorList`](value.md#kp.DeviceDescriptorList) + + DeviceDescriptorList object, contain information of connected devices from USB perspectives. + + + +* **Return type** + + [`DeviceDescriptorList`](value.md#kp.DeviceDescriptorList) + + + + +--- + +### kp.core.set_npu_timeout(device_group, seconds) +To set a global timeout value for NPU inference timeout. (Please call after the load model function.) (Only support KL730/KL830.) + + +* **Parameters** + + * **device_group** : [`kp.DeviceGroup`](value.md#kp.DeviceGroup) + + A set of devices handle. + + * **seconds** : [`int`](https://docs.python.org/3/library/functions.html#int) + + Pre-set timeout value in seconds. (Set as 0 is wait forever.) + + + +* **Raises** + + * [`kp.ApiKPException`](exception.md#kp.ApiKPException) + + + +* **Return type** + + [`None`](https://docs.python.org/3/library/constants.html#None) + + + + +--- + +### kp.core.set_timeout(device_group, milliseconds) +To set a global timeout value for all USB communications with the device. + + +* **Parameters** + + * **device_group** : [`kp.DeviceGroup`](value.md#kp.DeviceGroup) + + A set of devices handle. + + * **milliseconds** : [`int`](https://docs.python.org/3/library/functions.html#int) + + Pre-set timeout value in milliseconds. + + + +* **Return type** + + [`None`](https://docs.python.org/3/library/constants.html#None) + + + + +--- + +### kp.core.store_ddr_management_attributes(device_group, ddr_manage_attributes) +(Advance) Store DDR memory management attributes into DeviceGroup. + + +* **Parameters** + + * **device_group** : [`kp.DeviceGroup`](value.md#kp.DeviceGroup) + + A set of devices handle. + + * **ddr_manage_attributes** : [`kp.DdrManageAttributes`](value.md#kp.DdrManageAttributes) + + DDR memory management descriptor of Kneron device. + + + +* **Raises** + + * [`kp.ApiKPException`](exception.md#kp.ApiKPException) + + + +* **Return type** + + [`None`](https://docs.python.org/3/library/constants.html#None) + + +* **Notes** +Must reset-reboot device before setting the DDR memory management attributes. +Must issue kp.core.store_ddr_management_attributes before kp.core.load_model()/kp.core.load_model_from_file()/kp.core.load_encrypted_models()/kp.core.load_encrypted_models_from_file()/kp.core.load_model_from_flash + + diff --git a/docs/plus_python/api_document/V3.1.2/kp/enum.md b/docs/plus_python/api_document/V3.1.2/kp/enum.md new file mode 100644 index 0000000..2eb0f69 --- /dev/null +++ b/docs/plus_python/api_document/V3.1.2/kp/enum.md @@ -0,0 +1,788 @@ +# kp enum + + + +--- + +### **class** kp.ApiReturnCode(value) +Return code of PLUS APIs. + + +* **Attributes** + + * **KP_SUCCESS** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + * **KP_ERROR_USB_IO_N1** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-1 + + * **KP_ERROR_USB_INVALID_PARAM_N2** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-2 + + * **KP_ERROR_USB_ACCESS_N3** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-3 + + * **KP_ERROR_USB_NO_DEVICE_N4** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-4 + + * **KP_ERROR_USB_NOT_FOUND_N5** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-5 + + * **KP_ERROR_USB_BUSY_N6** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-6 + + * **KP_ERROR_USB_TIMEOUT_N7** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-7 + + * **KP_ERROR_USB_OVERFLOW_N8** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-8 + + * **KP_ERROR_USB_PIPE_N9** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-9 + + * **KP_ERROR_USB_INTERRUPTED_N10** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-10 + + * **KP_ERROR_USB_NO_MEM_N11** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-11 + + * **KP_ERROR_USB_NOT_SUPPORTED_N12** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-12 + + * **KP_ERROR_USB_OTHER_N99** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-99 + + * **KP_ERROR_WDI_BEGIN** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-200 + + * **KP_ERROR_WDI_IO_N1** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-201 + + * **KP_ERROR_WDI_INVALID_PARAM_N2** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-202 + + * **KP_ERROR_WDI_ACCESS_N3** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-203 + + * **KP_ERROR_WDI_NO_DEVICE_N4** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-204 + + * **KP_ERROR_WDI_NOT_FOUND_N5** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-205 + + * **KP_ERROR_WDI_BUSY_N6** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-206 + + * **KP_ERROR_WDI_TIMEOUT_N7** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-207 + + * **KP_ERROR_WDI_OVERFLOW_N8** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-208 + + * **KP_ERROR_WDI_PENDING_INSTALLATION_N9** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-209 + + * **KP_ERROR_WDI_INTERRUPTED_N10** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-210 + + * **KP_ERROR_WDI_RESOURCE_N11** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-211 + + * **KP_ERROR_WDI_NOT_SUPPORTED_N12** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-212 + + * **KP_ERROR_WDI_EXISTS_N13** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-213 + + * **KP_ERROR_WDI_USER_CANCEL_N14** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-214 + + * **KP_ERROR_WDI_NEEDS_ADMIN_N15** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-215 + + * **KP_ERROR_WDI_WOW64_N16** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-216 + + * **KP_ERROR_WDI_INF_SYNTAX_N17** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-217 + + * **KP_ERROR_WDI_CAT_MISSING_N18** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-218 + + * **KP_ERROR_WDI_UNSIGNED_N19** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-219 + + * **KP_ERROR_WDI_OTHER_N99** : [`int`](https://docs.python.org/3/library/functions.html#int), default=-299 + + * **KP_ERROR_DEVICE_NOT_EXIST_10** : [`int`](https://docs.python.org/3/library/functions.html#int), default=10 + + * **KP_ERROR_DEVICE_INCORRECT_RESPONSE_11** : [`int`](https://docs.python.org/3/library/functions.html#int), default=11 + + * **KP_ERROR_INVALID_PARAM_12** : [`int`](https://docs.python.org/3/library/functions.html#int), default=12 + + * **KP_ERROR_SEND_DESC_FAIL_13** : [`int`](https://docs.python.org/3/library/functions.html#int), default=13 + + * **KP_ERROR_SEND_DATA_FAIL_14** : [`int`](https://docs.python.org/3/library/functions.html#int), default=14 + + * **KP_ERROR_SEND_DATA_TOO_LARGE_15** : [`int`](https://docs.python.org/3/library/functions.html#int), default=15 + + * **KP_ERROR_RECV_DESC_FAIL_16** : [`int`](https://docs.python.org/3/library/functions.html#int), default=16 + + * **KP_ERROR_RECV_DATA_FAIL_17** : [`int`](https://docs.python.org/3/library/functions.html#int), default=17 + + * **KP_ERROR_RECV_DATA_TOO_LARGE_18** : [`int`](https://docs.python.org/3/library/functions.html#int), default=18 + + * **KP_ERROR_FW_UPDATE_FAILED_19** : [`int`](https://docs.python.org/3/library/functions.html#int), default=19 + + * **KP_ERROR_FILE_OPEN_FAILED_20** : [`int`](https://docs.python.org/3/library/functions.html#int), default=20 + + * **KP_ERROR_INVALID_MODEL_21** : [`int`](https://docs.python.org/3/library/functions.html#int), default=21 + + * **KP_ERROR_IMAGE_RESOLUTION_TOO_SMALL_22** : [`int`](https://docs.python.org/3/library/functions.html#int), default=22 + + * **KP_ERROR_IMAGE_ODD_WIDTH_23** : [`int`](https://docs.python.org/3/library/functions.html#int), default=23 + + * **KP_ERROR_INVALID_FIRMWARE_24** : [`int`](https://docs.python.org/3/library/functions.html#int), default=24 + + * **KP_ERROR_RESET_FAILED_25** : [`int`](https://docs.python.org/3/library/functions.html#int), default=25 + + * **KP_ERROR_DEVICES_NUMBER_26** : [`int`](https://docs.python.org/3/library/functions.html#int), default=26 + + * **KP_ERROR_CONFIGURE_DEVICE_27** : [`int`](https://docs.python.org/3/library/functions.html#int), default=27 + + * **KP_ERROR_CONNECT_FAILED_28** : [`int`](https://docs.python.org/3/library/functions.html#int), default=28 + + * **KP_ERROR_DEVICE_GROUP_MIX_PRODUCT_29** : [`int`](https://docs.python.org/3/library/functions.html#int), default=29 + + * **KP_ERROR_RECEIVE_INCORRECT_HEADER_STAMP_30** : [`int`](https://docs.python.org/3/library/functions.html#int), default=30 + + * **KP_ERROR_RECEIVE_SIZE_MISMATCH_31** : [`int`](https://docs.python.org/3/library/functions.html#int), default=31 + + * **KP_ERROR_RECEIVE_JOB_ID_MISMATCH_32** : [`int`](https://docs.python.org/3/library/functions.html#int), default=32 + + * **KP_ERROR_INVALID_CUSTOMIZED_JOB_ID_33** : [`int`](https://docs.python.org/3/library/functions.html#int), default=33 + + * **KP_ERROR_FW_LOAD_FAILED_34** : [`int`](https://docs.python.org/3/library/functions.html#int), default=34 + + * **KP_ERROR_MODEL_NOT_LOADED_35** : [`int`](https://docs.python.org/3/library/functions.html#int), default=35 + + * **KP_ERROR_INVALID_CHECKPOINT_DATA_36** : [`int`](https://docs.python.org/3/library/functions.html#int), default=36 + + * **KP_DBG_CHECKPOINT_END_37** : [`int`](https://docs.python.org/3/library/functions.html#int), default=37 + + * **KP_ERROR_INVALID_HOST_38** : [`int`](https://docs.python.org/3/library/functions.html#int), default=38 + + * **KP_ERROR_MEMORY_FREE_FAILURE_39** : [`int`](https://docs.python.org/3/library/functions.html#int), default=39 + + * **KP_ERROR_USB_BOOT_LOAD_SECOND_MODEL_40** : [`int`](https://docs.python.org/3/library/functions.html#int), default=40 + + * **KP_ERROR_CHECK_FW_VERSION_FAILED_41** : [`int`](https://docs.python.org/3/library/functions.html#int), default=41 + + * **KP_ERROR_FIFOQ_INPUT_BUFF_COUNT_NOT_ENOUGH_42** : [`int`](https://docs.python.org/3/library/functions.html#int), default=42 + + * **KP_ERROR_FIFOQ_SETTING_FAILED_43** : [`int`](https://docs.python.org/3/library/functions.html#int), default=43 + + * **KP_ERROR_UNSUPPORTED_DEVICE_44** : [`int`](https://docs.python.org/3/library/functions.html#int), default=44 + + * **KP_ERROR_IMAGE_INVALID_HEIGHT_45** : [`int`](https://docs.python.org/3/library/functions.html#int), default=45 + + * **KP_ERROR_ADJUST_DDR_HEAP_FAILED_46** : [`int`](https://docs.python.org/3/library/functions.html#int), default=46 + + * **KP_ERROR_DEVICE_NOT_ACCESSIBLE_47** : [`int`](https://docs.python.org/3/library/functions.html#int), default=47 + + * **KP_ERROR_INVALID_INPUT_NODE_DATA_NUMBER_48** : [`int`](https://docs.python.org/3/library/functions.html#int), default=48 + + * **KP_ERROR_OTHER_99** : [`int`](https://docs.python.org/3/library/functions.html#int), default=99 + + * **KP_FW_ERROR_UNKNOWN_APP** : [`int`](https://docs.python.org/3/library/functions.html#int), default=100 + + * **KP_FW_INFERENCE_ERROR_101** : [`int`](https://docs.python.org/3/library/functions.html#int), default=101 + + * **KP_FW_DDR_MALLOC_FAILED_102** : [`int`](https://docs.python.org/3/library/functions.html#int), default=102 + + * **KP_FW_INFERENCE_TIMEOUT_103** : [`int`](https://docs.python.org/3/library/functions.html#int), default=103 + + * **KP_FW_LOAD_MODEL_FAILED_104** : [`int`](https://docs.python.org/3/library/functions.html#int), default=104 + + * **KP_FW_CONFIG_POST_PROC_ERROR_MALLOC_FAILED_105** : [`int`](https://docs.python.org/3/library/functions.html#int), default=105 + + * **KP_FW_CONFIG_POST_PROC_ERROR_NO_SPACE_106** : [`int`](https://docs.python.org/3/library/functions.html#int), default=106 + + * **KP_FW_IMAGE_SIZE_NOT_MATCH_MODEL_INPUT_107** : [`int`](https://docs.python.org/3/library/functions.html#int), default=107 + + * **KP_FW_NOT_SUPPORT_PREPROCESSING_108** : [`int`](https://docs.python.org/3/library/functions.html#int), default=108 + + * **KP_FW_GET_MODEL_INFO_FAILED_109** : [`int`](https://docs.python.org/3/library/functions.html#int), default=109 + + * **KP_FW_WRONG_INPUT_BUFFER_COUNT_110** : [`int`](https://docs.python.org/3/library/functions.html#int), default=110 + + * **KP_FW_INVALID_PRE_PROC_MODEL_INPUT_SIZE_111** : [`int`](https://docs.python.org/3/library/functions.html#int), default=111 + + * **KP_FW_INVALID_INPUT_CROP_PARAM_112** : [`int`](https://docs.python.org/3/library/functions.html#int), default=112 + + * **KP_FW_ERROR_FILE_OPEN_FAILED_113** : [`int`](https://docs.python.org/3/library/functions.html#int), default=113 + + * **KP_FW_ERROR_FILE_STATE_FAILED_114** : [`int`](https://docs.python.org/3/library/functions.html#int), default=114 + + * **KP_FW_ERROR_FILE_READ_FAILED_115** : [`int`](https://docs.python.org/3/library/functions.html#int), default=115 + + * **KP_FW_ERROR_FILE_WRITE_FAILED_116** : [`int`](https://docs.python.org/3/library/functions.html#int), default=116 + + * **KP_FW_ERROR_FILE_CHMOD_FAILED_117** : [`int`](https://docs.python.org/3/library/functions.html#int), default=117 + + * **KP_FW_ERROR_FILE_FAILED_OTHER_118** : [`int`](https://docs.python.org/3/library/functions.html#int), default=118 + + * **KP_FW_ERROR_INVALID_BOOT_CONFIG_119** : [`int`](https://docs.python.org/3/library/functions.html#int), default=119 + + * **KP_FW_ERROR_LOADER_ERROR_120** : [`int`](https://docs.python.org/3/library/functions.html#int), default=120 + + * **KP_FW_ERROR_POSIX_SPAWN_FAILED_121** : [`int`](https://docs.python.org/3/library/functions.html#int), default=121 + + * **KP_FW_ERROR_USB_SEND_FAILED_122** : [`int`](https://docs.python.org/3/library/functions.html#int), default=122 + + * **KP_FW_ERROR_USB_RECEIVE_FAILED_123** : [`int`](https://docs.python.org/3/library/functions.html#int), default=123 + + * **KP_FW_ERROR_HANDLE_NOT_READY_124** : [`int`](https://docs.python.org/3/library/functions.html#int), default=124 + + * **KP_FW_FIFOQ_ACCESS_FAILED_125** : [`int`](https://docs.python.org/3/library/functions.html#int), default=125 + + * **KP_FW_FIFOQ_NOT_READY_126** : [`int`](https://docs.python.org/3/library/functions.html#int), default=126 + + * **KP_FW_ERROR_FILE_SEEK_FAILED_127** : [`int`](https://docs.python.org/3/library/functions.html#int), default=127 + + * **KP_FW_ERROR_FILE_FLUSH_FAILED_128** : [`int`](https://docs.python.org/3/library/functions.html#int), default=128 + + * **KP_FW_ERROR_FILE_SYNC_FAILED_129** : [`int`](https://docs.python.org/3/library/functions.html#int), default=129 + + * **KP_FW_ERROR_FILE_CLOSE_FAILED_130** : [`int`](https://docs.python.org/3/library/functions.html#int), default=130 + + * **KP_FW_ERROR_MODEL_EXIST_CPU_NODE_131** : [`int`](https://docs.python.org/3/library/functions.html#int), default=131 + + * **KP_FW_ERROR_MODEL_EXIST_CONST_INPUT_NODE_132** : [`int`](https://docs.python.org/3/library/functions.html#int), default=132 + + * **KP_FW_ERROR_GET_MSG_QUEUE_FAILED_133** : [`int`](https://docs.python.org/3/library/functions.html#int), default=133 + + * **KP_FW_ERROR_SEND_MSG_QUEUE_FAILED_134** : [`int`](https://docs.python.org/3/library/functions.html#int), default=134 + + * **KP_FW_ERROR_RECV_MSG_QUEUE_FAILED_135** : [`int`](https://docs.python.org/3/library/functions.html#int), default=135 + + * **KP_FW_ERROR_UNSUPPORT_TOOLCHAIN_VERSION_136** : [`int`](https://docs.python.org/3/library/functions.html#int), default=136 + + * **KP_FW_ERROR_SET_IE_TIMEOUT_FAIL_137** : [`int`](https://docs.python.org/3/library/functions.html#int), default=137 + + * **KP_FW_ERROR_SET_NPU_TIMEOUT_FAIL_138** : [`int`](https://docs.python.org/3/library/functions.html#int), default=138 + + * **KP_FW_NCPU_ERR_BEGIN** : [`int`](https://docs.python.org/3/library/functions.html#int), default=200 + + * **KP_FW_NCPU_INVALID_IMAGE_201** : [`int`](https://docs.python.org/3/library/functions.html#int), default=201 + + * **KP_FW_NCPU_INPROC_FAILED_202** : [`int`](https://docs.python.org/3/library/functions.html#int), default=202 + + * **KP_FW_NCPU_CPU_OP_NOT_FOUND_203** : [`int`](https://docs.python.org/3/library/functions.html#int), default=203 + + * **KP_FW_NCPU_MYSTERY_OP_NOT_FOUND_204** : [`int`](https://docs.python.org/3/library/functions.html#int), default=204 + + * **KP_FW_EFUSE_CAN_NOT_BURN_300** : [`int`](https://docs.python.org/3/library/functions.html#int), default=300 + + * **KP_FW_EFUSE_PROTECTED_301** : [`int`](https://docs.python.org/3/library/functions.html#int), default=301 + + * **KP_FW_EFUSE_OTHER_302** : [`int`](https://docs.python.org/3/library/functions.html#int), default=302 + + * **KP_FW_APP_MASK_FDFR_ENROLL_WITH_MASKED_FACE_10000** : [`int`](https://docs.python.org/3/library/functions.html#int), default=10000 + + * **KP_FW_APP_SEG_INSUFFICIENT_RESULT_BUFFER_SIZE_10001** : [`int`](https://docs.python.org/3/library/functions.html#int), default=10001 + + + + +--- + +### **class** kp.ChannelOrdering(value) +enum for feature map channels ordering. + + +* **Attributes** + + * **KP_CHANNEL_ORDERING_HCW** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + KL520 default, height/channel/width in order + + * **KP_CHANNEL_ORDERING_CHW** : [`int`](https://docs.python.org/3/library/functions.html#int), default=1 + + KL720 default, channel/height/width in order + + * **KP_CHANNEL_ORDERING_HWC** : [`int`](https://docs.python.org/3/library/functions.html#int), default=2 + + TensorFlow style, height/width/channel in order + + * **KP_CHANNEL_ORDERING_DEFAULT** : [`int`](https://docs.python.org/3/library/functions.html#int), default=3 + + KL520, KL630, KL720 use their default, others use onnx shape order + + + + +--- + +### **class** kp.DataType(value) +enum for Kneron data type. + + +* **Attributes** + + * **KP_DTYPE_UNKNOWN** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + Unknown data type. + + * **KP_DTYPE_INT8** : [`int`](https://docs.python.org/3/library/functions.html#int), default=1 + + Represent one scalar value by int8_t data type. + + * **KP_DTYPE_INT16** : [`int`](https://docs.python.org/3/library/functions.html#int), default=2 + + Represent one scalar value by int16_t data type. + + * **KP_DTYPE_INT32** : [`int`](https://docs.python.org/3/library/functions.html#int), default=3 + + Represent one scalar value by int32_t data type. + + * **KP_DTYPE_INT64** : [`int`](https://docs.python.org/3/library/functions.html#int), default=4 + + Represent one scalar value by int64_t data type. + + * **KP_DTYPE_UINT8** : [`int`](https://docs.python.org/3/library/functions.html#int), default=5 + + Represent one scalar value by uint8_t data type. + + * **KP_DTYPE_UINT16** : [`int`](https://docs.python.org/3/library/functions.html#int), default=6 + + Represent one scalar value by uint16_t data type. + + * **KP_DTYPE_UINT32** : [`int`](https://docs.python.org/3/library/functions.html#int), default=7 + + Represent one scalar value by uint32_t data type. + + * **KP_DTYPE_UINT64** : [`int`](https://docs.python.org/3/library/functions.html#int), default=8 + + Represent one scalar value by uint64_t data type. + + * **KP_DTYPE_FLOAT32** : [`int`](https://docs.python.org/3/library/functions.html#int), default=9 + + Represent one scalar value by float32 data type. + + * **KP_DTYPE_BFLOAT16** : [`int`](https://docs.python.org/3/library/functions.html#int), default=10 + + Represent one scalar value by bfloat16 data type (store in uint16_t 2 bytes). + + * **KP_DTYPE_DOUBLE64** : [`int`](https://docs.python.org/3/library/functions.html#int), default=11 + + Represent one scalar value by double64 data type. + + + + +--- + +### **class** kp.FixedPointDType(value) +enum for fixed-point data type. + + +* **Attributes** + + * **KP_FIXED_POINT_DTYPE_UNKNOWN** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + Unknown data type. + + * **KP_FIXED_POINT_DTYPE_INT8** : [`int`](https://docs.python.org/3/library/functions.html#int), default=1 + + Represent one fixed-point value by 8-bit data type. + + * **KP_FIXED_POINT_DTYPE_INT16** : [`int`](https://docs.python.org/3/library/functions.html#int), default=2 + + Represent one fixed-point value by 16-bit data type. + + + + +--- + +### **class** kp.ImageFormat(value) +enum for image format supported for inference. + + +* **Attributes** + + * **KP_IMAGE_FORMAT_UNKNOWN** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x0 + + Unknown format. + + * **KP_IMAGE_FORMAT_RGB565** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x60 + + RGB565 16bits (order: BGR). + + * **KP_IMAGE_FORMAT_RGBA8888** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x0D + + RGBA8888 32bits. + + * **KP_IMAGE_FORMAT_YUYV** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x2F + + YUYV 16bits. + + * **KP_IMAGE_FORMAT_YCBCR422_CRY1CBY0** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x30 + + YCbCr422 16bit (order: CrY1CbY0). + + * **KP_IMAGE_FORMAT_YCBCR422_CBY1CRY0** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x31 + + YCbCr422 16bit (order: CbY1CrY0). + + * **KP_IMAGE_FORMAT_YCBCR422_Y1CRY0CB** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x32 + + YCbCr422 16bit (order: Y1CrY0Cb). + + * **KP_IMAGE_FORMAT_YCBCR422_Y1CBY0CR** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x33 + + YCbCr422 16bit (order: Y1CbY0Cr). + + * **KP_IMAGE_FORMAT_YCBCR422_CRY0CBY1** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x34 + + YCbCr422 16bit (order: CrY0CbY1). + + * **KP_IMAGE_FORMAT_YCBCR422_CBY0CRY1** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x35 + + YCbCr422 16bit (order: CbY0CrY1). + + * **KP_IMAGE_FORMAT_YCBCR422_Y0CRY1CB** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x36 + + YCbCr422 16bit (order: Y0CrY1Cb). + + * **KP_IMAGE_FORMAT_YCBCR422_Y0CBY1CR** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x37 + + YCbCr422 16bit (order: Y0CbY1Cr). + + * **KP_IMAGE_FORMAT_RAW8** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x20 + + RAW 8bits (Grayscale). + + * **KP_IMAGE_FORMAT_YUV420** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x70 + + YUV420 12bits (planar) + + + + +--- + +### **class** kp.ModelTargetChip(value) +enum for model target chip. + + +* **Attributes** + + * **KP_MODEL_TARGET_CHIP_UNKNOWN** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + Model for unknown chip. + + * **KP_MODEL_TARGET_CHIP_KL520** : [`int`](https://docs.python.org/3/library/functions.html#int), default=1 + + Model for KL520. + + * **KP_MODEL_TARGET_CHIP_KL720** : [`int`](https://docs.python.org/3/library/functions.html#int), default=2 + + Model for KL720. + + * **KP_MODEL_TARGET_CHIP_KL530** : [`int`](https://docs.python.org/3/library/functions.html#int), default=3 + + Model for KL530. + + * **KP_MODEL_TARGET_CHIP_KL730** : [`int`](https://docs.python.org/3/library/functions.html#int), default=4 + + Model for KL730. + + * **KP_MODEL_TARGET_CHIP_KL630** : [`int`](https://docs.python.org/3/library/functions.html#int), default=5 + + Model for KL630. + + * **KP_MODEL_TARGET_CHIP_KL540** : [`int`](https://docs.python.org/3/library/functions.html#int), default=6 + + Model for KL540. + + + + +--- + +### **class** kp.ModelTensorDataLayout(value) +enum for npu raw data layout format for tensors. + + +* **Attributes** + + * **KP_MODEL_TENSOR_DATA_LAYOUT_UNKNOWN** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + Unknown NPU data layout. + + * **KP_MODEL_TENSOR_DATA_LAYOUT_4W4C8B** : [`int`](https://docs.python.org/3/library/functions.html#int), default=1 + + Layout - width: 4 scalars, channel: 4 scalars, depth: 8 bits. + + * **KP_MODEL_TENSOR_DATA_LAYOUT_1W16C8B** : [`int`](https://docs.python.org/3/library/functions.html#int), default=2 + + Layout - width: 1 scalars, channel: 16 scalars, depth: 8 bits. + + * **KP_MODEL_TENSOR_DATA_LAYOUT_16W1C8B** : [`int`](https://docs.python.org/3/library/functions.html#int), default=3 + + Layout - width: 16 scalars, channel: 1 scalars, depth: 8 bits. + + * **KP_MODEL_TENSOR_DATA_LAYOUT_8W1C16B** : [`int`](https://docs.python.org/3/library/functions.html#int), default=4 + + Layout - width: 8 scalars, channel: 1 scalars, depth: 16 bits. + + * **KP_MODEL_TENSOR_DATA_LAYOUT_4W4C8BHL** : [`int`](https://docs.python.org/3/library/functions.html#int), default=5 + + Layout - width: 4 scalars, channel: 4 scalars, depth: 16 bits, and store scalar into 2 entries with “High 8-bit” and “Low 8-bit”. + + * **KP_MODEL_TENSOR_DATA_LAYOUT_1W16C8BHL** : [`int`](https://docs.python.org/3/library/functions.html#int), default=6 + + Layout - width: 1 scalars, channel: 16 scalars, depth: 16 bits, and store scalar into 2 entries with “High 8-bit” and “Low 8-bit”. + + * **KP_MODEL_TENSOR_DATA_LAYOUT_16W1C8BHL** : [`int`](https://docs.python.org/3/library/functions.html#int), default=7 + + Layout - width: 16 scalars, channel: 1 scalars, depth: 16 bits, and store scalar into 2 entries with “High 8-bit” and “Low 8-bit”. + + * **KP_MODEL_TENSOR_DATA_LAYOUT_RAW_8B** : [`int`](https://docs.python.org/3/library/functions.html#int), default=8 + + Layout - packed int8_t data, depth: 8 bits. + + * **KP_MODEL_TENSOR_DATA_LAYOUT_RAW_16B** : [`int`](https://docs.python.org/3/library/functions.html#int), default=9 + + Layout - packed int16_t data, depth: 16 bits. + + * **KP_MODEL_TENSOR_DATA_LAYOUT_RAW_FLOAT** : [`int`](https://docs.python.org/3/library/functions.html#int), default=10 + + Layout - packed float data, depth: 32 bits. + + * **KP_MODEL_TENSOR_DATA_LAYOUT_1W16C8B_CH_COMPACT** : [`int`](https://docs.python.org/3/library/functions.html#int), default=11 + + Layout - width: 1 scalars, channel: 16 scalars, depth: 8 bits (channel compact mode). + + * **KP_MODEL_TENSOR_DATA_LAYOUT_1W16C8BHL_CH_COMPACT** : [`int`](https://docs.python.org/3/library/functions.html#int), default=12 + + Layout - width: 1 scalars, channel: 16 scalars, depth: 16 bits, and store scalar into 2 entries with “High 8-bit” and “Low 8-bit” (channel compact mode). + + * **KP_MODEL_TENSOR_DATA_LAYOUT_HW4C8B_KEEP_A** : [`int`](https://docs.python.org/3/library/functions.html#int), default=13 + + Layout - packed int8_t data, channel: 4 scalars, depth: 8 bits (NPU keeping alpha channel data in vision model, e.g. model input shape is 1x4xHxW). + + * **KP_MODEL_TENSOR_DATA_LAYOUT_HW4C8B_DROP_A** : [`int`](https://docs.python.org/3/library/functions.html#int), default=14 + + Layout - packed int8_t data, channel: 4 scalars, depth: 8 bits (NPU ignore alpha channel data in vision model, e.g. model input shape is 1x3xHxW). + + * **KP_MODEL_TENSOR_DATA_LAYOUT_HW1C8B** : [`int`](https://docs.python.org/3/library/functions.html#int), default=15 + + Layout - packed int8_t data, channel: 1 scalars, depth: 8 bits. + + * **KP_MODEL_TENSOR_DATA_LAYOUT_HW1C16B_LE** : [`int`](https://docs.python.org/3/library/functions.html#int), default=16 + + Layout - packed int16_t data, channel: 1 scalars, depth: 16 bits (16-bit data arranged in little-endian order). + + * **KP_MODEL_TENSOR_DATA_LAYOUT_HW1C16B_BE** : [`int`](https://docs.python.org/3/library/functions.html#int), default=17 + + Layout - packed int16_t data, channel: 1 scalars, depth: 16 bits (16-bit data arranged in big-endian order). + + + + +--- + +### **class** kp.ModelTensorShapeInformationVersion(value) +enum for tensor shape information version. + + +* **Attributes** + + * **KP_MODEL_TENSOR_SHAPE_INFO_VERSION_UNKNOWN** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + Unknow version. + + * **KP_MODEL_TENSOR_SHAPE_INFO_VERSION_1** : [`int`](https://docs.python.org/3/library/functions.html#int), default=1 + + Version 1 - for KL520, KL720 and KL630. + + * **KP_MODEL_TENSOR_SHAPE_INFO_VERSION_2** : [`int`](https://docs.python.org/3/library/functions.html#int), default=2 + + Version 2 - for KL730. + + + + +--- + +### **class** kp.NormalizeMode(value) +enum for normalization mode. + + +* **Attributes** + + * **KP_NORMALIZE_DISABLE** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0xFF + + Disable normalize. + + * **KP_NORMALIZE_KNERON** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x1 + + RGB/256 - 0.5, refer to the toolchain manual. + + * **KP_NORMALIZE_TENSOR_FLOW** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x2 + + RGB/127.5 - 1.0, refer to the toolchain manual. + + * **KP_NORMALIZE_YOLO** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x3 + + RGB/255.0, refer to the toolchain manual. + + * **KP_NORMALIZE_CUSTOMIZED_DEFAULT** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x4 + + Customized, default, refer to the toolchain manual. + + * **KP_NORMALIZE_CUSTOMIZED_SUB128** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x5 + + Customized, subtract 128, refer to the toolchain manual. + + * **KP_NORMALIZE_CUSTOMIZED_DIV2** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x6 + + Customized, divide by 2, refer to the toolchain manual. + + * **KP_NORMALIZE_CUSTOMIZED_SUB128_DIV2** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x7 + + Customized, subtract 128 and divide by 2, refer to the toolchain manual. + + + + +--- + +### **class** kp.PaddingMode(value) +enum for padding mode. + + +* **Attributes** + + * **KP_PADDING_DISABLE** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x1 + + Disable padding in pre-process. + + * **KP_PADDING_CORNER** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x2 + + Enable corner padding (padding right and bottom) in pre-process. + + * **KP_PADDING_SYMMETRIC** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x3 + + Enable symmetric padding (padding right, left, top and bottom) in pre-process. + + + + +--- + +### **class** kp.ProductId(value) +enum for USB PID(Product ID). + + +* **Attributes** + + * **KP_DEVICE_KL520** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x100 + + Product ID of KL520. + + * **KP_DEVICE_KL720** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x720 + + Product ID of KL720. + + * **KP_DEVICE_KL720_LEGACY** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x200 + + Legacy Product ID of KL720. + + * **KP_DEVICE_KL530** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x530 + + Product ID of KL530. + + * **KP_DEVICE_KL830** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x832 + + Product ID of KL830. + + * **KP_DEVICE_KL730** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x732 + + Product ID of KL730. + + * **KP_DEVICE_KL630** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x630 + + Product ID of KL630. + + * **KP_DEVICE_KL540** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x540 + + Product ID of KL540. + + + + +--- + +### **class** kp.QuantizationParametersVersion(value) +enum for tensor quantization information version. + + +* **Attributes** + + * **KP_MODEL_QUANTIZATION_PARAMS_VERSION_UNKNOWN** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + Unknow version. + + * **KP_MODEL_QUANTIZATION_PARAMS_VERSION_1** : [`int`](https://docs.python.org/3/library/functions.html#int), default=1 + + Version 1 - for KL520, KL720, KL630 and KL730. + + + + +--- + +### **class** kp.ResetMode(value) +enum for reset mode. + + +* **Attributes** + + * **KP_RESET_REBOOT** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + Higheset level to reset Kneron device. Kneron device would disconnect after this reset. + + * **KP_RESET_INFERENCE** : [`int`](https://docs.python.org/3/library/functions.html#int), default=1 + + Soft reset - reset inference FIFO queue. + + * **KP_RESET_SHUTDOWN** : [`int`](https://docs.python.org/3/library/functions.html#int), default=2 + + Shut down Kneron device. For KL520, only useful if HW circuit supports (ex. 96 bord), dongle is not supported. For KL720, this function is not supported. + + * **KP_RESET_REBOOT_SYSTEM** : [`int`](https://docs.python.org/3/library/functions.html#int), default=3 + + Reboot entire system (Only support embedding linux system). + + + + +--- + +### **class** kp.ResizeMode(value) +enum for resize mode. + + +* **Attributes** + + * **KP_RESIZE_DISABLE** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x1 + + Disable resize in pre-process. + + * **KP_RESIZE_ENABLE** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0x2 + + Enable resize in pre-process. + + + + +--- + +### **class** kp.UsbSpeed(value) +enum for USB speed mode. + + +* **Attributes** + + * **KP_USB_SPEED_UNKNOWN** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + unknown speed. + + * **KP_USB_SPEED_LOW** : [`int`](https://docs.python.org/3/library/functions.html#int), default=1 + + Low speed. + + * **KP_USB_SPEED_FULL** : [`int`](https://docs.python.org/3/library/functions.html#int), default=2 + + Full speed. + + * **KP_USB_SPEED_HIGH** : [`int`](https://docs.python.org/3/library/functions.html#int), default=3 + + High speed. + + * **KP_USB_SPEED_SUPER** : [`int`](https://docs.python.org/3/library/functions.html#int), default=4 + + Super speed. + + + diff --git a/docs/plus_python/api_document/V3.1.2/kp/exception.md b/docs/plus_python/api_document/V3.1.2/kp/exception.md new file mode 100644 index 0000000..0119527 --- /dev/null +++ b/docs/plus_python/api_document/V3.1.2/kp/exception.md @@ -0,0 +1,16 @@ +# kp exception + + + +--- + +### **exception** kp.ApiKPException(api_return_code, function_name, result=None) +This class represents an Exception thrown when a KneronPLUS API returns error code. + + + +#### with_traceback() +Exception.with_traceback(tb) – +set self.__traceback__ to tb and return self. + + diff --git a/docs/plus_python/api_document/V3.1.2/kp/inference.md b/docs/plus_python/api_document/V3.1.2/kp/inference.md new file mode 100644 index 0000000..7af7f18 --- /dev/null +++ b/docs/plus_python/api_document/V3.1.2/kp/inference.md @@ -0,0 +1,345 @@ +# kp.inference + + + +--- + +### kp.inference.generic_data_inference_receive(device_group) +Generic raw data inference multiple input receive. +When multiple input data inference is done, this function can be used to get the results in RAW format. +Note that data received is in Kneron RAW format, users need +kp.inference.generic_inference_retrieve_float_node()/kp.inference.generic_inference_retrieve_fixed_node() to +convert RAW format data to floating-point/fixed-point data. + + +* **Parameters** + + * **device_group** : [`kp.DeviceGroup`](value.md#kp.DeviceGroup) + + Represents a set of devices handle. + + + +* **Returns** + + * **generic_data_inference_result** : [`kp.GenericDataInferenceResult`](value.md#kp.GenericDataInferenceResult) + + GenericDataInferenceResult object contained the received RAW data results. + + + +* **Raises** + + * [`kp.ApiKPException`](exception.md#kp.ApiKPException) + + + +* **Return type** + + [`GenericDataInferenceResult`](value.md#kp.GenericDataInferenceResult) + + +* **Notes** +The data received is in Kneron RAW format, users need +kp.inference.generic_inference_retrieve_float_node()/kp.inference.generic_inference_retrieve_fixed_node() to +convert RAW format data to floating-point/fixed-point data. + + + +--- + +### kp.inference.generic_data_inference_send(device_group, generic_inference_input_descriptor) +Generic raw data inference multiple input send. +This is to perform a multiple input data inference, it is non-blocking if device buffer queue is not full. +When this is performed, user can issue +kp.inference.generic_data_inference_receive() to get the result. +In addition, to have better performance, users can issue multiple +kp.inference.generic_data_inference_send() then start to receive results through +kp.inference.generic_data_inference_receive(). + + +* **Parameters** + + * **device_group** : [`kp.DeviceGroup`](value.md#kp.DeviceGroup) + + Represents a set of devices handle. + + * **generic_inference_input_descriptor** : [`kp.GenericDataInferenceDescriptor`](value.md#kp.GenericDataInferenceDescriptor) + + Needed parameters for performing multiple data inference including image buffers, image buffers size, model ID … etc. + + + +* **Raises** + + * [`kp.ApiKPException`](exception.md#kp.ApiKPException) + + + +* **Return type** + + [`None`](https://docs.python.org/3/library/constants.html#None) + + + + +--- + +### kp.inference.generic_image_inference_receive(device_group) +Generic image inference multiple input receive. +When multiple input image inference is done, this function can be used to get the results in RAW format. +Note that the data received is in Kneron RAW format, users need +kp.inference.generic_inference_retrieve_float_node()/kp.inference.generic_inference_retrieve_fixed_node() to +convert RAW format data to floating-point/fixed-point data. + + +* **Parameters** + + * **device_group** : [`kp.DeviceGroup`](value.md#kp.DeviceGroup) + + Represents a set of devices handle. + + + +* **Returns** + + * **generic_image_inference_result** : [`kp.GenericImageInferenceResult`](value.md#kp.GenericImageInferenceResult) + + GenericImageInferenceResult object contained the received RAW data results. + + + +* **Raises** + + * [`kp.ApiKPException`](exception.md#kp.ApiKPException) + + + +* **Return type** + + [`GenericImageInferenceResult`](value.md#kp.GenericImageInferenceResult) + + +* **Notes** +The data received is in Kneron RAW format, users need +kp.inference.generic_inference_retrieve_float_node()/kp.inference.generic_inference_retrieve_fixed_node() to +convert RAW format data to floating-point/fixed-point data. + + + +--- + +### kp.inference.generic_image_inference_send(device_group, generic_inference_input_descriptor) +Generic image inference multiple input send. +This is to perform multiple input image inference, it is non-blocking if device buffer queue is not full. +When this is performed, user can issue kp.inference.generic_image_inference_receive() to get the +result. In addition, to have better performance, users can issue multiple +kp.inference.generic_image_inference_send() then start to receive results through +kp.inference.generic_image_inference_receive(). + + +* **Parameters** + + * **device_group** : [`kp.DeviceGroup`](value.md#kp.DeviceGroup) + + Represents a set of devices handle. + + * **generic_inference_input_descriptor** : [`kp.GenericImageInferenceDescriptor`](value.md#kp.GenericImageInferenceDescriptor) + + Needed parameters for performing image inference including model ID, images width, height ..etc. + + + +* **Raises** + + * [`kp.ApiKPException`](exception.md#kp.ApiKPException) + + + +* **Return type** + + [`None`](https://docs.python.org/3/library/constants.html#None) + + + + +--- + +### kp.inference.generic_inference_retrieve_fixed_node(node_idx, generic_raw_result, channels_ordering) +Retrieve single node output fixed-point data from GenericRawResult/GenericRawBypassPreProcResult/GenericImageInferenceResult/GenericDataInferenceResult object. + + +* **Parameters** + + * **node_idx** : [`int`](https://docs.python.org/3/library/functions.html#int) + + Wanted output node index, starts from 0. Number of total output nodes can be known + from ‘GenericRawResult.header.num_output_node’ + + * **generic_raw_result** : [`kp.v1.GenericRawResult`](v1/value.md#kp.v1.GenericRawResult), [`kp.v1.GenericRawBypassPreProcResult`](v1/value.md#kp.v1.GenericRawBypassPreProcResult), [`kp.GenericImageInferenceResult`](value.md#kp.GenericImageInferenceResult), [`kp.GenericDataInferenceResult`](value.md#kp.GenericDataInferenceResult) + + GenericRawResult/GenericRawBypassPreProcResult/GenericImageInferenceResult/GenericDataInferenceResult object contained the received RAW data results, it should + come from ‘kp.v1.inference.generic_raw_inference_receive()’/’kp.v1.inference.generic_raw_inference_bypass_pre_proc_receive()’/’kp.inference.generic_image_inference_receive()’/’kp.inference.generic_data_inference_receive()’ + + * **channels_ordering** : [`kp.ChannelOrdering`](enum.md#kp.ChannelOrdering) + + The raw output feature map channel ordering. + + + +* **Returns** + + * **inference_fixed_node_output** : [`kp.InferenceFixedNodeOutput`](value.md#kp.InferenceFixedNodeOutput) + + Raw node output in fixed-point format. + + + +* **Return type** + + [`InferenceFixedNodeOutput`](value.md#kp.InferenceFixedNodeOutput) + + + + +--- + +### kp.inference.generic_inference_retrieve_float_node(node_idx, generic_raw_result, channels_ordering) +Retrieve single node output floating-point data from GenericRawResult/GenericRawBypassPreProcResult/GenericImageInferenceResult/GenericDataInferenceResult object. + + +* **Parameters** + + * **node_idx** : [`int`](https://docs.python.org/3/library/functions.html#int) + + Wanted output node index, starts from 0. Number of total output nodes can be known + from ‘GenericRawResult.header.num_output_node’ + + * **generic_raw_result** : [`kp.v1.GenericRawResult`](v1/value.md#kp.v1.GenericRawResult), [`kp.v1.GenericRawBypassPreProcResult`](v1/value.md#kp.v1.GenericRawBypassPreProcResult), [`kp.GenericImageInferenceResult`](value.md#kp.GenericImageInferenceResult), [`kp.GenericDataInferenceResult`](value.md#kp.GenericDataInferenceResult) + + GenericRawResult/GenericRawBypassPreProcResult/GenericImageInferenceResult/GenericDataInferenceResult object contained the received RAW data results, it should + come from ‘kp.v1.inference.generic_raw_inference_receive()’/’kp.v1.inference.generic_raw_inference_bypass_pre_proc_receive()’/’kp.inference.generic_image_inference_receive()’/’kp.inference.generic_data_inference_receive()’ + + * **channels_ordering** : [`kp.ChannelOrdering`](enum.md#kp.ChannelOrdering) + + The raw output feature map channel ordering. + + + +* **Returns** + + * **inference_float_node_output** : [`kp.InferenceFloatNodeOutput`](value.md#kp.InferenceFloatNodeOutput) + + Raw node output in floating-point format. + + + +* **Return type** + + [`InferenceFloatNodeOutput`](value.md#kp.InferenceFloatNodeOutput) + + + + +--- + +### kp.inference.profile_get_statistics(device_group) +Collect inference profile results. + + +* **Parameters** + + * **device_group** : [`kp.DeviceGroup`](value.md#kp.DeviceGroup) + + Represents a set of devices handle. + + + +* **Raises** + + * [`kp.ApiKPException`](exception.md#kp.ApiKPException) + + + +* **Return type** + + [`ProfileData`](value.md#kp.ProfileData) + + +* **Notes** +Please using following steps to profile the model inference performance: +1. Enable feature by kp.inference.profile_set_enable() +2. Run inference +3. Collect the statistic result by kp.inference.profile_get_statistics() +4. Disable feature by kp.inference.profile_set_enable() + + + +--- + +### kp.inference.profile_set_enable(device_group, enable) +To set enable/disable model profile. + + +* **Parameters** + + * **device_group** : [`kp.DeviceGroup`](value.md#kp.DeviceGroup) + + Represents a set of devices handle. + + * **enable** : [bool](https://docs.python.org/3/library/stdtypes.html#bltin-boolean-values) + + Set enable/disable. + + + +* **Raises** + + * [`kp.ApiKPException`](exception.md#kp.ApiKPException) + + + +* **Return type** + + [`None`](https://docs.python.org/3/library/constants.html#None) + + +* **Notes** +Please using following steps to profile the model inference performance: +1. Enable feature by kp.inference.profile_set_enable() +2. Run inference +3. Collect the statistic result by kp.inference.profile_get_statistics() +4. Disable feature by kp.inference.profile_set_enable() + + + +--- + +### kp.inference.set_inference_configuration(device_group, inference_configuration) +Configure inference settings. + + +* **Parameters** + + * **device_group** : [`kp.DeviceGroup`](value.md#kp.DeviceGroup) + + Represents a set of devices handle. + + * **inference_configuration** : [`kp.InferenceConfiguration`](value.md#kp.InferenceConfiguration) + + Inference configurations. + + + +* **Raises** + + * [`kp.ApiKPException`](exception.md#kp.ApiKPException) + + + +* **Return type** + + [`None`](https://docs.python.org/3/library/constants.html#None) + + + diff --git a/docs/plus_python/api_document/V3.1.2/kp/v1/inference.md b/docs/plus_python/api_document/V3.1.2/kp/v1/inference.md new file mode 100644 index 0000000..650b5db --- /dev/null +++ b/docs/plus_python/api_document/V3.1.2/kp/v1/inference.md @@ -0,0 +1,189 @@ +# kp.v1.inference (Legacy Module) + + + +--- + +### kp.v1.inference.generic_raw_inference_bypass_pre_proc_receive(device_group, generic_raw_image_header, model_nef_descriptor) +Generic raw inference bypass pre-processing receive. +When an image inference is done, this function can be used to get the results in RAW format. +Note that data received is in Kneron RAW format, users need +kp.inference.generic_inference_retrieve_float_node()/kp.inference.generic_inference_retrieve_fixed_node() to +convert RAW format data to floating-point/fixed-point data. + + +* **Parameters** + + * **device_group** : [`kp.DeviceGroup`](../value.md#kp.DeviceGroup) + + Represents a set of devices handle. + + * **generic_raw_image_header** : [`kp.v1.GenericRawBypassPreProcImageHeader`](value.md#kp.v1.GenericRawBypassPreProcImageHeader) + + Needed parameters for performing bypass pre-processing inference including image buffer size, model ID … etc. + + * **model_nef_descriptor** : [`kp.ModelNefDescriptor`](../value.md#kp.ModelNefDescriptor) + + ModelNefDescriptor object for describing the uploaded models. + + + +* **Returns** + + * **generic_raw_result** : [`kp.v1.GenericRawBypassPreProcResult`](value.md#kp.v1.GenericRawBypassPreProcResult) + + GenericRawBypassPreProcResult object contained the received RAW data results. + + + +* **Raises** + + * [`kp.ApiKPException`](../exception.md#kp.ApiKPException) + + + +* **Return type** + + [`GenericRawBypassPreProcResult`](value.md#kp.v1.GenericRawBypassPreProcResult) + + +* **Notes** +The data received is in Kneron RAW format, users need +kp.inference.generic_inference_retrieve_float_node()/kp.inference.generic_inference_retrieve_fixed_node() to +convert RAW format data to floating-point/fixed-point data. + + + +--- + +### kp.v1.inference.generic_raw_inference_bypass_pre_proc_send(device_group, generic_raw_image_header, image_buffer) +Generic raw inference bypass pre-processing send. +This is to perform a single image inference, it is non-blocking if device buffer queue is not full. When this +is performed, user can issue kp.v1.inference.generic_raw_inference_bypass_pre_proc_receive() to get the result. +In addition, to have better performance, users can issue multiple +kp.v1.inference.generic_raw_inference_bypass_pre_proc_send() then start to receive results through +kp.v1.inference.generic_raw_inference_bypass_pre_proc_receive(). + + +* **Parameters** + + * **device_group** : [`kp.DeviceGroup`](../value.md#kp.DeviceGroup) + + Represents a set of devices handle. + + * **generic_raw_image_header** : [`kp.v1.GenericRawBypassPreProcImageHeader`](value.md#kp.v1.GenericRawBypassPreProcImageHeader) + + Needed parameters for performing bypass pre-processing inference including image buffer size, model ID ..etc. + + * **image_buffer** : [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes) + + The data bytes contains the image. + + + +* **Raises** + + * [`kp.ApiKPException`](../exception.md#kp.ApiKPException) + + + +* **Return type** + + [`None`](https://docs.python.org/3/library/constants.html#None) + + + + +--- + +### kp.v1.inference.generic_raw_inference_receive(device_group, generic_raw_image_header, model_nef_descriptor) +Generic raw inference receive. +When an image inference is done, this function can be used to get the results in RAW format. +kp.inference.generic_inference_retrieve_float_node()/kp.inference.generic_inference_retrieve_fixed_node() to +convert RAW format data to floating-point/fixed-point data. + + +* **Parameters** + + * **device_group** : [`kp.DeviceGroup`](../value.md#kp.DeviceGroup) + + Represents a set of devices handle. + + * **generic_raw_image_header** : [`kp.v1.GenericRawImageHeader`](value.md#kp.v1.GenericRawImageHeader) + + Needed parameters for performing inference including image width, height ..etc. + + * **model_nef_descriptor** : [`kp.ModelNefDescriptor`](../value.md#kp.ModelNefDescriptor) + + ModelNefDescriptor object for describing the uploaded models. + + + +* **Returns** + + * **generic_raw_result** : [`kp.v1.GenericRawResult`](value.md#kp.v1.GenericRawResult) + + GenericRawResult object contained the received RAW data results. + + + +* **Raises** + + * [`kp.ApiKPException`](../exception.md#kp.ApiKPException) + + + +* **Return type** + + [`GenericRawResult`](value.md#kp.v1.GenericRawResult) + + +* **Notes** +The data received is in Kneron RAW format, users need +kp.inference.generic_inference_retrieve_float_node()/kp.inference.generic_inference_retrieve_fixed_node() to +convert RAW format data to floating-point/fixed-point data. + + + +--- + +### kp.v1.inference.generic_raw_inference_send(device_group, generic_raw_image_header, image, image_format) +Generic raw inference send. +This is to perform a single image inference, it is non-blocking if device buffer queue is not full. +When this is performed, user can issue kp.v1.inference.generic_raw_inference_receive() to get the result. +In addition, to have better performance, users can issue multiple kp.v1.inference.generic_raw_inference_send() then +start to receive results through kp.v1.inference.generic_raw_inference_receive(). + + +* **Parameters** + + * **device_group** : [`kp.DeviceGroup`](../value.md#kp.DeviceGroup) + + Represents a set of devices handle. + + * **generic_raw_image_header** : [`kp.v1.GenericRawImageHeader`](value.md#kp.v1.GenericRawImageHeader) + + Needed parameters for performing inference including image width, height ..etc. + + * **image** : [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes), [`numpy.ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray) + + The data bytes or numpy.ndarray contains the image. + + * **image_format** : [`kp.ImageFormat`](../enum.md#kp.ImageFormat) + + Image format supported for inference. + + + +* **Raises** + + * [`kp.ApiKPException`](../exception.md#kp.ApiKPException) + + + +* **Return type** + + [`None`](https://docs.python.org/3/library/constants.html#None) + + + diff --git a/docs/plus_python/api_document/V3.1.2/kp/v1/value.md b/docs/plus_python/api_document/V3.1.2/kp/v1/value.md new file mode 100644 index 0000000..404a376 --- /dev/null +++ b/docs/plus_python/api_document/V3.1.2/kp/v1/value.md @@ -0,0 +1,413 @@ +# kp.v1 value (Legacy Module) + + + +--- + +### **class** kp.v1.GenericRawBypassPreProcImageHeader(model_id=0, inference_number=0, image_buffer_size=0) +Inference descriptor for images bypass pre-processing. + + +* **Attributes** + + * `model_id` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Target inference model ID. + + * `inference_number` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Inference sequence number. + + * `image_buffer_size` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Inference image buffer size. + + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** image_buffer_size(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Inference image buffer size. + + + +#### **_property_** inference_number(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Inference sequence number. + + + +#### **_property_** model_id(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Target inference model ID. + + + +--- + +### **class** kp.v1.GenericRawBypassPreProcResult(buffer_size) +Generic inference raw result for bypass pre-processing. + + +* **Attributes** + + * `header` : `kp.GenericRawBypassPreProcResultHeader` + + kp.GenericRawBypassPreProcResultHeader: Inference raw output descriptor for bypass pre-processing. + + * `raw_result` : [`kp.GenericRawResultNDArray`](../value.md#kp.GenericRawResultNDArray) + + kp.GenericRawResultNDArray: Inference raw result buffer. + + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** header(: GenericRawBypassPreProcResultHeader) +kp.GenericRawBypassPreProcResultHeader: Inference raw output descriptor for bypass pre-processing. + + + +#### **_property_** raw_result(: [GenericRawResultNDArray](../value.md#kp.GenericRawResultNDArray)) +kp.GenericRawResultNDArray: Inference raw result buffer. + + + +--- + +### **class** kp.v1.GenericRawBypassPreProcResultHeader(inference_number=0, crop_number=0, num_output_node=0, product_id=0) +Inference raw output descriptor for bypass pre-processing. + + +* **Attributes** + + * `inference_number` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Inference sequence number. + + * `crop_number` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Crop box sequence number. + + * `num_output_node` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Total number of output nodes. + + * `product_id` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: USB PID (Product ID). + + + + +#### **_property_** crop_number(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Crop box sequence number. + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** inference_number(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Inference sequence number. + + + +#### **_property_** num_output_node(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Total number of output nodes. + + + +#### **_property_** product_id(: [int](https://docs.python.org/3/library/functions.html#int)) +int: USB PID (Product ID). + + + +--- + +### **class** kp.v1.GenericRawImageHeader(model_id=0, resize_mode=ResizeMode.KP_RESIZE_ENABLE, padding_mode=PaddingMode.KP_PADDING_CORNER, normalize_mode=NormalizeMode.KP_NORMALIZE_KNERON, inference_number=0, inference_crop_box_list=[], width=0, height=0, image_format=ImageFormat.KP_IMAGE_FORMAT_RGB565) +Inference descriptor for images. + + +* **Attributes** + + * `model_id` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Target inference model ID. + + * `resize_mode` : [`kp.ResizeMode`](../enum.md#kp.ResizeMode), default=kp.ResizeMode.KP_RESIZE_ENABLE + + kp.ResizeMode: Preprocess resize mode, refer to ResizeMode. + + * `padding_mode` : [`kp.PaddingMode`](../enum.md#kp.PaddingMode), default=kp.PaddingMode.KP_PADDING_CORNER + + kp.PaddingMode: Preprocess padding mode, none or auto refer to PaddingMode. + + * `normalize_mode` : [`kp.NormalizeMode`](../enum.md#kp.NormalizeMode), default=kp.NormalizeMode.KP_NORMALIZE_KNERON + + kp.NormalizeMode: Inference normalization, refer to NormalizeMode. + + * `inference_number` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Inference sequence number. + + * `inference_crop_box_list` : `List`[[`kp.InferenceCropBox`](../value.md#kp.InferenceCropBox)], default=[] + + List[kp.InferenceCropBox]: Box information to crop. + + * `width` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Inference image width. + + * `height` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Inference image height. + + * `image_format` : [`kp.ImageFormat`](../enum.md#kp.ImageFormat), default=kp.ImageFormat.KP_IMAGE_FORMAT_RGB565 + + kp.ImageFormat: Inference image format, refer to ImageFormat. + + + + +#### **_property_** crop_count(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Number of crop box. + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** height(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Inference image height. + + + +#### **_property_** image_format(: [ImageFormat](../enum.md#kp.ImageFormat)) +kp.ImageFormat: Inference image format, refer to ImageFormat. + + + +#### **_property_** inference_crop_box_list(: [List](https://docs.python.org/3/library/typing.html#typing.List)[[InferenceCropBox](../value.md#kp.InferenceCropBox)]) +List[kp.InferenceCropBox]: Box information to crop. + + + +#### **_property_** inference_number(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Inference sequence number. + + + +#### **_property_** model_id(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Target inference model ID. + + + +#### **_property_** normalize_mode(: [NormalizeMode](../enum.md#kp.NormalizeMode)) +kp.NormalizeMode: Inference normalization, refer to NormalizeMode. + + + +#### **_property_** padding_mode(: [PaddingMode](../enum.md#kp.PaddingMode)) +kp.PaddingMode: Preprocess padding mode, none or auto refer to PaddingMode. + + + +#### **_property_** resize_mode(: [ResizeMode](../enum.md#kp.ResizeMode)) +kp.ResizeMode: Preprocess resize mode, refer to ResizeMode. + + + +#### **_property_** width(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Inference image width. + + + +--- + +### **class** kp.v1.GenericRawResult(buffer_size) +Generic inference raw result. + + +* **Attributes** + + * `header` : `kp.GenericRawResultHeader` + + kp.GenericRawResultHeader: Inference raw output descriptor. + + * `raw_result` : [`kp.GenericRawResultNDArray`](../value.md#kp.GenericRawResultNDArray) + + kp.GenericRawResultNDArray: Inference raw result buffer. + + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** header(: GenericRawResultHeader) +kp.GenericRawResultHeader: Inference raw output descriptor. + + + +#### **_property_** raw_result(: [GenericRawResultNDArray](../value.md#kp.GenericRawResultNDArray)) +kp.GenericRawResultNDArray: Inference raw result buffer. + + + +--- + +### **class** kp.v1.GenericRawResultHeader(inference_number=0, crop_number=0, num_output_node=0, product_id=0, hw_pre_proc_info={'img_width': 0, 'img_height': 0, 'resized_img_width': 0, 'resized_img_heig ...) +Inference raw output descriptor. + + +* **Attributes** + + * `inference_number` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Inference sequence number. + + * `crop_number` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Crop box sequence number. + + * `num_output_node` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Total number of output nodes. + + * `product_id` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: USB PID (Product ID). + + * `hw_pre_proc_info` : [`kp.HwPreProcInfo`](../value.md#kp.HwPreProcInfo), default=kp.HwPreProcInfo() + + kp.HwPreProcInfo: Hardware preprocess info + + + + +#### **_property_** crop_number(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Crop box sequence number. + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** hw_pre_proc_info(: [HwPreProcInfo](../value.md#kp.HwPreProcInfo)) +kp.HwPreProcInfo: Hardware preprocess info + + + +#### **_property_** inference_number(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Inference sequence number. + + + +#### **_property_** num_output_node(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Total number of output nodes. + + + +#### **_property_** product_id(: [int](https://docs.python.org/3/library/functions.html#int)) +int: USB PID (Product ID). + + diff --git a/docs/plus_python/api_document/V3.1.2/kp/value.md b/docs/plus_python/api_document/V3.1.2/kp/value.md new file mode 100644 index 0000000..a7f85b8 --- /dev/null +++ b/docs/plus_python/api_document/V3.1.2/kp/value.md @@ -0,0 +1,2610 @@ +# kp value + + + +--- + +### **class** kp.DdrManageAttributes(model_size=0, input_buffer_size=0, input_buffer_count=0, result_buffer_size=0, result_buffer_count=0) +DDR memory management descriptor of Kneron device. + + +* **Attributes** + + * `model_size` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: DDR space for model. + + * `input_buffer_size` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Input buffer size for FIFO queue. + + * `input_buffer_count` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Input buffer count for FIFO queue. + + * `result_buffer_size` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Result buffer size for FIFO queue. + + * `result_buffer_count` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Result buffer count for FIFO queue. + + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** input_buffer_count(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Input buffer count for FIFO queue. + + + +#### **_property_** input_buffer_size(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Input buffer size for FIFO queue. + + + +#### **_property_** model_size(: [int](https://docs.python.org/3/library/functions.html#int)) +int: DDR space for model. + + + +#### **_property_** result_buffer_count(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Result buffer count for FIFO queue. + + + +#### **_property_** result_buffer_size(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Result buffer size for FIFO queue. + + + +--- + +### **class** kp.DeviceDescriptor(usb_port_id=0, vendor_id=0, product_id=0, link_speed=UsbSpeed.KP_USB_SPEED_UNKNOWN, kn_number=0, is_connectable=False, usb_port_path='', firmware='') +Information of one connected device from USB perspectives. + + +* **Attributes** + + * `usb_port_id` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: An unique ID representing for a Kneron device, can be used as input while connecting devices. + + * `vendor_id` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Supposed to be 0x3231. + + * `product_id` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: USB PID (Product ID). + + * `link_speed` : [`UsbSpeed`](enum.md#kp.UsbSpeed), default=UsbSpeed.KP_USB_SPEED_UNKNOWN + + UsbSpeed: Enum for USB speed mode. + + * `kn_number` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: KN number. + + * `is_connectable` : [bool](https://docs.python.org/3/library/stdtypes.html#bltin-boolean-values), default=False + + bool: Indicate if this device is connectable. + + * `usb_port_path` : [`str`](https://docs.python.org/3/library/stdtypes.html#str), default=’’ + + str: “busNo-hub_portNo-device_portNo” (ex: “1-2-3”, means bus 1 - (hub) port 2 - (device) port 3) + + * `firmware` : [`str`](https://docs.python.org/3/library/stdtypes.html#str), default=’’ + + str: Firmware description. + + + + +#### **_property_** firmware(: [str](https://docs.python.org/3/library/stdtypes.html#str)) +str: Firmware description. + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** is_connectable(: [bool](https://docs.python.org/3/library/functions.html#bool)) +bool: Indicate if this device is connectable. + + + +#### **_property_** kn_number(: [int](https://docs.python.org/3/library/functions.html#int)) +int: KN number. + + + +#### **_property_** link_speed(: [UsbSpeed](enum.md#kp.UsbSpeed)) +UsbSpeed: Enum for USB speed mode. + + + +#### **_property_** product_id(: [int](https://docs.python.org/3/library/functions.html#int)) +int: USB PID (Product ID). + + + +#### **_property_** usb_port_id(: [int](https://docs.python.org/3/library/functions.html#int)) +int: An unique ID representing for a Kneron device, can be used as input while connecting devices. + + + +#### **_property_** usb_port_path(: [str](https://docs.python.org/3/library/stdtypes.html#str)) +str: “busNo-hub_portNo-device_portNo” (ex: “1-2-3”, means bus 1 - (hub) port 2 - (device) port 3) + + + +#### **_property_** vendor_id(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Supposed to be 0x3231. + + + +--- + +### **class** kp.DeviceDescriptorList(device_descriptor_list=[]) +Information of connected devices from USB perspectives. + + +* **Attributes** + + * `device_descriptor_list` : `List`[`kp.DeviceDescriptor`], default=[] + + List[kp.DeviceDescriptor]: DeviceDescriptor objects list, contain information of connected devices from USB perspectives. + + + + +#### **_property_** device_descriptor_list(: [List](https://docs.python.org/3/library/typing.html#typing.List)[DeviceDescriptor]) +List[kp.DeviceDescriptor]: DeviceDescriptor objects list, contain information of connected devices from USB +perspectives. + + + +#### **_property_** device_descriptor_number(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Number of connected devices. + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +--- + +### **class** kp.DeviceGroup(address) +A handle represent connected Kneron device. + + +* **Attributes** + + * `address` : [`int`](https://docs.python.org/3/library/functions.html#int) + + int: Memory address of connected Kneron device handler. + + + + +#### **_property_** address(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Memory address of connected Kneron device handler. + + + +#### **_property_** content(: DeviceGroupContent) +DeviceGroupContent: A DeviceGroup descriptor. + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +--- + +### **class** kp.FirmwareVersion(reserved=0, major=0, minor=0, update=0, build=0) +Information of firmware version. + + +* **Attributes** + + * `reserved` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Reserved version number for backward compatibility. + + * **major** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + * **minor** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + * **update** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + * **build** : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** reserved(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Reserved version number for backward compatibility. + + + +--- + +### **class** kp.GenericDataInferenceDescriptor(inference_number=0, model_id=0, input_node_data_list=[]) +Multiple input inference descriptor for bypass pre-processing inference. + + +* **Attributes** + + * `model_id` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Target inference model ID. + + * `inference_number` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Inference sequence number. + + * `input_node_data_list` : `List`[`GenericInputNodeData`], default=[] + + List[GenericInputNodeData]: Multiple input inference data descriptors (The data order must be mapping model input tensor order as shown in ModelNefDescriptor). + + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** inference_number(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Inference sequence number. + + + +#### **_property_** input_node_data_list(: [List](https://docs.python.org/3/library/typing.html#typing.List)[GenericInputNodeData]) +List[GenericInputNodeData]: Multiple input inference data descriptors (The data order must be mapping model input tensor order as shown in ModelNefDescriptor). + + + +#### **_property_** input_node_data_num(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Number of multiple input inference data descriptors in input_node_data_list. + + + +#### **_property_** model_id(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Target inference model ID. + + + +--- + +### **class** kp.GenericDataInferenceResult(buffer_size) +Multiple input bypass pre-processing inference raw result. + + +* **Attributes** + + * `header` : `kp.GenericDataInferenceResultHeader` + + kp.GenericDataInferenceResultHeader: Multiple input bypass pre-processing inference raw output descriptor. + + * `raw_result` : `kp.GenericRawResultNDArray` + + kp.GenericRawResultNDArray: Inference raw result buffer. + + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** header(: GenericDataInferenceResultHeader) +kp.GenericDataInferenceResultHeader: Multiple input bypass pre-processing inference raw output descriptor. + + + +#### **_property_** raw_result(: GenericRawResultNDArray) +kp.GenericRawResultNDArray: Inference raw result buffer. + + + +--- + +### **class** kp.GenericDataInferenceResultHeader(inference_number=0, crop_number=0, num_output_node=0, product_id=0) +Multiple input bypass pre-processing inference raw output descriptor. + + +* **Attributes** + + * `inference_number` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Inference sequence number. + + * `crop_number` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Crop box sequence number. + + * `num_output_node` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Total number of output nodes. + + * `product_id` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: USB PID (Product ID). + + + + +#### **_property_** crop_number(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Crop box sequence number. + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** inference_number(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Inference sequence number. + + + +#### **_property_** num_output_node(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Total number of output nodes. + + + +#### **_property_** product_id(: [int](https://docs.python.org/3/library/functions.html#int)) +int: USB PID (Product ID). + + + +--- + +### **class** kp.GenericImageInferenceDescriptor(inference_number=0, model_id=0, input_node_image_list=[]) +Multiple input inference descriptor for images. + + +* **Attributes** + + * `model_id` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Target inference model ID. + + * `inference_number` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Inference sequence number. + + * `input_node_image_list` : `List`[`GenericInputNodeImage`], default=[] + + List[kp.GenericInputNodeImage]: Multiple input inference image data descriptors (Max number of input image is 5) (The image data order must be mapping model input tensor order as shown in ModelNefDescriptor). + + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** inference_number(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Inference sequence number. + + + +#### **_property_** input_node_image_list(: [List](https://docs.python.org/3/library/typing.html#typing.List)[GenericInputNodeImage]) +List[kp.GenericInputNodeImage]: Multiple input inference image data descriptors (Max number of input image is 5) (The image data order must be mapping model input tensor order as shown in ModelNefDescriptor). + + + +#### **_property_** input_node_image_num(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Number of multiple input inference image data descriptors in input_node_image_list. + + + +#### **_property_** model_id(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Target inference model ID. + + + +--- + +### **class** kp.GenericImageInferenceResult(buffer_size) +Generic multiple input inference raw result. + + +* **Attributes** + + * `header` : `kp.GenericImageInferenceResultHeader` + + kp.GenericImageInferenceResultHeader: Multiple input image inference raw output descriptor. + + * `raw_result` : `kp.GenericRawResultNDArray` + + kp.GenericRawResultNDArray: Inference raw result buffer. + + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** header(: GenericImageInferenceResultHeader) +kp.GenericImageInferenceResultHeader: Multiple input image inference raw output descriptor. + + + +#### **_property_** raw_result(: GenericRawResultNDArray) +kp.GenericRawResultNDArray: Inference raw result buffer. + + + +--- + +### **class** kp.GenericImageInferenceResultHeader(inference_number=0, crop_number=0, num_output_node=0, product_id=0, hw_pre_proc_info_list=[]) +Multiple input image inference raw output descriptor. + + +* **Attributes** + + * `inference_number` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Inference sequence number. + + * `crop_number` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Crop box sequence number. + + * `num_output_node` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Total number of output nodes. + + * `product_id` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: USB PID (Product ID). + + * `hw_pre_proc_info_list` : `List`[`kp.HwPreProcInfo`], default=[] + + List[kp.HwPreProcInfo]: Hardware pre-process information for each input node. + + + + +#### **_property_** crop_number(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Crop box sequence number. + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** hw_pre_proc_info_list(: [List](https://docs.python.org/3/library/typing.html#typing.List)[HwPreProcInfo]) +List[kp.HwPreProcInfo]: Hardware pre-process information for each input node. + + + +#### **_property_** inference_number(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Inference sequence number. + + + +#### **_property_** num_hw_pre_proc_info(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Number of hardware pre-process information. + + + +#### **_property_** num_output_node(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Total number of output nodes. + + + +#### **_property_** product_id(: [int](https://docs.python.org/3/library/functions.html#int)) +int: USB PID (Product ID). + + + +--- + +### **class** kp.GenericInputNodeData(buffer=b'') +Single data descriptor for bypass pre-processing inference. + + +* **Attributes** + + * `buffer` : [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes), default=bytes() + + bytes: The data bytes contains the inference data. + + + + +#### **_property_** buffer(: [bytes](https://docs.python.org/3/library/stdtypes.html#bytes)) +bytes: The data bytes contains the inference data. + + + +#### **_property_** buffer_size(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Inference data buffer size. + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +--- + +### **class** kp.GenericInputNodeImage(image=array([], shape=(0, 0, 2), dtype=uint8), width=0, height=0, image_format=ImageFormat.KP_IMAGE_FORMAT_RGB565, resize_mode=ResizeMode.KP_RESIZE_ENABLE, padding_mode=PaddingMode.KP_PADDING_CORNER, normalize_mode=NormalizeMode.KP_NORMALIZE_KNERON, inference_crop_box_list=[]) +Single inference image data descriptor. + + +* **Attributes** + + * `image` : [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes), [`numpy.ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray), default=numpy.ndarray([0, 0, `kp.Const.CHANNEL_NUM_OTHER_FORMAT.value`], dtype=np.uint8) + + numpy.ndarray: The data bytes or numpy.ndarray (dtype=numpy.uint8, dim=3) contains the image. + + * `width` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Inference image width (Must apply when using bytes image data). + + * `height` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Inference image height (Must apply when using bytes image data). + + * `image_format` : [`kp.ImageFormat`](enum.md#kp.ImageFormat), default=kp.ImageFormat.KP_IMAGE_FORMAT_RGB565 + + kp.ImageFormat: Inference image format, refer to ImageFormat. + + * `resize_mode` : [`kp.ResizeMode`](enum.md#kp.ResizeMode), default=kp.ResizeMode.KP_RESIZE_ENABLE + + kp.ResizeMode: Preprocess resize mode, refer to ResizeMode. + + * `padding_mode` : [`kp.PaddingMode`](enum.md#kp.PaddingMode), default=kp.PaddingMode.KP_PADDING_CORNER + + kp.PaddingMode: Preprocess padding mode, none or auto refer to PaddingMode. + + * `normalize_mode` : [`kp.NormalizeMode`](enum.md#kp.NormalizeMode), default=kp.NormalizeMode.KP_NORMALIZE_KNERON + + kp.NormalizeMode: Inference normalization, refer to NormalizeMode. + + * `inference_crop_box_list` : `List`[`kp.InferenceCropBox`], default=[] + + List[kp.InferenceCropBox]: Box information to crop. + + + + +#### **_property_** crop_count(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Number of crop box. + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** height(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Inference image height (Must apply when using bytes image data). + + + +#### **_property_** image(: [ndarray](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray)) +numpy.ndarray: The data bytes or numpy.ndarray (dtype=numpy.uint8, dim=3) contains the image. + + + +#### **_property_** image_format(: [ImageFormat](enum.md#kp.ImageFormat)) +kp.ImageFormat: Inference image format, refer to ImageFormat. + + + +#### **_property_** inference_crop_box_list(: [List](https://docs.python.org/3/library/typing.html#typing.List)[InferenceCropBox]) +List[kp.InferenceCropBox]: Box information to crop. + + + +#### **_property_** normalize_mode(: [NormalizeMode](enum.md#kp.NormalizeMode)) +kp.NormalizeMode: Inference normalization, refer to NormalizeMode. + + + +#### **_property_** padding_mode(: [PaddingMode](enum.md#kp.PaddingMode)) +kp.PaddingMode: Preprocess padding mode, none or auto refer to PaddingMode. + + + +#### **_property_** resize_mode(: [ResizeMode](enum.md#kp.ResizeMode)) +kp.ResizeMode: Preprocess resize mode, refer to ResizeMode. + + + +#### **_property_** width(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Inference image width (Must apply when using bytes image data). + + + +--- + +### **class** kp.GenericRawResultNDArray(buffer_size) +Inference raw result buffer. + + +* **Attributes** + + * `buffer_size` : [`int`](https://docs.python.org/3/library/functions.html#int) + + int: Size of generic inference raw result buffer. + + + + +#### **_property_** buffer_size(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Size of generic inference raw result buffer. + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +--- + +### **class** kp.HwPreProcInfo(img_width=0, img_height=0, resized_img_width=0, resized_img_height=0, pad_top=0, pad_bottom=0, pad_left=0, pad_right=0, model_input_width=0, model_input_height=0, crop_area={'crop_box_index': 0, 'x': 0, 'y': 0, 'width': 0, 'height': 0}) +Information of Hardware Pre Process. + + +* **Attributes** + + * `img_width` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Image width before hardware pre-process. + + * **img_height: int, default=0** + + Image height before hardware pre-process. + + * **resized_img_width: int, default=0** + + Image width after resize. + + * **resized_img_height: int, default=0** + + Image height after resize. + + * **pad_top: int, default=0** + + Pixels padding on top. + + * **pad_bottom: int, default=0** + + Pixels padding on bottom. + + * **pad_left: int, default=0** + + Pixels padding on left. + + * **pad_right: int, default=0** + + Pixels padding on right. + + * **model_input_width: int, default=0** + + Model required input width. + + * **model_input_height: int, default=0** + + Model required input height. + + * **crop_area: InferenceCropBox, default=InferenceCropBox()** + + Information of crop area. (may not be the same as input due to hardware limitation) + + + + +#### **_property_** crop_area(: InferenceCropBox) +InferenceCropBox: Information of crop area. (may not be the same as input due to hardware limitation) + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** img_height(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Image height before hardware pre-process. + + + +#### **_property_** img_width(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Image width before hardware pre-process. + + + +#### **_property_** model_input_height(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Model required input height. + + + +#### **_property_** model_input_width(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Model required input width. + + + +#### **_property_** pad_bottom(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Pixels padding on bottom. + + + +#### **_property_** pad_left(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Pixels padding on left. + + + +#### **_property_** pad_right(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Pixels padding on right. + + + +#### **_property_** pad_top(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Pixels padding on top. + + + +#### **_property_** resized_img_height(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Image height after resize. + + + +#### **_property_** resized_img_width(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Image width after resize. + + + +--- + +### **class** kp.InferenceConfiguration(enable_frame_drop=False) +Inference configurations. + + +* **Attributes** + + * `enable_frame_drop` : [bool](https://docs.python.org/3/library/stdtypes.html#bltin-boolean-values), default=False + + bool: Enable this to keep inference non-blocking by dropping oldest and unprocessed frames. + + + + +#### **_property_** enable_frame_drop(: [bool](https://docs.python.org/3/library/functions.html#bool)) +bool: Enable this to keep inference non-blocking by dropping oldest and unprocessed frames. + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +--- + +### **class** kp.InferenceCropBox(crop_box_index=0, x=0, y=0, width=0, height=0) +Class for an image crop region. + + +* **Attributes** + + * `crop_box_index` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Index number of crop box. + + * `x` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: X coordinate of crop box top-left corner. + + * `y` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Y coordinate of crop box top-left corner. + + * `width` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Width coordinate of crop box. + + * `height` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Height coordinate of crop box. + + + + +#### **_property_** crop_box_index(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Index number of crop box. + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** height(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Height coordinate of crop box. + + + +#### **_property_** width(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Width coordinate of crop box. + + + +#### **_property_** x(: [int](https://docs.python.org/3/library/functions.html#int)) +int: X coordinate of crop box top-left corner. + + + +#### **_property_** y(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Y coordinate of crop box top-left corner. + + + +--- + +### **class** kp.InferenceFixedNodeOutput(name='', shape=[], quantization_parameters={'version': 'QuantizationParametersVersion.KP_MODEL_QUANTIZATION_PARAMS_VER ..., dtype=FixedPointDType.KP_FIXED_POINT_DTYPE_UNKNOWN, num_data=0, data=array([], dtype=float64), channels_ordering=ChannelOrdering.KP_CHANNEL_ORDERING_CHW) +Generic inference node output in fixed-point format. + + +* **Attributes** + + * `name` : [`str`](https://docs.python.org/3/library/stdtypes.html#str), default=’’ + + str: Name of the tensor. + + * `shape` : `List`[[`int`](https://docs.python.org/3/library/functions.html#int)], default=[] + + List[int]: ONNX shape of the tensor. + + * `quantization_parameters` : `QuantizationParameters`, default=QuantizationParameters() + + QuantizationParameters: Quantization parameters of the tensor. + + * `dtype` : [`FixedPointDType`](enum.md#kp.FixedPointDType), default=FixedPointDType. + + FixedPointDType: fixed-point data type. + + * `num_data` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Total number of fixed-point values. + + * **data** : [`np.ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray), default=np.array([]) + + N-dimensional numpy.ndarray of feature map in fixed-point (8-bits/16-bits). + + * `channels_ordering` : [`ChannelOrdering`](enum.md#kp.ChannelOrdering), default=ChannelOrdering.KP_CHANNEL_ORDERING_CHW + + kp.ChannelOrdering: Channel ordering of feature map. (Options: KP_CHANNEL_ORDERING_HCW, KP_CHANNEL_ORDERING_CHW, KP_CHANNEL_ORDERING_DEFAULT) + + + + +#### **_property_** channels_ordering(: [ChannelOrdering](enum.md#kp.ChannelOrdering)) +kp.ChannelOrdering: Channel ordering of feature map. (Options: KP_CHANNEL_ORDERING_HCW, KP_CHANNEL_ORDERING_CHW, KP_CHANNEL_ORDERING_DEFAULT) + + + +#### **_property_** dtype(: [FixedPointDType](enum.md#kp.FixedPointDType)) +FixedPointDType: fixed-point data type. + + + +#### **_property_** factor(: [ndarray](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray)) +numpy.ndarray: N-dimensional numpy.ndarray of dequantization factor. + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** name(: [str](https://docs.python.org/3/library/stdtypes.html#str)) +str: Name of the tensor. + + + +#### **_property_** ndarray(: [ndarray](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray)) +numpy.ndarray: N-dimensional numpy.ndarray of feature map. + + + +#### **_property_** num_data(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Total number of fixed-point values. + + + +#### **_property_** quantization_parameters(: QuantizationParameters) +QuantizationParameters: Quantization parameters of the tensor. + + + +#### **_property_** shape(: [List](https://docs.python.org/3/library/typing.html#typing.List)[[int](https://docs.python.org/3/library/functions.html#int)]) +List[int]: ONNX shape of the tensor. + + + +#### to_float_node_output() +Convert fixed-point node output to floating-point node output. + + +* **Returns** + + * **inference_float_node_output** : `kp.InferenceFloatNodeOutput` + + + +* **Return type** + + `InferenceFloatNodeOutput` + + + + +--- + +### **class** kp.InferenceFloatNodeOutput(name='', shape=[], num_data=0, data=array([], dtype=float64), channels_ordering=ChannelOrdering.KP_CHANNEL_ORDERING_CHW) +Generic inference node output in floating-point format. + + +* **Attributes** + + * `name` : [`str`](https://docs.python.org/3/library/stdtypes.html#str), default=’’ + + str: Name of the tensor. + + * `shape` : `List`[[`int`](https://docs.python.org/3/library/functions.html#int)], default=[] + + List[int]: ONNX shape of the tensor. + + * `num_data` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Total number of floating-point values. + + * **data** : [`np.ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray), default=np.array([]) + + N-dimensional numpy.ndarray of feature map. (Channel ordering: KL520 - H,C,W; KL720 - C,H,W) + + * `channels_ordering` : [`kp.ChannelOrdering`](enum.md#kp.ChannelOrdering), default=kp.ChannelOrdering.KP_CHANNEL_ORDERING_CHW + + kp.ChannelOrdering: Channel ordering of feature map. (Options: KP_CHANNEL_ORDERING_HCW, KP_CHANNEL_ORDERING_CHW) + + + + +#### **_property_** channels_ordering(: [ChannelOrdering](enum.md#kp.ChannelOrdering)) +kp.ChannelOrdering: Channel ordering of feature map. (Options: KP_CHANNEL_ORDERING_HCW, KP_CHANNEL_ORDERING_CHW) + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** name(: [str](https://docs.python.org/3/library/stdtypes.html#str)) +str: Name of the tensor. + + + +#### **_property_** ndarray(: [ndarray](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray)) +numpy.ndarray: N-dimensional numpy.ndarray of feature map. + + + +#### **_property_** num_data(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Total number of floating-point values. + + + +#### **_property_** shape(: [List](https://docs.python.org/3/library/typing.html#typing.List)[[int](https://docs.python.org/3/library/functions.html#int)]) +List[int]: ONNX shape of the tensor. + + + +--- + +### **class** kp.ModelNefDescriptor(magic=0, metadata={'kn_number': '0x0', 'toolchain_version': '', 'compiler_version': '', 'nef_ ..., target_chip=ModelTargetChip.KP_MODEL_TARGET_CHIP_UNKNOWN, crc=0, models=[]) +A basic descriptor for NEF. + + +* **Attributes** + + * `magic` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Magic number for model_nef_descriptor (0x5AA55AA5). + + * `metadata` : `ModelNefMetadata`, default=ModelNefMetadata() + + ModelNefMetadata: NEF metadata. + + * `target_chip` : [`ModelTargetChip`](enum.md#kp.ModelTargetChip), default=ModelTargetChip.KP_MODEL_TARGET_CHIP_UNKNOWN + + ModelTargetChip: Target chip of all models. + + * `crc` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: CRC of NEF models. + + * `models` : `List`[`SingleModelDescriptor`], default=[] + + List[SingleModelDescriptor]: Model descriptors. + + + + +#### **_property_** crc(: [int](https://docs.python.org/3/library/functions.html#int)) +int: CRC of NEF models. + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** magic(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Magic number for model_nef_descriptor (0x5AA55AA5). + + + +#### **_property_** metadata(: ModelNefMetadata) +ModelNefMetadata: NEF metadata. + + + +#### **_property_** models(: [List](https://docs.python.org/3/library/typing.html#typing.List)[SingleModelDescriptor]) +List[SingleModelDescriptor]: Model descriptors. + + + +#### **_property_** target_chip(: [ModelTargetChip](enum.md#kp.ModelTargetChip)) +ModelTargetChip: Target chip of all models. + + + +--- + +### **class** kp.ModelNefMetadata(kn_number=0, toolchain_version='', compiler_version='', nef_schema_version={'version': '0.0.0'}, platform='') +A basic descriptor for a model NEF metadata. + + +* **Attributes** + + * `kn_number` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Target KN number device of encrypted all models. + + * `toolchain_version` : [`str`](https://docs.python.org/3/library/stdtypes.html#str), default=’’ + + str: Toolchain version of all models. + + * `compiler_version` : [`str`](https://docs.python.org/3/library/stdtypes.html#str), default=’’ + + str: Compiler version of all models. + + * `nef_schema_version` : `NefSchemaVersion`, default=NefSchemaVersion() + + NefSchemaVersion: Schema version of nef. + + * `platform` : [`str`](https://docs.python.org/3/library/stdtypes.html#str), default=’’ + + str: Target device platform USB dongle, 96 board, etc. + + + + +#### **_property_** compiler_version(: [str](https://docs.python.org/3/library/stdtypes.html#str)) +str: Compiler version of all models. + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** kn_number(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Target KN number device of encrypted all models. + + + +#### **_property_** nef_schema_version(: NefSchemaVersion) +NefSchemaVersion: Schema version of nef. + + + +#### **_property_** platform(: [str](https://docs.python.org/3/library/stdtypes.html#str)) +str: Target device platform USB dongle, 96 board, etc. + + + +#### **_property_** toolchain_version(: [str](https://docs.python.org/3/library/stdtypes.html#str)) +str: Toolchain version of all models. + + + +--- + +### **class** kp.NefSchemaVersion(major=0, minor=0, revision=0) +A NEF schema version object. + + +* **Attributes** + + * `major` + + int: Major number. + + * `minor` + + int: Minor number. + + * `revision` + + int: Revision number. + + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** major(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Major number. + + + +#### **_property_** minor(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Minor number. + + + +#### **_property_** revision(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Revision number. + + + +--- + +### **class** kp.NpuPerformanceMonitorStatistics(model_id=0, npu_clock_rate=0, f0=0, f1=0, f2=0, f3=0, f4=0, f5=0, f6=0, f7=0) +One model inference performance monitor statistic data. + + +* **Attributes** + + * `model_id` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Target inference model ID. + + * `npu_clock_rate` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: NPU clock rate. + + * `f0` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Value of performance monitor mode f0. + + * `f0_time` : [`float`](https://docs.python.org/3/library/functions.html#float), default=0 + + float: time of performance monitor mode f0. + + * `f1` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Value of performance monitor mode f1. + + * `f1_time` : [`float`](https://docs.python.org/3/library/functions.html#float), default=0 + + float: time of performance monitor mode f1. + + * `f2` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Value of performance monitor mode f2. + + * `f2_time` : [`float`](https://docs.python.org/3/library/functions.html#float), default=0 + + float: time of performance monitor mode f2. + + * `f3` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Value of performance monitor mode f3. + + * `f3_time` : [`float`](https://docs.python.org/3/library/functions.html#float), default=0 + + float: time of performance monitor mode f3. + + * `f4` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Value of performance monitor mode f4. + + * `f4_time` : [`float`](https://docs.python.org/3/library/functions.html#float), default=0 + + float: time of performance monitor mode f4. + + * `f5` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Value of performance monitor mode f5. + + * `f5_time` : [`float`](https://docs.python.org/3/library/functions.html#float), default=0 + + float: time of performance monitor mode f5. + + * `f6` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Value of performance monitor mode f6. + + * `f6_time` : [`float`](https://docs.python.org/3/library/functions.html#float), default=0 + + float: time of performance monitor mode f6. + + * `f7` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Value of performance monitor mode f7. + + * `f7_time` : [`float`](https://docs.python.org/3/library/functions.html#float), default=0 + + float: time of performance monitor mode f7. + + + + +#### **_property_** f0(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Value of performance monitor mode f0. + + + +#### **_property_** f0_time(: [float](https://docs.python.org/3/library/functions.html#float)) +float: time of performance monitor mode f0. + + + +#### **_property_** f1(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Value of performance monitor mode f1. + + + +#### **_property_** f1_time(: [float](https://docs.python.org/3/library/functions.html#float)) +float: time of performance monitor mode f1. + + + +#### **_property_** f2(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Value of performance monitor mode f2. + + + +#### **_property_** f2_time(: [float](https://docs.python.org/3/library/functions.html#float)) +float: time of performance monitor mode f2. + + + +#### **_property_** f3(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Value of performance monitor mode f3. + + + +#### **_property_** f3_time(: [float](https://docs.python.org/3/library/functions.html#float)) +float: time of performance monitor mode f3. + + + +#### **_property_** f4(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Value of performance monitor mode f4. + + + +#### **_property_** f4_time(: [float](https://docs.python.org/3/library/functions.html#float)) +float: time of performance monitor mode f4. + + + +#### **_property_** f5(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Value of performance monitor mode f5. + + + +#### **_property_** f5_time(: [float](https://docs.python.org/3/library/functions.html#float)) +float: time of performance monitor mode f5. + + + +#### **_property_** f6(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Value of performance monitor mode f6. + + + +#### **_property_** f6_time(: [float](https://docs.python.org/3/library/functions.html#float)) +float: time of performance monitor mode f6. + + + +#### **_property_** f7(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Value of performance monitor mode f7. + + + +#### **_property_** f7_time(: [float](https://docs.python.org/3/library/functions.html#float)) +float: time of performance monitor mode f7. + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** model_id(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Target inference model ID. + + + +#### **_property_** npu_clock_rate(: [int](https://docs.python.org/3/library/functions.html#int)) +int: NPU clock rate. + + + +--- + +### **class** kp.PerformanceMonitorData(npu_clock_rate=0, model_statistic_list=[]) +Model inference performance monitor data. + + +* **Attributes** + + * `model_profiled_num` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Number of profiled model. + + * `model_statistic_list` : `List`[`kp.NpuPerformanceMonitorStatistics`], default=[] + + List[kp.NpuPerformanceMonitorStatistics]: List of performance monitor statistic data. + + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** model_profiled_num(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Number of profiled model. + + + +#### **_property_** model_statistic_list(: [List](https://docs.python.org/3/library/typing.html#typing.List)[NpuPerformanceMonitorStatistics]) +List[kp.NpuPerformanceMonitorStatistics]: List of performance monitor statistic data. + + + +--- + +### **class** kp.ProfileData(model_statistic_list=[]) +Model inference profiling data. + + +* **Attributes** + + * `model_profiled_num` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Number of profiled model. + + * `model_statistic_list` : `List`[`kp.ProfileModelStatistics`], default=[] + + List[kp.ProfileModelStatistics]: List of model inference statistic data. + + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** model_profiled_num(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Number of profiled model. + + + +#### **_property_** model_statistic_list(: [List](https://docs.python.org/3/library/typing.html#typing.List)[ProfileModelStatistics]) +List[kp.ProfileModelStatistics]: List of model inference statistic data. + + + +--- + +### **class** kp.ProfileModelStatistics(model_id=0, inference_count=0, cpu_op_count=0, avg_pre_process_ms=0, avg_inference_ms=0, avg_cpu_op_ms=0, avg_cpu_op_per_cpu_node_ms=0, avg_post_process_ms=0) +One model inference statistic data. + + +* **Attributes** + + * `model_id` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Target inference model ID. + + * `inference_count` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Number of Inference in the statistic. + + * `cpu_op_count` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Number of CPU operation per inference. + + * `avg_pre_process_ms` : [`float`](https://docs.python.org/3/library/functions.html#float), default=0 + + float: Average pre-process time in milliseconds. + + * `avg_inference_ms` : [`float`](https://docs.python.org/3/library/functions.html#float), default=0 + + float: Average inference time in milliseconds. + + * `avg_cpu_op_ms` : [`float`](https://docs.python.org/3/library/functions.html#float), default=0 + + float: Average CPU operation time per-inference in milliseconds. + + * `avg_cpu_op_per_cpu_node_ms` : [`float`](https://docs.python.org/3/library/functions.html#float), default=0 + + float: Average CPU operation time per-CPU node in milliseconds. + + * `avg_post_process_ms` : [`float`](https://docs.python.org/3/library/functions.html#float), default=0 + + float: Average post-process time in milliseconds. + + + + +#### **_property_** avg_cpu_op_ms(: [float](https://docs.python.org/3/library/functions.html#float)) +float: Average CPU operation time per-inference in milliseconds. + + + +#### **_property_** avg_cpu_op_per_cpu_node_ms(: [float](https://docs.python.org/3/library/functions.html#float)) +float: Average CPU operation time per-CPU node in milliseconds. + + + +#### **_property_** avg_inference_ms(: [float](https://docs.python.org/3/library/functions.html#float)) +float: Average inference time in milliseconds. + + + +#### **_property_** avg_post_process_ms(: [float](https://docs.python.org/3/library/functions.html#float)) +float: Average post-process time in milliseconds. + + + +#### **_property_** avg_pre_process_ms(: [float](https://docs.python.org/3/library/functions.html#float)) +float: Average pre-process time in milliseconds. + + + +#### **_property_** cpu_op_count(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Number of CPU operation per inference. + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** inference_count(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Number of Inference in the statistic. + + + +#### **_property_** model_id(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Target inference model ID. + + + +--- + +### **class** kp.QuantizationParameters(version=QuantizationParametersVersion.KP_MODEL_QUANTIZATION_PARAMS_VERSION_1, data={'quantized_axis': 0, 'quantized_fixed_point_descriptor_list': {}}) +Quantization parameters data for tensor. + + +* **Attributes** + + * `version` : [`QuantizationParametersVersion`](enum.md#kp.QuantizationParametersVersion), default=QuantizationParametersVersion.KP_MODEL_QUANTIZATION_PARAMS_VERSION_1 + + QuantizationParametersVersion: Quantization parameters version (ref. + + * `data` : `Union`[`QuantizationParametersV1`] = `QuantizationParametersV1` + + Union[QuantizationParametersV1]: Quantization parameters for tensor. + + + + +#### **_property_** data(: QuantizationParametersV1) +Union[QuantizationParametersV1]: Quantization parameters for tensor. + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** v1(: QuantizationParametersV1) +QuantizationParametersV1: Quantization parameters for tensor. (Version 1) + + + +#### **_property_** version(: [QuantizationParametersVersion](enum.md#kp.QuantizationParametersVersion)) +QuantizationParametersVersion: Quantization parameters version (ref. QuantizationParametersVersion). + + + +--- + +### **class** kp.QuantizationParametersV1(quantized_axis=0, quantized_fixed_point_descriptor_list=[]) +Quantization parameters V1 for tensor. + + +* **Attributes** + + * `quantized_axis` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: The axis along which the fixed-point quantization information performed. + + * `quantized_fixed_point_descriptor_list` : `List`[`QuantizedFixedPointDescriptor`], default=[] + + List[QuantizedFixedPointDescriptor]: (a) List length = 1 for all-channel fixed-point quantization parameter, (b) List length > 1 for per-channel fixed-point quantization parameter. + + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** quantized_axis(: [int](https://docs.python.org/3/library/functions.html#int)) +int: The axis along which the fixed-point quantization information performed. + + + +#### **_property_** quantized_fixed_point_descriptor_list(: [List](https://docs.python.org/3/library/typing.html#typing.List)[QuantizedFixedPointDescriptor]) +List[QuantizedFixedPointDescriptor]: (a) List length = 1 for all-channel fixed-point quantization parameter, (b) List length > 1 for per-channel fixed-point quantization parameter. + + + +--- + +### **class** kp.QuantizedFixedPointDescriptor(scale={'dtype': 'DataType.KP_DTYPE_FLOAT32', 'value': 1.0}, radix=0) +Quantization parameters for fixed-point value. + + +* **Attributes** + + * `scale` : `Scale`, default=Scale() + + float: Scale for fixed/floating point conversion. + + * `radix` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Radix for fixed/floating point conversion. + + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** radix(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Radix for fixed/floating point conversion. + + + +#### **_property_** scale(: Scale) +float: Scale for fixed/floating point conversion. + + + +--- + +### **class** kp.Scale(dtype=DataType.KP_DTYPE_FLOAT32, value=1.0) +Scale of Quantization parameter. + + +* **Attributes** + + * `dtype` : [`DataType`](enum.md#kp.DataType), default=DataType.KP_DTYPE_FLOAT32 + + DataType: enum for Kneron data type. + + * `value` : `Union`[`np.int8`, `np.int16`, `np.int32`, `np.int64`, `np.uint8`, `np.uint16`, `np.uint32`, `np.uint64`, `np.float32`, `np.float64`], default=np.float32(1.0) + + float: Scale for fixed/floating point conversion. + + + + +#### **_property_** dtype(: [DataType](enum.md#kp.DataType)) +DataType: enum for Kneron data type. + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** value(: [float](https://docs.python.org/3/library/functions.html#float)) +float: Scale for fixed/floating point conversion. + + + +--- + +### **class** kp.SetupFileSchemaVersion(major=0, minor=0, revision=0) +A setup information file version object. + + +* **Attributes** + + * `major` + + int: Major number. + + * `minor` + + int: Minor number. + + * `revision` + + int: Revision number. + + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** major(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Major number. + + + +#### **_property_** minor(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Minor number. + + + +#### **_property_** revision(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Revision number. + + + +--- + +### **class** kp.SetupSchemaVersion(major=0, minor=0, revision=0) +A setup information schema version object. + + +* **Attributes** + + * `major` + + int: Major number. + + * `minor` + + int: Minor number. + + * `revision` + + int: Revision number. + + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** major(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Major number. + + + +#### **_property_** minor(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Minor number. + + + +#### **_property_** revision(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Revision number. + + + +--- + +### **class** kp.SingleModelDescriptor(target_chip=ModelTargetChip.KP_MODEL_TARGET_CHIP_UNKNOWN, version=0, id=0, input_nodes=[], output_nodes=[], setup_schema_version={'version': '0.0.0'}, setup_file_schema_version={'version': '0.0.0'}, max_raw_out_size=0) +A basic descriptor for a model. + + +* **Attributes** + + * `target_chip` : [`ModelTargetChip`](enum.md#kp.ModelTargetChip), default=KP_MODEL_TARGET_CHIP_UNKNOWN + + ModelTargetChip: Target chip of model. + + * `version` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Version of model. + + * `id` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Model ID. + + * `input_nodes` : `List`[`TensorDescriptor`], default=[] + + List[TensorDescriptor]: List of model input node tensor information. + + * `output_nodes` : `List`[`TensorDescriptor`], default=[] + + List[TensorDescriptor]: List of model output node tensor information. + + * `setup_schema_version` : `SetupSchemaVersion`, default=SetupSchemaVersion() + + SetupSchemaVersion: Schema version of setup. + + * `setup_file_schema_version` : `SetupFileSchemaVersion`, default=SetupFileSchemaVersion() + + SetupFileSchemaVersion: File schema version of setup. + + * `max_raw_out_size` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Needed raw output buffer size for this model. + + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** id(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Model ID. + + + +#### **_property_** input_nodes(: [List](https://docs.python.org/3/library/typing.html#typing.List)[TensorDescriptor]) +List[TensorDescriptor]: List of model input node tensor information. + + + +#### **_property_** max_raw_out_size(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Needed raw output buffer size for this model. + + + +#### **_property_** output_nodes(: [List](https://docs.python.org/3/library/typing.html#typing.List)[TensorDescriptor]) +List[TensorDescriptor]: List of model output node tensor information. + + + +#### **_property_** setup_file_schema_version(: SetupFileSchemaVersion) +SetupFileSchemaVersion: File schema version of setup. + + + +#### **_property_** setup_schema_version(: SetupSchemaVersion) +SetupSchemaVersion: Schema version of setup. + + + +#### **_property_** target_chip(: [ModelTargetChip](enum.md#kp.ModelTargetChip)) +ModelTargetChip: Target chip of model. + + + +#### **_property_** version(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Version of model. + + + +--- + +### **class** kp.SystemInfo(kn_number=0, firmware_version={'firmware_version': '0.0.0-build.0'}) +System Information of Kneron device. + + +* **Attributes** + + * `kn_number` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Unique Kneron device ID. + + * `firmware_version` : `kp.FirmwareVersion`, default=kp.FirmwareVersion() + + kp.FirmwareVersion: Firmware version of Kneron device. + + + + +#### **_property_** firmware_version() +kp.FirmwareVersion: Firmware version of Kneron device. + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** kn_number() +int: Unique Kneron device ID. + + + +--- + +### **class** kp.TensorDescriptor(index=0, name='', data_layout=ModelTensorDataLayout.KP_MODEL_TENSOR_DATA_LAYOUT_UNKNOWN, tensor_shape_info={'version': 'ModelTensorShapeInformationVersion.KP_MODEL_TENSOR_SHAPE_INFO_ ..., quantization_parameters={'version': 'QuantizationParametersVersion.KP_MODEL_QUANTIZATION_PARAMS_VER ...) +Tensor information. + + +* **Attributes** + + * `index` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Index number of the tensor. + + * `name` : [`str`](https://docs.python.org/3/library/stdtypes.html#str), default=’’ + + str: Name of the tensor. + + * `data_layout` : [`ModelTensorDataLayout`](enum.md#kp.ModelTensorDataLayout), default=ModelTensorDataLayout.KP_MODEL_TENSOR_DATA_LAYOUT_UNKNOWN + + ModelTensorDataLayout: NPU data layout of the tensor. + + * `tensor_shape_info` : `TensorShapeInfo`, default=TensorShapeInfo() + + TensorShapeInfo: Tensor shape information. + + * `quantization_parameters` : `QuantizationParameters`, default=QuantizationParameters() + + QuantizationParameters: Quantization parameters of the tensor. + + + + +#### **_property_** data_layout(: [ModelTensorDataLayout](enum.md#kp.ModelTensorDataLayout)) +ModelTensorDataLayout: NPU data layout of the tensor. + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** index(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Index number of the tensor. + + + +#### **_property_** name(: [str](https://docs.python.org/3/library/stdtypes.html#str)) +str: Name of the tensor. + + + +#### **_property_** quantization_parameters(: QuantizationParameters) +QuantizationParameters: Quantization parameters of the tensor. + + + +#### **_property_** tensor_shape_info(: TensorShapeInfo) +TensorShapeInfo: Tensor shape information. + + + +--- + +### **class** kp.TensorShapeInfo(version=ModelTensorShapeInformationVersion.KP_MODEL_TENSOR_SHAPE_INFO_VERSION_1, data={'shape_npu': [], 'shape_onnx': [], 'axis_permutation_onnx_to_npu': []}) +Tensor shape information. + + +* **Attributes** + + * `version` : [`ModelTensorShapeInformationVersion`](enum.md#kp.ModelTensorShapeInformationVersion), default=ModelTensorShapeInformationVersion.KP_MODEL_TENSOR_SHAPE_INFO_VERSION_1 + + ModelTensorShapeInformationVersion: Shape information version (ref. + + * `data` : `Union`[`TensorShapeInfoV1`, `TensorShapeInfoV2`] = `TensorShapeInfoV1` + + Union[TensorShapeInfoV1, TensorShapeInfoV2]: Shape information data. + + + + +#### **_property_** data(: TensorShapeInfoV1 | TensorShapeInfoV2) +Union[TensorShapeInfoV1, TensorShapeInfoV2]: Shape information data. + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** v1(: TensorShapeInfoV1) +TensorShapeInfoV1: Tensor shape information. (version 1) + + + +#### **_property_** v2(: TensorShapeInfoV2) +TensorShapeInfoV2: Tensor shape information. (version 2) + + + +#### **_property_** version(: [ModelTensorShapeInformationVersion](enum.md#kp.ModelTensorShapeInformationVersion)) +ModelTensorShapeInformationVersion: Shape information version (ref. kp_model_tensor_shape_info_version_t). + + + +--- + +### **class** kp.TensorShapeInfoV1(shape_npu=[], shape_onnx=[], axis_permutation_onnx_to_npu=[]) +Tensor shape information. (version 1) + + +* **Attributes** + + * `shape_npu` : `List`[[`int`](https://docs.python.org/3/library/functions.html#int)], default=[] + + List[int]: NPU shape of the tensor (Default dimension order: BxCxHxW). + + * `shape_onnx` : `List`[[`int`](https://docs.python.org/3/library/functions.html#int)], default=[] + + List[int]: ONNX shape of the tensor. + + * `axis_permutation_onnx_to_npu` : `List`[[`int`](https://docs.python.org/3/library/functions.html#int)], default=[] + + List[int]: Remap axis permutation from onnx to npu shape (shape_intrp_dim). + + + + +#### **_property_** axis_permutation_onnx_to_npu(: [List](https://docs.python.org/3/library/typing.html#typing.List)[[int](https://docs.python.org/3/library/functions.html#int)]) +List[int]: Remap axis permutation from onnx to npu shape (shape_intrp_dim). + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** shape_npu(: [List](https://docs.python.org/3/library/typing.html#typing.List)[[int](https://docs.python.org/3/library/functions.html#int)]) +List[int]: NPU shape of the tensor (Default dimension order: BxCxHxW). + + + +#### **_property_** shape_onnx(: [List](https://docs.python.org/3/library/typing.html#typing.List)[[int](https://docs.python.org/3/library/functions.html#int)]) +List[int]: ONNX shape of the tensor. + + + +--- + +### **class** kp.TensorShapeInfoV2(shape=[], stride_onnx=[], stride_npu=[]) +Tensor shape information. (version 2) + + +* **Attributes** + + * `shape` : `List`[[`int`](https://docs.python.org/3/library/functions.html#int)], default=[] + + List[int]: ONNX shape of the tensor. + + * `stride_onnx` : `List`[[`int`](https://docs.python.org/3/library/functions.html#int)], default=[] + + List[int]: Data access stride of ONNX (in scalar). + + * `stride_npu` : `List`[[`int`](https://docs.python.org/3/library/functions.html#int)], default=[] + + List[int]: Data access stride of NPU (in scalar). + + + + +#### get_member_variable_dict() +Represent member variables with Dict format. + + +* **Returns** + + * **ret** : [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + Represent member variables in Dict format. + + + +* **Return type** + + [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) + + + + +#### **_property_** shape(: [List](https://docs.python.org/3/library/typing.html#typing.List)[[int](https://docs.python.org/3/library/functions.html#int)]) +List[int]: ONNX shape of the tensor. + + + +#### **_property_** stride_npu(: [List](https://docs.python.org/3/library/typing.html#typing.List)[[int](https://docs.python.org/3/library/functions.html#int)]) +List[int]: Data access stride of NPU (in scalar). + + + +#### **_property_** stride_onnx(: [List](https://docs.python.org/3/library/typing.html#typing.List)[[int](https://docs.python.org/3/library/functions.html#int)]) +List[int]: Data access stride of ONNX (in scalar). + + diff --git a/docs/plus_python/api_document/index.md b/docs/plus_python/api_document/index.md index 9bd78e9..cda785f 100644 --- a/docs/plus_python/api_document/index.md +++ b/docs/plus_python/api_document/index.md @@ -1,9 +1,10 @@ ## kp API Document * Leatest Version - - [V3.1.0](./V3.1.0/index.md) + - [V3.1.2](./V3.1.2/index.md) * Archive + - [V3.1.0](./V3.1.0/index.md) - [V3.0.0](./V3.0.0/index.md) - [V2.3.0](./V2.3.0/index.md) - [V2.2.0](./V2.2.0/index.md) diff --git a/docs/plus_python/feature_guide/chapter/generic_inference.md b/docs/plus_python/feature_guide/chapter/generic_inference.md index cc5871c..7a4d869 100644 --- a/docs/plus_python/feature_guide/chapter/generic_inference.md +++ b/docs/plus_python/feature_guide/chapter/generic_inference.md @@ -13,7 +13,7 @@ ![](../../imgs/generic_inference_flow.svg) -For **Generic Image Inference API**, images (RGB565, RGBA8888, YUYV422,...) can be provided as the input for the Kneron Device. And Kneron Device provides the automatic hardware image pre-processing including resize, padding, normalization and data re-layout before NPU inference. +For **Generic Image Inference API**, images (RGB565, RGBA8888, YUYV422,...) can be provided as the input for the Kneron Device. And Kneron Device provides the automatic [hardware image preprocessing](./../../../plus_c/appendix/hardware_image_preprocessing.md) including resize, padding, normalization and data re-layout before NPU inference. For **Generic Data Inference API**, data (or images), which is not supported by automatic hardware image pre-processing, can be used as the input for NPU inference, if and only if the data has been performed pre-processing on Host to the format that model requests on NPU. @@ -26,10 +26,12 @@ The pre-processing on Host includes but not limited to: Please refer following sections for according information: -- [Supported Image Format](./../../../plus_c/appendix/supported_image_format.md) for the supported image format of hardware image pre-processing. -- [Supported NPU Data Layout Format (KL520, KL720 and KL630)](./../../../plus_c/appendix/supported_npu_data_layout_format.md) for the NPU layout format. -- [Convert ONNX & NPU Data on the KL730 Platform](./../../../plus_c/appendix/convert_onnx_data_to_npu_data_on_kl730.md) for the KL730 ONNX/NPU data conversion. -- [3.1 Generic Data Inference With Pre-Processing on Host](#31-generic-data-inference-with-pre-processing-on-host) for the demonstration of the pre-processing. +- [Supported Image Format](./../../../plus_c/appendix/supported_image_format.md) for the supported image format of hardware image pre-processing. +- [Supported NPU Data Layout Format (KL520, KL720 and KL630)](./../../../plus_c/appendix/supported_npu_data_layout_format.md) for the KL520, KL720 and KL630 NPU layout format. +- [Supported NPU Data Layout Format (KL730)](./../../../plus_c/appendix/supported_npu_data_layout_format.md) for the KL730 NPU layout format. +- [Hardware Image Preprocessing](./../../../plus_c/appendix/hardware_image_preprocessing.md) for the efficient image preprocessing +- [Convert ONNX & NPU Data on the KL730 Platform](./../../../plus_c/appendix/convert_onnx_data_to_npu_data_on_kl730.md) for the KL730 ONNX/NPU data conversion. +- [3.1 Generic Data Inference With Pre-Processing on Host](#31-generic-data-inference-with-pre-processing-on-host) for the demonstration of the pre-processing. Furthermore, **Generic Inference** provide following functions to retrieve specific output node data (More information please reference *API Reference/Inference API*): @@ -48,7 +50,7 @@ Generic image inference examples are using the **Generic Image Inference API**, However, **Generic Image Inference API** can only provide the raw output from the model without post-processing. If you wish to get the result with post-processing, you may implement the corresponding post-processing in Software (Please refer [2.2 Generic Image Inference With Post-Processing on Host](#22-generic-image-inference-with-post-processing-on-host) for the demonstration). -In **Generic Image Inference API**, you may customized what to do in the pre-processing. There are few items are provided: +In **Generic Image Inference API**, you may customized what to do in the [hardware image preprocessing](./../../../plus_c/appendix/hardware_image_preprocessing.md). There are few items are provided: 1. Image Resize - You can choose to do or not to do the image resize by setting `resize_mode` in `kp.GenericInputNodeImage` of `kp.GenericImageInferenceDescriptor`. @@ -63,6 +65,7 @@ In **Generic Image Inference API**, you may customized what to do in the pre-pro 5. Data Normalization - You can choose to do *Kneron Normalization*, *Tensor Flow Normalization*, *Yolo Normalization*, or other *Customized Normalization* by setting `normalize_mode` in `kp.GenericInputNodeImage` of `kp.GenericImageInferenceDescriptor`. +>The **limitations** for the specified model input NPU format can be found in the [hardware image preprocessing](./../../../plus_c/appendix/hardware_image_preprocessing.md#limitation) documentation. ### 2.1 Generic Image Inference With Raw Output diff --git a/docs/plus_python/introduction/install_dependency.md b/docs/plus_python/introduction/install_dependency.md index 7b37de3..f1f023f 100644 --- a/docs/plus_python/introduction/install_dependency.md +++ b/docs/plus_python/introduction/install_dependency.md @@ -123,6 +123,11 @@ Note: This feature is only provided in Kneron PLUS v1.3.0 and above. - Click "Install Driver" button. + **Note**: If the KL730 device has been sync up to KL730 SDK v1.2.0 or later, and using the KL730 firmware built-in PLUS v3.1.0 or later, this driver installation could be ignored. + + + + ## 3. Update Kneron AI Device USB Permission on Ubuntu/Raspberry Pi * Config USB permission on Ubuntu/Raspberry Pi diff --git a/docs/plus_python/introduction/run_examples.md b/docs/plus_python/introduction/run_examples.md index 07d0347..9f791e4 100644 --- a/docs/plus_python/introduction/run_examples.md +++ b/docs/plus_python/introduction/run_examples.md @@ -20,6 +20,7 @@ The provided examples are designed to show how to use KP APIs and present Kneron 7. [Drop Frame Usage Example](#7-drop-frame-usage-example) 8. [Model Zoo Examples](#8-model-zoo-examples) 9. [Device Memory Usage Control Example](#9-device-memory-usage-control-example) +10. [Get Model Information Example](#10-get-model-information-example) --- @@ -643,3 +644,181 @@ $ python3 KL520DemoGenericImageInferenceFifoqConfig.py ] }] ``` + +## 10. Get Model Information Example + +This example demonstrates how to use `kp.core.load_model_from_file()` to parse the NEF file and retrieve model information from the NEF descriptor `kp.ModelNefDescriptor`. This tool allows you to quickly probe the model metadata. + +```bash +$ python3 ModelInformation.py -t KL520 -p 25 -m ../../res/models/KL520/tiny_yolo_v3/models_520.nef + +[Connect Device] + - Success +[Set Device Timeout] + - Success +[Upload Firmware] + - Success +[Load Model] + - Success +{ + "magic": "0x5AA55AA5", + "metadata": { + "kn_number": "0x0", + "toolchain_version": "kneron_compiler version: 2024-12-02(7b261fd55a)/kneron_nef_utils version: 2025-01-07(d9ea70a);", + "compiler_version": "", + "nef_schema_version": { + "version": "0.0.1" + }, + "platform": "" + }, + "target_chip": "ModelTargetChip.KP_MODEL_TARGET_CHIP_KL520", + "crc": "0x6CBF1FF9", + "models": { + "0": { + "target_chip": "ModelTargetChip.KP_MODEL_TARGET_CHIP_KL520", + "version": "0x1", + "id": 19, + "input_nodes": { + "0": { + "index": 0, + "name": "", + "data_layout": "ModelTensorDataLayout.KP_MODEL_TENSOR_DATA_LAYOUT_4W4C8B", + "tensor_shape_info": { + "version": "ModelTensorShapeInformationVersion.KP_MODEL_TENSOR_SHAPE_INFO_VERSION_1", + "data": { + "shape_npu": [ + 1, + 3, + 224, + 224 + ], + "shape_onnx": [ + 1, + 3, + 224, + 224 + ], + "axis_permutation_onnx_to_npu": [ + 0, + 1, + 2, + 3 + ] + } + }, + "quantization_parameters": { + "version": "QuantizationParametersVersion.KP_MODEL_QUANTIZATION_PARAMS_VERSION_1", + "data": { + "quantized_axis": 1, + "quantized_fixed_point_descriptor_list": { + "0": { + "scale": { + "dtype": "DataType.KP_DTYPE_FLOAT32", + "value": 1.0 + }, + "radix": 8 + } + } + } + } + } + }, + "output_nodes": { + "0": { + "index": 0, + "name": "", + "data_layout": "ModelTensorDataLayout.KP_MODEL_TENSOR_DATA_LAYOUT_16W1C8B", + "tensor_shape_info": { + "version": "ModelTensorShapeInformationVersion.KP_MODEL_TENSOR_SHAPE_INFO_VERSION_1", + "data": { + "shape_npu": [ + 1, + 255, + 7, + 7 + ], + "shape_onnx": [ + 1, + 255, + 7, + 7 + ], + "axis_permutation_onnx_to_npu": [ + 0, + 1, + 2, + 3 + ] + } + }, + "quantization_parameters": { + "version": "QuantizationParametersVersion.KP_MODEL_QUANTIZATION_PARAMS_VERSION_1", + "data": { + "quantized_axis": 1, + "quantized_fixed_point_descriptor_list": { + "0": { + "scale": { + "dtype": "DataType.KP_DTYPE_FLOAT32", + "value": 1.4717674255371094 + }, + "radix": 2 + } + } + } + } + }, + "1": { + "index": 1, + "name": "", + "data_layout": "ModelTensorDataLayout.KP_MODEL_TENSOR_DATA_LAYOUT_16W1C8B", + "tensor_shape_info": { + "version": "ModelTensorShapeInformationVersion.KP_MODEL_TENSOR_SHAPE_INFO_VERSION_1", + "data": { + "shape_npu": [ + 1, + 255, + 14, + 14 + ], + "shape_onnx": [ + 1, + 255, + 14, + 14 + ], + "axis_permutation_onnx_to_npu": [ + 0, + 1, + 2, + 3 + ] + } + }, + "quantization_parameters": { + "version": "QuantizationParametersVersion.KP_MODEL_QUANTIZATION_PARAMS_VERSION_1", + "data": { + "quantized_axis": 1, + "quantized_fixed_point_descriptor_list": { + "0": { + "scale": { + "dtype": "DataType.KP_DTYPE_FLOAT32", + "value": 1.4307060241699219 + }, + "radix": 2 + } + } + } + } + } + }, + "setup_schema_version": { + "version": "0.0.0" + }, + "setup_file_schema_version": { + "version": "0.0.0" + }, + "max_raw_out_size": 86180 + } + } +} +``` diff --git a/docs/plus_python/introduction/upgrade_ai_device_to_kdp2.md b/docs/plus_python/introduction/upgrade_ai_device_to_kdp2.md index c7d153c..60bc7e4 100644 --- a/docs/plus_python/introduction/upgrade_ai_device_to_kdp2.md +++ b/docs/plus_python/introduction/upgrade_ai_device_to_kdp2.md @@ -1,6 +1,6 @@ # Upgrade AI Device to KDP2 Firmware -**Note**: KneronDFUT supports 3 platforms - Windows 10 (x86_64 64-bit), Ubuntu 18.04 (x86_64 64-bit), and Raspberry Pi OS - Buster (armv7l 32-bit) +**Note**: KneronDFUT supports 3 platforms - Windows 10, 11 (x86_64 64-bit) and Ubuntu 18.04 (x86_64 64-bit) **Note**: If you are not using the 3 platforms, you may use the DFUT_console provided in Kneron PLUS. Please refer [Build with DFUT_console](../../plus_c/introduction/build_plus.md#23-build-with-dfutconsole) diff --git a/docs/plus_python/introduction/write_model_to_flash.md b/docs/plus_python/introduction/write_model_to_flash.md index 03d43db..6bdf77f 100644 --- a/docs/plus_python/introduction/write_model_to_flash.md +++ b/docs/plus_python/introduction/write_model_to_flash.md @@ -1,6 +1,6 @@ # Write Model To Flash -**Note**: KneronDFUT supports 3 platforms - Windows 10 (x86_64 64-bit), Ubuntu 18.04 (x86_64 64-bit), and Raspberry Pi OS - Buster (armv7l 32-bit) +**Note**: KneronDFUT supports 3 platforms - Windows 10, 11 (x86_64 64-bit) and Ubuntu 18.04 (x86_64 64-bit) **Note**: If you are not using the 3 platforms, you may use the DFUT_console provided in Kneron PLUS. Please refer [Build with DFUT_console](../../plus_c/introduction/build_plus.md#23-build-with-dfutconsole) diff --git a/docs/plus_python/tutorial/chapter/model_inference_with_data_inference.md b/docs/plus_python/tutorial/chapter/model_inference_with_data_inference.md index e6f09ef..a5bc9c4 100644 --- a/docs/plus_python/tutorial/chapter/model_inference_with_data_inference.md +++ b/docs/plus_python/tutorial/chapter/model_inference_with_data_inference.md @@ -177,7 +177,6 @@ To infer without hardware image preprocessing, the input data must do the follow ``` - For KL730 - > More information about *ONNX/NPU data Conversion for KL730*, please refer to [Convert ONNX & NPU Data on the KL730 Platform](../../../plus_c/appendix/convert_onnx_data_to_npu_data_on_kl730.md) - Get required model/data information diff --git a/mkdocs.yml b/mkdocs.yml index 327b4fc..d8535c8 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -12,6 +12,11 @@ markdown_extensions: - pymdownx.magiclink - pymdownx.superfences - pymdownx.tilde + - pymdownx.arithmatex: + generic: true + +extra_javascript: + - https://unpkg.com/mathjax@3/es5/tex-mml-chtml.js nav: - Kneron AI: index.md @@ -42,6 +47,7 @@ nav: - Create Multiple Model Example for KL720: plus_c/feature_guide/customized_api/create_kl720_multiple_models_example.md - Create Single Model Example for KL730: plus_c/feature_guide/customized_api/create_kl730_single_model_example.md - Create Multiple Model Example for KL730: plus_c/feature_guide/customized_api/create_kl730_multiple_models_example.md + - Create Single Model with Software NPU Format Convert Example for KL730: plus_c/feature_guide/customized_api/create_kl730_single_model_with_sw_npu_format_convert_example.md - NCPU Firmware Configuration: plus_c/feature_guide/customized_api/ncpu_firmware_configuration.md - Run Customized Examples: plus_c/feature_guide/customized_api/run_customized_examples.md - Device DDR Management: plus_c/feature_guide/device_ddr_management.md @@ -55,7 +61,9 @@ nav: - Release Note: - Index: plus_c/release_note/index.md - Version 3: - - V3.1.0 (Latest Version): plus_c/release_note/v3/v3_1_0.md + - V3.1.2 (Latest Version): plus_c/release_note/v3/v3_1_2.md + - V3.1.1: plus_c/release_note/v3/v3_1_1.md + - V3.1.0: plus_c/release_note/v3/v3_1_0.md - V3.0.0: plus_c/release_note/v3/v3_0_0.md - Version 2: - V2.3.0: plus_c/release_note/v2/v2_3_0.md @@ -67,20 +75,28 @@ nav: - V1.3.0: plus_c/release_note/v1/v1_3_0.md - Appendix: - Index: plus_c/appendix/index.md + - API Support List: plus_c/appendix/api_support_list.md - Supported NPU Data Layout Format (KL520, KL720 and KL630): plus_c/appendix/supported_npu_data_layout_format.md - Supported NPU Data Layout Format (KL730): plus_c/appendix/supported_npu_data_layout_format_kl730.md - Convert ONNX & NPU Data on the KL730 Platform: plus_c/appendix/convert_onnx_data_to_npu_data_on_kl730.md + - Hardware Image Preprocessing: plus_c/appendix/hardware_image_preprocessing.md - Supported Image Format: plus_c/appendix/supported_image_format.md - NPU Raw Output Memory Layout: plus_c/appendix/npu_raw_output_memory_layout.md - Yolo Object Name Mapping: plus_c/appendix/yolo_object_name_mapping.md - API Reference: - - v3.1.x: - - Data Structure: plus_c_api/api_reference_3.1.x/kp_struct.h.md - - Core API: plus_c_api/api_reference_3.1.x/kp_core.h.md - - Inference API: plus_c_api/api_reference_3.1.x/kp_inference.h.md - - (legacy)Data Structure: plus_c_api/api_reference_3.1.x/kp_struct_v1.h.md - - (legacy)Inference API: plus_c_api/api_reference_3.1.x/kp_inference_v1.h.md + - v3.1.2: + - Data Structure: plus_c_api/api_reference_3.1.2/kp_struct.h.md + - Core API: plus_c_api/api_reference_3.1.2/kp_core.h.md + - Inference API: plus_c_api/api_reference_3.1.2/kp_inference.h.md + - (legacy)Data Structure: plus_c_api/api_reference_3.1.2/kp_struct_v1.h.md + - (legacy)Inference API: plus_c_api/api_reference_3.1.2/kp_inference_v1.h.md - Archive: + - v3.1.0: + - Data Structure: plus_c_api/api_reference_3.1.0/kp_struct.h.md + - Core API: plus_c_api/api_reference_3.1.0/kp_core.h.md + - Inference API: plus_c_api/api_reference_3.1.0/kp_inference.h.md + - (legacy)Data Structure: plus_c_api/api_reference_3.1.0/kp_struct_v1.h.md + - (legacy)Inference API: plus_c_api/api_reference_3.1.0/kp_inference_v1.h.md - v3.0.x: - Data Structure: plus_c_api/api_reference_3.0.x/kp_struct.h.md - Core API: plus_c_api/api_reference_3.0.x/kp_core.h.md @@ -168,7 +184,18 @@ nav: - Compatible with V1.x API: plus_python/api_migration/chapter/api_compatible_legacy.md - API Document: - Index: plus_python/api_document/index.md - - V3.1.0 (Latest Version): + - V3.1.2 (Latest Version): + - Index: plus_python/api_document/V3.1.2/index.md + - kp.core: plus_python/api_document/V3.1.2/kp/core.md + - kp.inference: plus_python/api_document/V3.1.2/kp/inference.md + - kp value: plus_python/api_document/V3.1.2/kp/value.md + - kp enum: plus_python/api_document/V3.1.2/kp/enum.md + - kp exception: plus_python/api_document/V3.1.2/kp/exception.md + - kp const: plus_python/api_document/V3.1.2/kp/const.md + - kp.v1 (Legacy Module): + - kp.v1.inference: plus_python/api_document/V3.1.2/kp/v1/inference.md + - kp.v1 value: plus_python/api_document/V3.1.2/kp/v1/value.md + - V3.1.0: - Index: plus_python/api_document/V3.1.0/index.md - kp.core: plus_python/api_document/V3.1.0/kp/core.md - kp.inference: plus_python/api_document/V3.1.0/kp/inference.md @@ -245,7 +272,9 @@ nav: - Release Note: - Index: plus_c/release_note/index.md - Version 3: - - V3.1.0 (Latest Version): plus_c/release_note/v3/v3_1_0.md + - V3.1.2 (Latest Version): plus_c/release_note/v3/v3_1_2.md + - V3.1.1: plus_c/release_note/v3/v3_1_1.md + - V3.1.0: plus_c/release_note/v3/v3_1_0.md - V3.0.0: plus_c/release_note/v3/v3_0_0.md - Version 2: - V2.3.0: plus_c/release_note/v2/v2_3_0.md @@ -261,7 +290,9 @@ nav: - Supported NPU Data Layout Format (KL520, KL720 and KL630): plus_c/appendix/supported_npu_data_layout_format.md - Supported NPU Data Layout Format (KL730): plus_c/appendix/supported_npu_data_layout_format_kl730.md - Convert ONNX & NPU Data on the KL730 Platform: plus_c/appendix/convert_onnx_data_to_npu_data_on_kl730.md + - Hardware Image Preprocessing: plus_c/appendix/hardware_image_preprocessing.md - Supported Image Format: plus_c/appendix/supported_image_format.md + - NPU Raw Output Memory Layout: plus_c/appendix/npu_raw_output_memory_layout.md - Yolo Object Name Mapping: plus_c/appendix/yolo_object_name_mapping.md - Firmware SDK: From 7c04c0c0f5cc6fcc7169c4bcec2e070e7d982eb3 Mon Sep 17 00:00:00 2001 From: Andy Huang Date: Mon, 4 Aug 2025 11:03:32 +0800 Subject: [PATCH 2/2] Fix PLUS V3.1.2 Document --- docs/plus_c/appendix/hardware_image_preprocessing.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/plus_c/appendix/hardware_image_preprocessing.md b/docs/plus_c/appendix/hardware_image_preprocessing.md index a8fc059..6217db8 100644 --- a/docs/plus_c/appendix/hardware_image_preprocessing.md +++ b/docs/plus_c/appendix/hardware_image_preprocessing.md @@ -35,13 +35,13 @@ The Kneron's unique features: $$ - We support the following normalization formula template: - $RGB/256 - 0.5,\quad \text{where } RGB \in [0, 255]$ - - Quantization facetor: Radix=8, Scale=1.0 + - Quantization factor: Radix=8, Scale=1.0 - Hardware operation: SUB128 - $RGB/128 - 1.0,\quad \text{where } RGB \in [0, 255]$ - - Quantization facetor: Radix=7, Scale=1.0 + - Quantization factor: Radix=7, Scale=1.0 - Hardware operation: SUB128 - $RGB/256,\quad \text{where } RGB \in [0, 255]$ - - Quantization facetor: Radix=9, Scale=1.0 + - Quantization factor: Radix=7, Scale=1.0 - Hardware operation: DIV2 - Limited NPU format conversion - The Kneron NPU is a hardware accelerator designed specifically for neural networks, enabling efficient data processing that aligns with the hardware's preferred data layout and bit width. In Kneron devices, we offer limited conversions for NPU data layouts to optimize the speed of inference for vision models.