diff --git a/docs/index.md b/docs/index.md index 3910682..8596302 100644 --- a/docs/index.md +++ b/docs/index.md @@ -7,52 +7,55 @@ It is composed of tools, control libraries and example references. ![](./imgs/kneronAI_arch.png) -Kneron AI consists the following components: +Kneron AI consists the following components: -1. **Kneron AI Development Kit - Kneron PLUS** - It is Platform Libraries Unified Software to control Kneron Chip via USB interface - *KL520 SDK v1.6.0 / KL720 SDK v1.4.1 / KL630 SDK v2.5.2, or higher version is required* +1. **Kneron AI Development Kit - Kneron PLUS** + It is Platform Libraries Unified Software to control Kneron Chip via USB interface + *KL520 SDK v1.6.0 / KL720 SDK v1.4.1 / KL630 SDK v2.5.2 / KL730 SDK v1.0.0-alpha, or higher version is required* -2. **Kneron AI Development Kit - Firmware SDK** - Open source for peripheral drivers, middleware and application code can be optimized to meet the needs for different applications - - KL520 SDK - - KL720 SDK +2. **Kneron AI Development Kit - Firmware SDK** + Open source for peripheral drivers, middleware and application code can be optimized to meet the needs for different applications + - KL520 SDK + - KL720 SDK - KL630 SDK - -3. **Kneron AI Development Kit - Kneron Model Toolchain** - A series of utilities for Kneron AI model creation - - ONNX converter - - Compiler - - Quantizer - - Evaluator - - Simulator - -4. **Kneron AI Model Zoo** - A set of structure pre-optimized models used for demo and also open for re-training - -5. **Kneron AI Chips** - - KL520: Dongle, 96board, M.2 board - - KL720: Dongle, 96board + - KL730 SDK + +3. **Kneron AI Development Kit - Kneron Model Toolchain** + A series of utilities for Kneron AI model creation + - ONNX converter + - Compiler + - Quantizer + - Evaluator + - Simulator + +4. **Kneron AI Model Zoo** + A set of structure pre-optimized models used for demo and also open for re-training + +5. **Kneron AI Chips** + - KL520: Dongle, 96board, M.2 board + - KL720: Dongle, 96board - KL630: 96board + - KL730: 96board --- ## Compatibility Table -Versions | KL520 SDK version | KL720 SDK version | KL630 SDK version (NNM version) -:------------------|:------------------|:------------------|:------------------------------- -Kneron PLUS v2.2.x | 2.2.x | 2.2.x | 2.5.5 (1.2.x) -Kneron PLUS v2.1.x | 2.1.x | 2.1.x | 2.5.2 (1.0.x) -Kneron PLUS v2.0.x | 2.0.x | 2.0.x | Not supported -Kneron PLUS v1.3.x | 1.7.x | 1.5.x | Not supported -Kneron PLUS v1.2.x | 1.6.x | 1.4.x | Not supported -host_lib v1.0.0 | 1.5.0.0 | 1.3.0 | Not supported -host_lib v0.9.x | 1.4.0.x | Not supported | Not supported - -**Notes:** +Versions | KL520 SDK version | KL720 SDK version | KL630 SDK version (NNM version) | KL730 SDK version +:------------------------|:------------------|:------------------|:------------------------------- | :---------------- +Kneron PLUS v2.3.x-alpha | 2.2.x | 2.2.x | 2.5.5 (1.2.x) | 1.0.0-alpha +Kneron PLUS v2.2.x | 2.2.x | 2.2.x | 2.5.5 (1.2.x) | Not supported +Kneron PLUS v2.1.x | 2.1.x | 2.1.x | 2.5.2 (1.0.x) | Not supported +Kneron PLUS v2.0.x | 2.0.x | 2.0.x | Not supported | Not supported +Kneron PLUS v1.3.x | 1.7.x | 1.5.x | Not supported | Not supported +Kneron PLUS v1.2.x | 1.6.x | 1.4.x | Not supported | Not supported +host_lib v1.0.0 | 1.5.0.0 | 1.3.0 | Not supported | Not supported +host_lib v0.9.x | 1.4.0.x | Not supported | Not supported | Not supported + +**Notes:** **Host API v1.0.0(host_lib)** *stays with [KL520 SDK v1.5.0.0](./520_1.5.0.0/getting_start.md) / [KL720 SDK v1.3.0](./720_1.3.0/getting_start_720.md) and deprecated from KL520 SDK v1.6.0/KL720 SDK v1.4.1* --- -## First Touch +## First Touch **Kneron PLUS** provides low barrier AI inference experience to touch AI. @@ -61,11 +64,9 @@ Please see [Kneron PLUS-C - Getting Started](./plus_c/getting_started.md) \(or [ --- ## References - - [Kneron PLUS-C](./plus_c/introduction/introduction.md) / [Kneron PLUS-Python](./plus_python/introduction/index.md) + - [Kneron PLUS-C](./plus_c/introduction/introduction.md) / [Kneron PLUS-Python](./plus_python/introduction/index.md) - [Firmware KL520 SDK](./520_2.2.0/introduction.md) - [Firmware KL720 SDK](./720_2.2.0/introduction.md) - [Kneron Model Toolchain](./toolchain/manual_1_overview.md) - [Model Zoo - C-examples](./plus_c/modelzoo/index.md) / [Python-examples](./plus_python/modelzoo/index.md) - [Model Zoo - retraining](./model_training/classification.md) - - diff --git a/docs/plus_c/appendix/npu_raw_output_memory_layout.md b/docs/plus_c/appendix/npu_raw_output_memory_layout.md index 3ed7d21..21fbfad 100644 --- a/docs/plus_c/appendix/npu_raw_output_memory_layout.md +++ b/docs/plus_c/appendix/npu_raw_output_memory_layout.md @@ -10,5 +10,7 @@ In **KL630**, the data values are in (channel, height, width_align) format, wher In **KL720**, the data values are in (channel, height, width_align) format, where width_align is the width aligned to the nearest 16 bytes (NPU data layout format: 16W1C8B). -- For example, assume the output node shape is 1x4x12x12 (BxCxHxW). The NPU raw output node data will be arranged as: +In **KL730**, the data values are in (channel, height, width_align) format, where width_align is the width aligned to the nearest 16 bytes (NPU data layout format: 16W1C8B). + +- For example, assume the output node shape is 1x4x12x12 (BxCxHxW). The NPU raw output node data will be arranged as: ![](../imgs/customized_api_post_proc_mem_layout.png) diff --git a/docs/plus_c/appendix/supported_npu_data_layout_format.md b/docs/plus_c/appendix/supported_npu_data_layout_format.md index 8aea2c7..8fb7966 100644 --- a/docs/plus_c/appendix/supported_npu_data_layout_format.md +++ b/docs/plus_c/appendix/supported_npu_data_layout_format.md @@ -28,7 +28,7 @@ To infer by Kneron NPU, the input/output data must be re-layout by the following | 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 | -2. **KL720** +2. **KL630, KL720 and KL630** - Input Data Layout - **4W4C8B** - 4 Column 4 Channel 8-Bit Feature Map Format diff --git a/docs/plus_c/feature_guide/customized_api/create_kl730_multiple_models_example.md b/docs/plus_c/feature_guide/customized_api/create_kl730_multiple_models_example.md new file mode 100644 index 0000000..a4dd90a --- /dev/null +++ b/docs/plus_c/feature_guide/customized_api/create_kl730_multiple_models_example.md @@ -0,0 +1,708 @@ +# Create KL730 Multiple Models Example + + +--- + +## 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}/03_SDK/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_mul_example folder + + ```bash + $ cd {PLUS_FOLDER_PATH}/examples/ + $ mkdir my_KL730_mul_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_mul_example.h* + + - Please define the customized **header** structure and customized **result** structure in this file. + + - Header (my_KL730_mul_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_mul_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_MUL_EXAMPLE_JOB_ID 4003 + #define PD_BOX_MAX 80 + + /** + * @brief describe a pedestrian detect classification result of one detected person + */ + typedef struct + { + float pd_class_socre; /**< a pedestrian classification score */ + kp_bounding_box_t pd; /**< a pedestrian box information */ + } __attribute__((aligned(4))) one_pd_classification_result_t; + + /** + * @brief describe a pedestrian detect classification output result + */ + typedef struct + { + uint32_t box_count; /**< boxes of all classes */ + one_pd_classification_result_t pds[PD_BOX_MAX]; /**< pedestrian detect information */ + } __attribute__((aligned(4))) pd_classification_result_t; + + typedef struct + { + /* header stamp is necessary for data transfer between host and device */ + kp_inference_header_stamp_t header_stamp; + uint32_t width; + uint32_t height; + } __attribute__((aligned(4))) my_KL730_mul_example_header_t; + + // result (header + data) for 'Customize Inference Multiple Models' + typedef struct + { + /* header stamp is necessary for data transfer between host and device */ + kp_inference_header_stamp_t header_stamp; + pd_classification_result_t pd_classification_result; + } __attribute__((aligned(4))) my_KL730_mul_example_result_t; + + ``` + +4. Add *my_KL730_mul_example.c* + + - There are 5 steps for inferencing in Kneron AI device: + + 1. Connect Kneron AI device. + + 2. Upload the model to AI device. + + 3. Prepare data for the header. + + 4. Send the header and image buffer to SCPU firmware via **kp_customized_inference_send()**. + + 5. Receive the result from SCPU 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_mul_example.h" + + static char _scpu_fw_path[128] = "../../res/firmware/KL730/kp_firmware.tar"; + static char _model_file_path[128] = "../../res/models/KL730/YoloV5s480_256_3_pdc/models_730.nef"; + static char _image_file_path[128] = "../../res/images/travel_walk_480x256.bmp"; + static int _loop = 10; + + int main(int argc, char *argv[]) + { + kp_device_group_t device; + kp_model_nef_descriptor_t model_desc; + + // each device has a unique port ID, 0 for auto-search + int port_id = (argc > 1) ? atoi(argv[1]) : 0; + int ret; + + /******* connect the device *******/ + { + // 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("error ! 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("error ! upload firmware failed, error = %d (%s)\n", ret, kp_error_string(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 (KP_SUCCESS != ret) { + printf("error ! 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("error ! 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_mul_example_header_t input_header; + my_KL730_mul_example_result_t output_result; + pd_classification_result_t* pd_classification_result = &output_result.pd_classification_result; + + input_header.header_stamp.job_id = MY_KL730_MUL_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_mul_example_header_t); + int image_size = img_width * img_height * 2; // RGB565 + int result_size = sizeof(my_KL730_mul_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 (KP_SUCCESS != ret) { + printf("\ninference failed, error = %d\n", ret); + break; + } + + ret = kp_customized_inference_receive(device, (void *)&output_result, result_size, &recv_size); + + if (KP_SUCCESS != ret) { + printf("\ninference failed, error = %d\n", ret); + break; + } + + printf("\n[loop %d]\n", i + 1); + + for (int j = 0; j < pd_classification_result->box_count; j++) { + printf("Box %d (x1, y1, x2, y2, class, score, pb score) = (%d, %d), (%d, %d), %d, %f, %f\n", + j + 1, + (int)pd_classification_result->pds[j].pd.x1, + (int)pd_classification_result->pds[j].pd.y1, + (int)pd_classification_result->pds[j].pd.x2, + (int)pd_classification_result->pds[j].pd.y2, + (int)pd_classification_result->pds[j].pd.class_num, + pd_classification_result->pds[j].pd.score, + pd_classification_result->pds[j].pd_class_score); + } + } + + printf("\n"); + + free(img_buf); + kp_release_model_nef_descriptor(&model_desc); + kp_disconnect_devices(device); + + return 0; + } + ``` + +--- + +## 3. Firmware Development for pedestrian detection + pedestrian classification + +**Note**: For further information of KL730 VMF_NNM, please refer **Vienna_NNM_Programming_Guide.pdf** in {KL730_SDK_TOP_FOLDER_PATH}/03_SDK/01_Documents/ + +1. Go to App Flow Folder {KL730_SDK_FOLDER_PATH}/apps/vmf_nnm/solution/app_flow + +2. Add *my_KL730_mul_example_inf.h* into include folder + + - The content of this file should be synchronized with **my_KL730_mul_example.h** in PLUS. + + ```cpp + #include "kp_struct.h" + #include "model_res.h" + + #define MY_KL730_MUL_EXAMPLE_JOB_ID 4003 + #define PD_BOX_MAX 80 + + /** + * @brief describe a pedestrian detect classification result of one detected person + */ + typedef struct + { + float pd_class_socre; /**< a pedestrian classification score */ + kp_bounding_box_t pd; /**< a pedestrian box information */ + } __attribute__((aligned(4))) one_pd_classification_result_t; + + /** + * @brief describe a pedestrian detect classification output result + */ + typedef struct + { + uint32_t box_count; /**< boxes of all classes */ + one_pd_classification_result_t pds[DME_OBJECT_MAX]; /**< pedestrian detect information */ + } __attribute__((aligned(4))) pd_classification_result_t; + + typedef struct + { + /* header stamp is necessary for data transfer between host and device */ + kp_inference_header_stamp_t header_stamp; + uint32_t width; + uint32_t height; + } __attribute__((aligned(4))) my_KL730_mul_example_header_t; + + // result (header + data) for 'Customize Inference Multiple Models' + typedef struct + { + /* header stamp is necessary for data transfer between host and device */ + kp_inference_header_stamp_t header_stamp; + pd_classification_result_t pd_classification_result; + } __attribute__((aligned(4))) my_KL730_mul_example_result_t; + + void my_KL730_mul_example_inf(int job_id, int num_input_buf, void **inf_input_buf_list); + ``` + +3. Add *my_KL730_mul_example_inf.c* + + - There are 8 steps for inferencing in pedestrian detect model and pedestrian classification model: + + 1. Prepare the memory space for the result. + + 2. Prepare header of output result. + + 3. Prepare the temporary memory space for the result of middle model via **calloc()** + + 4. Prepare **VMF_NNM_INFERENCE_APP_CONFIG_T** for pedestrian detect model, which is used for configure the inference in NCPU firmware. + + 5. Activate NCPU firmware for pedestrian detect model via **VMF_NNM_Inference_App_Execute()**. + + 6. Prepare **VMF_NNM_INFERENCE_APP_CONFIG_T** for pedestrian classification model. + + 7. Activate NCPU firmware for pedestrian classification model via **VMF_NNM_Inference_App_Execute()**. + + 8. 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. + + - The inference result of NCPU 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 **pd_result** for pedestrian detect model, and **imagenet_result** for pedestrian classification model.) + + - For the detail of **VMF_NNM_INFERENCE_APP_CONFIG_T**, please refer to section [NCPU Firmware Configuration](./ncpu_firmware_configuration.md) + + ```cpp + #include + #include + #include + #include + + #include "model_type.h" + #include "vmf_nnm_inference_app.h" + #include "vmf_nnm_fifoq_manager.h" + #include "demo_customize_inf_multiple_models.h" + #include "vmf_nnm_post_proc.h" + #include "vmf_nnm_pre_post_proc_params.h" + + // for pedestrian detection result, should be in DDR + static struct yolo_result_s *_yolo_pd_result = NULL; + static struct classifier_result_s *_classifier_result = NULL; + + /** + * @brief describe class labels of pedestrian detection results. + */ + typedef enum { + KP_APP_PD_CLASS_PERSON = 0, + KP_APP_PD_CLASS_BICYCLE = 1, + KP_APP_PD_CLASS_CAR = 2, + KP_APP_PD_CLASS_MOTORCYCLE = 3, + KP_APP_PD_CLASS_BUS = 4, + KP_APP_PD_CLASS_TRUCK = 5, + KP_APP_PD_CLASS_CAT = 6, + KP_APP_PD_CLASS_DOG = 7 + } kp_app_pd_class_t; + + static VMF_NNM_PRE_POST_PROC_PARAMS_YOLO_t post_proc_params_v5s = { + .prob_thresh = 0.3, + .nms_thresh = 0.65, + .max_detection_per_class = 20, + .anchor_row = 3, + .anchor_col = 6, + .stride_size = 3, + .reserved_size = 0, + .data = { + // anchors[3][6] + 10, 13, 16, 30, 33, 23, + 30, 61, 62, 45, 59, 119, + 116, 90, 156, 198, 373, 326, + // strides[3] + 8, 16, 32, + }, + }; + + static bool init_temp_buffer() + { + // allocate DDR memory for ncpu/npu output restult + _yolo_pd_result = (struct yolo_result_s *)calloc(1, sizeof(struct yolo_result_s)); + if (NULL == _yolo_pd_result) + return false; + + _classifier_result = (struct classifier_result_s *)calloc(1, sizeof(struct classifier_result_s)); + if (NULL == _classifier_result) + return false; + + return true; + } + + static int inference_pedestrian_detection(my_KL730_mul_example_header_t *_input_header, + struct yolo_result_s *_pd_result /* output */) + { + // 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)); // for safety let default 'bool' to 'false' + + // image buffer address should be just after the header + inf_config.num_image = 1; + inf_config.image_list[0].image_buf = (void *)((uint32_t)_input_header + sizeof(my_KL730_mul_example_header_t)); + inf_config.image_list[0].image_width = _input_header->width; + inf_config.image_list[0].image_height = _input_header->height; + inf_config.image_list[0].image_channel = 3; // assume RGB565 + inf_config.image_list[0].image_format = KP_IMAGE_FORMAT_RGB565; // default: 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; // default: enable resize + inf_config.image_list[0].image_padding = KP_PADDING_CORNER; // default: enable padding on corner + inf_config.model_id = KNERON_YOLOV5S_PersonBicycleCarMotorcycleBusTruckCatDog8_256_480_3; // this depends on model + inf_config.user_define_data = (void *)&post_proc_params_v5s; // yolo post-process configurations for yolo v5 series + inf_config.post_proc_func = VMF_NNM_Post_Proc_Yolov5_No_Sigmoid; + + // set up fd result output buffer for ncpu/npu + inf_config.ncpu_result_buf = (void *)_pd_result; + + return VMF_NNM_Inference_App_Execute(&inf_config); + } + + static int inference_pedestrian_classification(my_KL730_mul_example_header_t *_input_header, + struct bounding_box_s *_box, + struct classifier_result_s * _imagenet_result/* output */) + { + // 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)); // for safety let default 'bool' to 'false' + + int32_t left = (int32_t)(_box->x1); + int32_t top = (int32_t)(_box->y1); + int32_t right = (int32_t)(_box->x2); + int32_t bottom = (int32_t)(_box->y2); + + // image buffer address should be just after the header + inf_config.num_image = 1; + inf_config.image_list[0].image_buf = (void *)((uint32_t)_input_header + sizeof(my_KL730_mul_example_header_t)); + inf_config.image_list[0].image_width = _input_header->width; + inf_config.image_list[0].image_height = _input_header->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; // default: enable resize + inf_config.image_list[0].image_padding = KP_PADDING_DISABLE; // default: disable padding + inf_config.image_list[0].enable_crop = true; // enable crop image in ncpu/npu + + // set crop box + inf_config.image_list[0].crop_area.crop_number = 0; + inf_config.image_list[0].crop_area.x1 = left; + inf_config.image_list[0].crop_area.y1 = top; + inf_config.image_list[0].crop_area.width = right - left; + inf_config.image_list[0].crop_area.height = bottom - top; + + inf_config.model_id = KNERON_PERSONCLASSIFIER_MB_56_48_3; // this depends on model + inf_config.post_proc_func = VMF_NNM_Post_Proc_Classifier; + + // set up fd result output buffer for ncpu/npu + inf_config.ncpu_result_buf = (void *)_classifier_result; + + return VMF_NNM_Inference_App_Execute(&inf_config); + } + + void my_KL730_mul_example_inf(int job_id, int num_input_buf, void **inf_input_buf_list) + { + if (1 != num_input_buf) { + VMF_NNM_Fifoq_Manager_Status_Code_Enqueue(job_id, KP_FW_WRONG_INPUT_BUFFER_COUNT_110); + return; + } + + int inf_status; + int result_buf_size; + uint32_t inf_result_buf; + uint32_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_mul_example_header_t *input_header = (my_KL730_mul_example_header_t *)inf_input_buf_list[0]; + my_KL730_mul_example_result_t *output_result = (my_KL730_mul_example_result_t *)inf_result_buf; + + + /******* Prepare header of output result *******/ + + output_result->header_stamp.magic_type = KDP2_MAGIC_TYPE_INFERENCE; + output_result->header_stamp.total_size = sizeof(my_KL730_mul_example_result_t); + output_result->header_stamp.job_id = job_id; + + /******* Prepare the temporary memory space for the result of middle model *******/ + + static bool is_init = false; + + if (!is_init) { + int status = init_temp_buffer(); + if (!status) { + // notify host error ! + output_result->header_stamp.status_code = KP_FW_DDR_MALLOC_FAILED_102; + VMF_NNM_Fifoq_Manager_Result_Enqueue(inf_result_buf, inf_result_phy_addr, result_buf_size, -1, false); + return; + } + + is_init = true; + } + + /******* Run face detect model *******/ + inf_status = inference_pedestrian_detection(input_header, _yolo_pd_result); + if (inf_status != KP_SUCCESS) { + // notify host error ! + output_result->header_stamp.status_code = inf_status; + VMF_NNM_Fifoq_Manager_Result_Enqueue(inf_result_buf, inf_result_phy_addr, result_buf_size, -1, false); + return; + } + + int box_count = 0; + int max_box_count = (pd_result->box_count > PD_BOX_MAX) ? PD_BOX_MAX : _yolo_pd_result->box_count; + pd_classification_result_t *pd_result = &output_result->pd_classification_result; + + for (int i = 0; i < max_box_count; i++) { + struct bounding_box_s *box = &_yolo_pd_result->boxes[i]; + + if (KP_APP_PD_CLASS_PERSON == box->class_num) { + // do face landmark for each faces + inf_status = inference_pedestrian_classification(input_header, box, _classifier_result); + + if (KP_SUCCESS != inf_status) { + // notify host error ! + output_result->header_stamp.status_code = inf_status; + VMF_NNM_Fifoq_Manager_Result_Enqueue(inf_result_buf, inf_result_phy_addr, result_buf_size, -1, false); + return; + } + + // pedestrian_imagenet_classification result (class 0 : background, class 1: person) + pd_result->pds[box_count].pd_class_score = _classifier_result->score[1]; + } + else{ + pd_result->pds[box_count].pd_class_score = 0; + } + + memcpy(&pd_result->pds[box_count].pd, box, sizeof(kp_bounding_box_t)); + box_count++; + } + + pd_result->box_count = box_count; + + output_result->header_stamp.status_code = KP_SUCCESS; + output_result->header_stamp.total_size = sizeof(my_KL730_mul_example_result_t) - sizeof(pd_classification_result_t) + + sizeof(pd_result->box_count) + (box_count * sizeof(one_pd_classification_result_t)); + // 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); + } + ``` + +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 coresponding 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_MUL_EXAMPLE_JOB_ID** and corespond the switch case to **my_KL730_mul_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_mul_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_MUL_EXAMPLE_JOB_ID: + my_KL730_mul_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; + } + } + + 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) + { + 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-for-pedestrian-detection--pedestrian-classification). + + - 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/create_kl730_single_model_example.md b/docs/plus_c/feature_guide/customized_api/create_kl730_single_model_example.md new file mode 100644 index 0000000..5d71d3c --- /dev/null +++ b/docs/plus_c/feature_guide/customized_api/create_kl730_single_model_example.md @@ -0,0 +1,530 @@ +# Create KL730 Single Model Example + +--- + +## 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}/03_SDK/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_example folder + + ```bash + $ cd {PLUS_FOLDER_PATH}/examples/ + $ mkdir my_KL730_sin_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_example.h* + + - Please define the customized **header** structure and customized **result** structure in this file. + + - Header (my_KL730_sin_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_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_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_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_example_header_t; + + typedef struct { + /* header stamp is necessary */ + kp_inference_header_stamp_t header_stamp; + + my_KL730_sin_example_yolo_result_t yolo_result; + } __attribute__((aligned(4))) my_KL730_sin_example_result_t; + ``` + +4. Add *my_KL730_sin_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_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_example_header_t input_header; + my_KL730_sin_example_result_t output_result; + + input_header.header_stamp.job_id = MY_KL730_SIN_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_example_header_t); + int image_size = img_width * img_height * 2; // RGB565 + int result_size = sizeof(my_KL730_sin_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 **Vienna_NNM_Programming_Guide.pdf** in {KL730_SDK_TOP_FOLDER_PATH}/03_SDK/01_Documents/ + +1. Go to App Flow Folder {KL730_SDK_FOLDER_PATH}/apps/vmf_nnm/solution/app_flow + +2. Add *my_KL730_sin_example_inf.h* into include folder + + - The content of this file should be synchronized with **my_KL730_sin_example.h** in PLUS. + + ```cpp + #include "kp_struct.h" + + #define MY_KL730_SIN_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_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_example_header_t; + + typedef struct { + /* header stamp is necessary */ + kp_inference_header_stamp_t header_stamp; + + my_KL730_sin_example_yolo_result_t yolo_result; + } __attribute__((aligned(4))) my_KL730_sin_example_result_t; + + void my_KL730_sin_example_inf(uint32_t job_id, void *inf_input_buf); + ``` + +3. Add *my_KL730_sin_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_example_inf.h" + #include "yolov5_post_process.h" + + static yolo_post_proc_params_t post_proc_params_v5s = { + .prob_thresh = 0.15, + .nms_thresh = 0.5, + .max_detection_per_class = 20, + .anchor_row = 3, + .anchor_col = 6, + .stride_size = 3, + .reserved_size = 0, + .data = { + // anchors[3][6] + 10, 13, 16, 30, 33, 23, + 30, 61, 62, 45, 59, 119, + 116, 90, 156, 198, 373, 326, + // strides[3] + 8, 16, 32, + }, + }; + + void my_KL730_sin_example_inf(uint32_t job_id, int num_input_buf, void **inf_input_buf_list) + { + 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; + uint32_t inf_result_buf; + uint32_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_example_header_t *input_header = (my_KL730_sin_example_header_t *)inf_input_buf_list[0]; + my_KL730_sin_example_result_t *output_result = (my_KL730_sin_example_result_t *)inf_result_buf; + + /******* Prepare the configuration *******/ + + VMF_NNM_INFERENCE_APP_CONFIG_T inf_config; + + // Set the initial value of config to 0, false and NULL + 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 *)((uint32_t)input_header + sizeof(my_KL730_sin_example_header_t)); + inf_config.image_list[0].image_width = input_header->width; + inf_config.image_list[0].image_height = input_header->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 + inf_config.ncpu_result_buf = (void *)&(output_result->yolo_result); // give result buffer for ncpu/npu, callback will carry it + inf_config.user_define_data = (void *)&post_proc_params_v5s; // yolo post-process configurations for yolo v3 series + inf_config.post_proc_func = yolov5_no_sigmoid_post_process; // yolo post-process function + + /******* Activate inferencing in NCPU *******/ + + int inf_status = 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_example_result_t); + output_result->header_stamp.job_id = job_id; + output_result->header_stamp.status_code = inf_status; + + // 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); + } + ``` + +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 coresponding 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_EXAMPLE_JOB_ID** and corespond the switch case to **my_KL730_sin_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_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_EXAMPLE_JOB_ID: + my_KL730_sin_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; + } + } + + 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) + { + 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 53f0d99..a017900 100644 --- a/docs/plus_c/feature_guide/customized_api/index.md +++ b/docs/plus_c/feature_guide/customized_api/index.md @@ -10,6 +10,8 @@ Documents in **Customized API** explain the usage of create customized API in So - [Create Multiple Model Example for KL630](./create_kl630_multiple_models_example.md) - [Create Single Model Example for KL720](./create_kl720_single_model_example.md) - [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) - [NCPU Firmware Configuration](./ncpu_firmware_configuration.md) - [Run Customized Examples](./run_customized_examples.md) diff --git a/docs/plus_c/feature_guide/customized_api/install_dependency.md b/docs/plus_c/feature_guide/customized_api/install_dependency.md index 58b9680..e9a21be 100644 --- a/docs/plus_c/feature_guide/customized_api/install_dependency.md +++ b/docs/plus_c/feature_guide/customized_api/install_dependency.md @@ -33,6 +33,14 @@ the developing of customized api must be proceeded under OS Windows 10. - Only required when developing firmware for KL630 - - Download the latest **KL630_SDK_vXXX.zip** from . It is located at **KL620 SDK** section. + - Download the latest **KL630_SDK_vXXX.zip** from . It is located at **KL630 SDK** section. - Unzip KL630_SDK_vXXX.zip - Please refer KLM5S3_Development_Environment_User_Guide.pdf in {KL630_SDK_TOP_FOLDER_PATH}/02_BSP/01_Documents + +5. **Cross Compiler for KL730** + + - Only required when developing firmware for KL730 + + - Download the latest **KL730_SDK_vXXX.zip** from . It is located at **KL730 SDK** section. + - Unzip KL730_SDK_vXXX.zip + - Please refer KLM5S3_Development_Environment_User_Guide.pdf in {KL730_SDK_TOP_FOLDER_PATH}/02_BSP/01_Documents diff --git a/docs/plus_c/feature_guide/customized_api/ncpu_firmware_configuration.md b/docs/plus_c/feature_guide/customized_api/ncpu_firmware_configuration.md index 62d058d..8b672a0 100644 --- a/docs/plus_c/feature_guide/customized_api/ncpu_firmware_configuration.md +++ b/docs/plus_c/feature_guide/customized_api/ncpu_firmware_configuration.md @@ -1,6 +1,6 @@ # Firmware Configuration -When SCPU activates NCPU to run models, **kmdw_inference_app_config_t** (KL520/KL720) or **VMF_NNM_INFERENCE_APP_CONFIG_T** (KL630), which contains configurations of NCPU, is required to pass to NCPU. +When SCPU activates NCPU to run models, **kmdw_inference_app_config_t** (KL520/KL720) or **VMF_NNM_INFERENCE_APP_CONFIG_T** (KL630/KL730), which contains configurations of NCPU, is required to pass to NCPU. **kmdw_inference_app_config_t** and **VMF_NNM_INFERENCE_APP_CONFIG_T** contain following configurable options: @@ -77,7 +77,7 @@ When SCPU activates NCPU to run models, **kmdw_inference_app_config_t** (KL520/K - **result_callback**: - type [KL520/KL720]: kmdw_inference_result_callback_t - - type [KL630]: VMF_NNM_INFERENCE_APP_RESULT_CALLBACK_T + - type [KL630/KL730]: VMF_NNM_INFERENCE_APP_RESULT_CALLBACK_T - The callback function for parallel mode - **inf_result_buf**: @@ -93,14 +93,22 @@ When SCPU activates NCPU to run models, **kmdw_inference_app_config_t** (KL520/K - type: kp_pad_value_t* - The pad_value for the pre-processing in NCPU. -- **user_define_data** +- **user_define_data** (KL520/KL720/KL630) + - type: void* + - The user define data for the pre-processing and post-processing in NCPU. + +- **pre_proc_config** (KL730) - type: void* - The user define data for the pre-processing in NCPU. -- **pre_proc_func** - - type [KL630]: void* +- **post_proc_config** (KL730) + - type: void* + - The user define data for the post-processing in NCPU. + +- **pre_proc_func** (KL630/KL730) + - type: void* - The pointer for the customized pre-processing function. -- **post_proc_func** - - type [KL630]: void* +- **post_proc_func** (KL630/KL730) + - type: void* - The pointer for the customized post-processing function. diff --git a/docs/plus_c/feature_guide/customized_api/run_customized_examples.md b/docs/plus_c/feature_guide/customized_api/run_customized_examples.md index e806786..cfa33ea 100644 --- a/docs/plus_c/feature_guide/customized_api/run_customized_examples.md +++ b/docs/plus_c/feature_guide/customized_api/run_customized_examples.md @@ -125,6 +125,17 @@ $ bash build.sh debug *If build succeeded, **fw_ncpu.bin** will be put into {PLUS_FOLDER_PATH}/res/firmware/KL720/ +### 1.6 KL730 Firmware + +```bash +$ cd {KL730_SDK_FOLDER_PATH}/apps/vmf_nnm +$ bash build.sh +``` + +*If build succeeded, **kp_firmware.tar** will be put into {KL730_SDK_FOLDER_PATH}/apps/vmf_nnm/bin/ + +*For further information of building firmware of KL730, please refer **Leipzig_NNM_Example_User_Guide.pdf** in {KL730_SDK_TOP_FOLDER_PATH}/03_SDK/01_Documents/ + --- ## 2. Build PLUS @@ -184,3 +195,16 @@ $ sudo ./my_kl720_sin_example.exe $ cd bin $ sudo ./my_kl720_mul_example.exe ``` +### 2.7 Run KL730 Single Model Example + +```bash +$ cd bin +$ sudo ./my_kl730_sin_example.exe +``` + +### 2.8 Run KL730 Multiple Models Example + +```bash +$ cd bin +$ sudo ./my_kl730_mul_example.exe +``` diff --git a/docs/plus_c/feature_guide/generic_inference.md b/docs/plus_c/feature_guide/generic_inference.md index e2b4d52..df29d63 100644 --- a/docs/plus_c/feature_guide/generic_inference.md +++ b/docs/plus_c/feature_guide/generic_inference.md @@ -6,7 +6,7 @@ **Note**: To execute **MSYS2 MinGW 64-bit**, please use the shortcut or `c:\msys64\msys2_shell.cmd -mingw64` instead of `c:\msys64\mingw64.exe`. -**Note**: In the inference related examples, we are using KL520 for most demo. If you wish to use KL630 or KL720, just change the prefix of the example name from kl520 to kl630 or kl720. (There might be no KL520 version, KL630 version or KL720 version on certain examples.) +**Note**: In the inference related examples, we are using KL520 for most demo. If you wish to use KL630, KL720, or KL730, just change the prefix of the example name from kl520 to kl630, kl720, or kl730. (There might be no KL520 version, KL630 version, KL720 version or KL730 version on certain examples.) **Note**: Few examples will auto connect multiple devices to run inference. If you put hybrid types of devices on host, the inference may fail. diff --git a/docs/plus_c/getting_started.md b/docs/plus_c/getting_started.md index f2afe94..628c90a 100644 --- a/docs/plus_c/getting_started.md +++ b/docs/plus_c/getting_started.md @@ -76,6 +76,15 @@ $ sudo sh KneronDFUT.sh --help --port : [argument required] port id set ("all" or specified multiple port ids "13,537") --scpu : [argument required] self pointed firmware file path (.tar) +[Update dongles to usb boot] (Only works for KL730) + --kl730-usb-boot : [no argument] choose update to Usb Boot + --port : [argument required] port id set ("all" or specified multiple port ids "13,537") + +[Update dongles to usb boot] (Only works for KL730) + --kl730-flash-boot : [no argument] choose update to Flash Boot + --port : [argument required] port id set ("all" or specified multiple port ids "13,537") + --scpu : [argument required] self pointed firmware file path (.tar) + [Update firmware file to flash memory in dongles] (Only works for KL720) --kl720-update : [no argument] choose write firmware to flash memory --port : [argument required] port id set ("all" or specified multiple port ids "13,537") @@ -84,7 +93,7 @@ $ sudo sh KneronDFUT.sh --help [Update model file to flash memory in dongles] --model-to-flash : [argument required] self pointed model file path (.nef) - --type : [argument required] type of device ("KL520", "KL630", or "KL720") + --type : [argument required] type of device ("KL520", "KL630", "KL720", or "KL730") --port : [argument required] port id set ("all" or specified multiple port ids "13,537") [Enable Graphic User Interface] @@ -230,6 +239,50 @@ $ sudo sh KneronDFUT.sh --help ==== Update Firmware to Device with Port Id: 262 Succeeded ==== ``` +### 2.4 KL730 + +1. Use GUI to Update AI Device + + ```bash + $ sudo sh KneronDFUT.sh + ``` + + * Select the AI device to be update to KDP2 firmware + + * Push **Run** button + \(**Update to USB Boot** should be checked by default\) + + ![](./imgs/dfut_kl730_usb_boot.png) + +2. Use Command Line to Update AI Device + + ```bash + $ sudo sh KneronDFUT.sh --list + ``` + + ```bash + =========================================== + Index: 1 + Port Id: 13 + Kn Number: 0x19611034 + Device Type: KL730 + FW Type: KDP2 + Usb Speed: Super-Speed + Connectable: true + =========================================== + ``` + + ```bash + $ sudo sh KneronDFUT.sh --kl730-usb-boot --port 13 + ``` + + ```bash + Start Update Device with Port Id 13 to USB Boot + + ==== Update of Device with Port Id: 13 Succeeded ==== + ``` + + --- ## 3. Build PLUS @@ -438,3 +491,46 @@ output bounding boxes on 'output_car_park_barrier_608x608.bmp' Besides output results in the screen console, it also draws detected objects in a new-created **output_one_bike_many_cars_608x608.bmp**. ![](./imgs/ex_kdp2_yolo_v5s.bmp) + +### 4.4 KL730 + +```bash +$ sudo ./kl730_demo_generic_image_inference_post_yolo +``` + +```bash +connect device ... OK +upload firmware ... OK +upload model ... OK +read image ... OK + +starting inference loop 10 times: +.......... + +inference loop is done, starting post-processing ... + +doing yolo v5 post-processing ... + +detectable class count : 80 +box count : 13 +Box 0 (x1, y1, x2, y2, score, class) = 124.0, 267.0, 133.0, 287.0, 0.155090, 0 +Box 1 (x1, y1, x2, y2, score, class) = 303.0, 262.0, 471.0, 435.0, 0.719055, 2 +Box 2 (x1, y1, x2, y2, score, class) = 26.0, 263.0, 132.0, 392.0, 0.508118, 2 +Box 3 (x1, y1, x2, y2, score, class) = 7.0, 264.0, 38.0, 296.0, 0.473145, 2 +Box 4 (x1, y1, x2, y2, score, class) = 0.0, 274.0, 12.0, 300.0, 0.447144, 2 +Box 5 (x1, y1, x2, y2, score, class) = 107.0, 270.0, 134.0, 317.0, 0.372437, 2 +Box 6 (x1, y1, x2, y2, score, class) = 158.0, 255.0, 197.0, 333.0, 0.323059, 2 +Box 7 (x1, y1, x2, y2, score, class) = 0.0, 267.0, 27.0, 303.0, 0.263916, 2 +Box 8 (x1, y1, x2, y2, score, class) = 26.0, 263.0, 132.0, 392.0, 0.325195, 7 +Box 9 (x1, y1, x2, y2, score, class) = 153.0, 254.0, 196.0, 331.0, 0.278320, 7 +Box 10 (x1, y1, x2, y2, score, class) = 121.0, 164.0, 155.0, 221.0, 0.491943, 11 +Box 11 (x1, y1, x2, y2, score, class) = 320.0, 170.0, 350.0, 226.0, 0.340576, 11 +Box 12 (x1, y1, x2, y2, score, class) = 205.0, 60.0, 250.0, 142.0, 0.317871, 11 + +output bounding boxes on 'output_car_park_barrier_608x608.bmp' + +``` + +Besides output results in the screen console, it also draws detected objects in a new-created **output_car_park_barrier_608x608.bmp**. + +![](./imgs/ex_kdp2_yolo_v5s_730.bmp) diff --git a/docs/plus_c/imgs/dfut_kl730_flash_boot.png b/docs/plus_c/imgs/dfut_kl730_flash_boot.png new file mode 100644 index 0000000..ee38f80 --- /dev/null +++ b/docs/plus_c/imgs/dfut_kl730_flash_boot.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4c82dea5441768dfea72077d5f8d38039cb469b4dd965eb750a2c3bf3379080d +size 20176 diff --git a/docs/plus_c/imgs/dfut_kl730_model.png b/docs/plus_c/imgs/dfut_kl730_model.png new file mode 100644 index 0000000..f815d3d --- /dev/null +++ b/docs/plus_c/imgs/dfut_kl730_model.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d8545392786e30763e867115920a0dbf852b0420018a5b67b36a744cbd683067 +size 19994 diff --git a/docs/plus_c/imgs/dfut_kl730_usb_boot.png b/docs/plus_c/imgs/dfut_kl730_usb_boot.png new file mode 100644 index 0000000..6193f89 --- /dev/null +++ b/docs/plus_c/imgs/dfut_kl730_usb_boot.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c65d0511770e0c19f57731d99e93bb48d2ca25e1bf2f785a10209ee492a31ee6 +size 20343 diff --git a/docs/plus_c/imgs/ex_kdp2_yolo_v5s_730.bmp b/docs/plus_c/imgs/ex_kdp2_yolo_v5s_730.bmp new file mode 100644 index 0000000..a620965 Binary files /dev/null and b/docs/plus_c/imgs/ex_kdp2_yolo_v5s_730.bmp differ diff --git a/docs/plus_c/imgs/zadig_install_kl730_driver.png b/docs/plus_c/imgs/zadig_install_kl730_driver.png new file mode 100644 index 0000000..0eabcad --- /dev/null +++ b/docs/plus_c/imgs/zadig_install_kl730_driver.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6472dded4f0a753218f3082736f93dd4efb61845d4da98f5cc55df5aa9f7ab8e +size 21043 diff --git a/docs/plus_c/introduction/install_dependency.md b/docs/plus_c/introduction/install_dependency.md index 0f0785b..3b77356 100644 --- a/docs/plus_c/introduction/install_dependency.md +++ b/docs/plus_c/introduction/install_dependency.md @@ -34,6 +34,7 @@ And the following sections in this chapter will provide the instructions for ins SUBSYSTEM=="usb",ATTRS{product}=="Kneron KL720l",ATTRS{idVendor}=="3231",ATTRS{idProduct}=="0200",MODE="0666" SUBSYSTEM=="usb",ATTRS{product}=="Kneron KL720",ATTRS{idVendor}=="3231",ATTRS{idProduct}=="0720",MODE="0666" SUBSYSTEM=="usb",ATTRS{product}=="Kneron KL630",ATTRS{idVendor}=="3231",ATTRS{idProduct}=="0630",MODE="0666" + SUBSYSTEM=="usb",ATTRS{product}=="Kneron KL730",ATTRS{idVendor}=="3231",ATTRS{idProduct}=="0732",MODE="0666" ``` and apply the new rules by following commands (Or reboot the host) ```bash @@ -105,6 +106,18 @@ Note: This feature is only provided in Kneron PLUS v1.3.0 and above. **Note**: After Upgrade Kneron KL720 to KDP2 (ex. via Kneron DFUT), you may need to re-install the driver of KL720, since the USB ID will be changed to "3231/0720". +4. KL730 + + - The application should detect Kneron KL730 device as "Kneron KL730" with USB ID + "3231/0732" as shown below: + + ![](../imgs/zadig_install_kl730_driver.png) + + - Make sure that the Driver field, has WinUSB option selected. + + - Click "Install Driver" button. + + ### 2.2 **MSYS2** diff --git a/docs/plus_c/introduction/introduction.md b/docs/plus_c/introduction/introduction.md index 6aa90b5..1576c1c 100644 --- a/docs/plus_c/introduction/introduction.md +++ b/docs/plus_c/introduction/introduction.md @@ -2,7 +2,7 @@ ## Basic Features -**Kneron PLUS** stands for *Platform Library Unified Software* which is a framework comprising new software(SW) and firmware(FW) design for KL520 and KL720 (and alpha for KL630). +**Kneron PLUS** stands for *Platform Library Unified Software* which is a framework comprising new software(SW) and firmware(FW) design for KL520, KL720, and KL630 (and alpha for KL730). In order to run the inference of models on Kneron AI devices, there are three parts of AI application development are required: @@ -31,57 +31,58 @@ Below gives some definitions regarding the Kneron PLUS: The features which PLUS Supported are listed below: -Index | Category | Supported Item | Min Version (KL520/KL720) | Min Version (KL630) [***1***] | KL520 | KL720 | KL630 -------- | :-------------------- | :------------------------------------------------------------------------ | :------------------------ | :---------------------------- | :---: | :---: | :---: -1 | Image Format | RGBA8888 , RAW8 , Packed YCbCr422 (YUYV422) , RGB565 | | | | | -2 | | Planar YUV420 | | | X | X | -3 | System | Firmware In Flash | | | | | -4 | | Model In Flash | | | | | -5 | | Runtime Upload Firmware | | | | X | -6 | | Runtime Upload Model | | | | | -7 | | Software Reset | | | | | -8 | | Software Shutdown (Developing Broad Only) | | | | X | X -9 | | Software Reboot | | | | | -10 | | Scan Devices | | | | | -11 | | Device Log via USB | | | X | | X -12 | | Device Connection : All Devices, Specified Device(s) | | | | | -13 | Inference | Flexible Send / Receive Inference | | | | | -14 | | Multiple Device Auto Dispatch | | | | | -15 | | Enable / Disable Pre-process on Device | | | | | -16 | | Enable / Disable Post-process on Device | | | | | -17 | | Output Floating Point / Fixed Point Result | | | | | -18 | | Enable / Disable Debug Checkpoints | v1.3.0 | | | | -19 | | Enable / Disable Execution Time Profiling | v1.3.0 | | | | -20 | System / Model Info | Get Firmware Version | | | | | -21 | | Get KN Number | | | | | -22 | | Get Model CRC | | | | | -23 | | Get Model Info | | | | | -24 | | Install Device Driver for Windows | v1.3.0 | | | | -25 | Application API | Generic Image Inference | v2.0.0 | | | | -26 | | Generic Data Inference | v2.0.0 | | | | -27 | | Customized Inference (C code only) | | | | | -28 | | User Define API (C code only) | | | | | -29 | System Examples | Get Firmware Info | | | | | -30 | | Get Model Info | | | | | -31 | | Reboot Device | | | | | -32 | | Shutdown Device | | | | X | X -33 | | Device FIFO Queue Config Example | v2.0.0 | | | | -34 | Inference Examples | Generic Image Inference (Raw Output) | v2.0.0 | | | | -35 | | Generic Image Inference (with Crop) | v2.0.0 | | | | -36 | | Generic Image Inference (with Post Process on Host Side) | v2.0.0 | | | | -37 | | Generic Image Inference (Multiple Threads) | v2.0.0 | | | | -38 | | Generic Image Inference (Model in Flash) | v2.0.0 | | | | -39 | | Generic Image Inference (Web Cam with Drop Frame) | v2.0.0 | | | | -40 | | Generic Data Inference (with Pre Process on Host Side) | v2.0.0 | | | | -41 | | User Define API Inference (Yolo with Config Post Process) (C code only) | v1.3.0 | | | | -42 | | Customized Inference with Single Model (C code only) | v2.0.0 for KL720 | | | | -43 | | Customized Inference with Multiple Models (C code only) | v2.0.0 for KL720 | | | | -44 | Debug Examples | Debug Checkpoints Example | v1.3.0 | | | X | X -45 | | Execution Time Profiling Example | v1.3.0 | | | X | X -46 | Model Zoo Examples | Simple examples for pre-trained models | | | | | X +Index | Category | Supported Item | Min Version (KL520/KL720) | Min Version (KL630) [***1***] | Min Version (KL730) [***2***] | KL520 | KL720 | KL630 | KL730 +------- | :-------------------- | :------------------------------------------------------------------------ | :------------------------ | :---------------------------- | :---------------------------- | :---: | :---: | :---: | :---: +1 | Image Format | RGBA8888 , RAW8 , Packed YCbCr422 (YUYV422) , RGB565 | | | | | | | +2 | | Planar YUV420 | | | | X | X | | +3 | System | Firmware In Flash | | | | | | | +4 | | Model In Flash | | | | | | | +5 | | Runtime Upload Firmware | | | | | X | | +6 | | Runtime Upload Model | | | | | | | +7 | | Software Reset | | | | | | | +8 | | Software Shutdown (Developing Broad Only) | | | | | X | X | X +9 | | Software Reboot | | | | | | | +10 | | Scan Devices | | | | | | | +11 | | Device Log via USB | | | | X | | X | X +12 | | Device Connection : All Devices, Specified Device(s) | | | | | | | +13 | Inference | Flexible Send / Receive Inference | | | | | | | +14 | | Multiple Device Auto Dispatch | | | | | | | +15 | | Enable / Disable Pre-process on Device | | | | | | | +16 | | Enable / Disable Post-process on Device | | | | | | | +17 | | Output Floating Point / Fixed Point Result | | | | | | | +18 | | Enable / Disable Debug Checkpoints | v1.3.0 | | | | | | +19 | | Enable / Disable Execution Time Profiling | v1.3.0 | | | | | | +20 | System / Model Info | Get Firmware Version | | | | | | | +21 | | Get KN Number | | | | | | | +22 | | Get Model CRC | | | | | | | +23 | | Get Model Info | | | | | | | +24 | | Install Device Driver for Windows | v1.3.0 | | | | | | +25 | Application API | Generic Image Inference | v2.0.0 | | | | | | +26 | | Generic Data Inference | v2.0.0 | | | | | | +27 | | Customized Inference (C code only) | | | | | | | +28 | | User Define API (C code only) | | | | | | | +29 | System Examples | Get Firmware Info | | | | | | | +30 | | Get Model Info | | | | | | | +31 | | Reboot Device | | | | | | | +32 | | Shutdown Device | | | | | X | X | X +33 | | Device FIFO Queue Config Example | v2.0.0 | | | | | | +34 | Inference Examples | Generic Image Inference (Raw Output) | v2.0.0 | | | | | | +35 | | Generic Image Inference (with Crop) | v2.0.0 | | | | | | +36 | | Generic Image Inference (with Post Process on Host Side) | v2.0.0 | | | | | | +37 | | Generic Image Inference (Multiple Threads) | v2.0.0 | | | | | | +38 | | Generic Image Inference (Model in Flash) | v2.0.0 | | | | | | +39 | | Generic Image Inference (Web Cam with Drop Frame) | v2.0.0 | | | | | | +40 | | Generic Data Inference (with Pre Process on Host Side) | v2.0.0 | | | | | | +41 | | User Define API Inference (Yolo with Config Post Process) (C code only) | v1.3.0 | | | | | | +42 | | Customized Inference with Single Model (C code only) | v2.0.0 for KL720 | | | | | | +43 | | Customized Inference with Multiple Models (C code only) | v2.0.0 for KL720 | | | | | | +44 | Debug Examples | Debug Checkpoints Example | v1.3.0 | | | | X | X | X +45 | | Execution Time Profiling Example | v1.3.0 | | | | X | X | X +46 | Model Zoo Examples | Simple examples for pre-trained models | | | | | | X | X **Note**: - [1] If the minimum version is not written, this feature is supported from v2.1.1. +- [2] If the minimum version is not written, this feature is supported from v2.3.0. The following components are contained in Kneron PLUS: @@ -102,21 +103,21 @@ Besides the basic features, there are few advanced features provided in Kneron P **Note**: Most of the advanced features and examples are C code only. Only **Update Kdp2 to Kdp2 Flash Boot** has the python version example. -Index | Category | Supported Item | Min Version (KL520/KL720) | Min Version (KL630) | KL520 | KL720 | KL630 -------- | :-------------------- | :-------------------------------------------------------- | :------------------------ | :-------------------- | :---: | :---: | :---: -1 | System | Runtime Upload Firmware via UART | | | | X | X -2 | | Hico Mode (MIPI image input, Companion Result Output) | | v2.1.1 | | | -3 | Examples | Update Kdp to Kdp2 Usb Boot | | | | X | X -4 | | Update Kdp2 to Kdp2 Usb Boot | | v2.1.1 | | X | -5 | | Update Kdp to Kdp2 Flash Boot | | | | | X -6 | | Update Kdp2 to Kdp2 Flash Boot | | v2.1.1 | | | -7 | | Update Model to Flash | | v2.1.1 | | | -8 | | Upload Firmware via UART | | | | X | X -9 | | Upload Firmware via Usb for No-Flash Device | v2.0.0 | | X | | X -10 | | Read / Write Device Memory | | | | | X -11 | | Access Firmware Log via USB | | | X | | X -12 | | Hico Cam Inference [***1***] [***2***] [***3***] | | v2.1.1 | | | -13 | | Hico ToF Inference (Kneron ToF module is required) | v1.3.0 | | X | | X +Index | Category | Supported Item | Min Version (KL520/KL720) | Min Version (KL630) | Min Version (KL730) | KL520 | KL720 | KL630 | KL730 +------- | :-------------------- | :-------------------------------------------------------- | :------------------------ | :------------------ | :------------------ | :---: | :---: | :---: | :---: +1 | System | Runtime Upload Firmware via UART | | | | | X | X | X +2 | | Hico Mode (MIPI image input, Companion Result Output) | | v2.1.1 | v2.3.0 | | | | X +3 | Examples | Update Kdp to Kdp2 Usb Boot | | | | | X | X | X +4 | | Update Kdp2 to Kdp2 Usb Boot | | v2.1.1 | v2.3.0 | | X | | +5 | | Update Kdp to Kdp2 Flash Boot | | | | | | X | X +6 | | Update Kdp2 to Kdp2 Flash Boot | | v2.1.1 | v2.3.0 | | | | +7 | | Update Model to Flash | | v2.1.1 | v2.3.0 | | | | +8 | | Upload Firmware via UART | | | | | X | X | X +9 | | Upload Firmware via Usb for No-Flash Device | v2.0.0 | | | X | | X | X +10 | | Read / Write Device Memory | | | | | | X | X +11 | | Access Firmware Log via USB | | | | X | | X | X +12 | | Hico Cam Inference [***1***] [***2***] [***3***] | | v2.1.1 | v2.3.0 | | | | X +13 | | Hico ToF Inference (Kneron ToF module is required) | v1.3.0 | | | X | | X | X **Note**: diff --git a/docs/plus_c/introduction/run_examples.md b/docs/plus_c/introduction/run_examples.md index b75cb54..beb864d 100644 --- a/docs/plus_c/introduction/run_examples.md +++ b/docs/plus_c/introduction/run_examples.md @@ -6,7 +6,7 @@ **Note**: To execute **MSYS2 MinGW 64-bit**, please use the shortcut or `c:\msys64\msys2_shell.cmd -mingw64` instead of `c:\msys64\mingw64.exe`. -**Note**: In the inference related examples, we are using KL520 for most demo. If you wish to use KL630 or KL720, just change the prefix of the example name from kl520 to kl630 or kl720. +**Note**: In the inference related examples, we are using KL520 for most demo. If you wish to use KL630, KL720, or KL730, just change the prefix of the example name from kl520 to kl630, kl720, or kl730. **Note**: Few examples will auto connect multiple devices to run inference. If you put hybrid types of devices on host, the inference may fail. @@ -150,7 +150,7 @@ This example is to show the usage of `kp_install_driver_for_windows()` and help ```bash [arguments] -h : help - -target: [target platform] (ALL, KL520, KL630, KL720) = KL520 + -target: [target platform] (ALL, KL520, KL630, KL720, KL730) = KL520 [note] You must run this app as administrator on Windows @@ -167,7 +167,7 @@ This example is to show the usage of `kp_install_driver_for_windows()` and help ```bash [arguments] -h : help - -target: [target platform] (ALL, KL520, KL630, KL720) = KL630 + -target: [target platform] (ALL, KL520, KL630, KL720, KL730) = KL630 [note] You must run this app as administrator on Windows @@ -184,7 +184,7 @@ This example is to show the usage of `kp_install_driver_for_windows()` and help ```bash [arguments] -h : help - -target: [target platform] (ALL, KL520, KL630, KL720) = KL720 + -target: [target platform] (ALL, KL520, KL630, KL720, KL730) = KL720 [note] You must run this app as administrator on Windows @@ -192,6 +192,23 @@ This example is to show the usage of `kp_install_driver_for_windows()` and help Installing driver for KL720 ... Success (0) ``` +4. For installing the driver for KL730: + + ```bash + $ ./install_driver_windows.exe -target KL730 + ``` + + ```bash + [arguments] + -h : help + -target: [target platform] (ALL, KL520, KL630, KL720, KL730) = KL730 + + [note] + You must run this app as administrator on Windows + + Installing driver for KL730 ... Success (0) + ``` + ### 1.4 Load Firmware and Model Example `kp_load_firmware_from_file()` is an API to load firmware file from host to the AI device via USB. And this API is only available when device is on **USB Boot Mode**. Please refer [Upgrade AI Device To KDP2](./upgrade_ai_device_to_kdp2.md) for more information. @@ -345,6 +362,12 @@ Therefore, all the functions in console mode, other than executable file name, a 8. For writing model into KL720, please refer [Write Model Into KL720](./write_model_to_flash.md#52-use-command-line-to-write-model-into-ai-device). +9. For upgrading KL730 to USB boot mode, please refer [Upgrade KL730 to USB Boot Mode](./upgrade_ai_device_to_kdp2.md#92-use-command-line-to-update-ai-device). + +10. For upgrading KL730 to Flash boot mode, please refer [Upgrade KL730 to Flash Boot Mode](./upgrade_ai_device_to_kdp2.md#102-use-command-line-to-update-ai-device). + +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 @@ -435,6 +458,8 @@ The main difference between **Generic Inference** and **Customized Inference** i For the detail introduction, please refer the documents in [Generic Inference](../feature_guide/generic_inference.md). +**Note**: Multiple calls of `kp_app_yolo_inference_send()` without any call of `kp_app_yolo_inference_receive()` may cause the system stuck. + ### 2.2 Customized Inference Example Customized inference examples are using the **Customized Inference API**, which provides some decent flexibility for users to customize their own applications with customized NEF models. diff --git a/docs/plus_c/introduction/run_examples_enterprise.md b/docs/plus_c/introduction/run_examples_enterprise.md index 50de112..971869e 100644 --- a/docs/plus_c/introduction/run_examples_enterprise.md +++ b/docs/plus_c/introduction/run_examples_enterprise.md @@ -8,7 +8,7 @@ Other than the examples briefed in [Run Examples](./run_examples.md), Kneron PLU **Note**: To execute **MSYS2 MinGW 64-bit**, please use the shortcut or `c:\msys64\msys2_shell.cmd -mingw64` instead of `c:\msys64\mingw64.exe`. -**Note**: In the inference related examples, we are using KL520 for most demo. If you wish to use KL630 or KL720, just change the prefix of the example name from kl520 to kl630 or kl720. (There might be no KL520 version, KL630 version or KL720 version on certain examples.) +**Note**: In the inference related examples, we are using KL520 for most demo. If you wish to use KL630, KL720, or KL730, just change the prefix of the example name from kl520 to kl630, kl720, or kl730. (There might be no KL520 version, KL630 version, KL720 version, or KL730 version on certain examples.) **Note**: Few examples will auto connect multiple devices to run inference. If you put hybrid types of devices on host, the inference may fail. 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 808e664..07fcf83 100644 --- a/docs/plus_c/introduction/upgrade_ai_device_to_kdp2.md +++ b/docs/plus_c/introduction/upgrade_ai_device_to_kdp2.md @@ -28,10 +28,10 @@ There are two modes to activate KDP2 firmware in Kneron AI device: - The GUI or command line of **KneronDFUT** can be used for writing the loader firmware to flash memory and switch AI devices to USB boot mode. - - After writing the loader firmware and switching device to USB boot mode. The KDP2 firmware can be uploaded via following KP API, before inference: + - After writing the loader firmware and switching device to USB boot mode. The KDP2 firmware can be uploaded via following KP API, before inference: - * C user: `kp_load_firmware_from_file()` - * Python user: `kp.core.load_firmware_from_file()` + * C user: `kp_load_firmware_from_file()` + * Python user: `kp.core.load_firmware_from_file()` - **Firmware in Flash Memory (Flash Boot)** @@ -86,6 +86,15 @@ $ sudo sh KneronDFUT.sh --help --port : [argument required] port id set ("all" or specified multiple port ids "13,537") --scpu : [argument required] self pointed firmware file path (.tar) +[Update dongles to usb boot] (Only works for KL730) + --kl730-usb-boot : [no argument] choose update to Usb Boot + --port : [argument required] port id set ("all" or specified multiple port ids "13,537") + +[Update dongles to usb boot] (Only works for KL730) + --kl730-flash-boot : [no argument] choose update to Flash Boot + --port : [argument required] port id set ("all" or specified multiple port ids "13,537") + --scpu : [argument required] self pointed firmware file path (.tar) + [Update firmware file to flash memory in dongles] (Only works for KL720) --kl720-update : [no argument] choose write firmware to flash memory --port : [argument required] port id set ("all" or specified multiple port ids "13,537") @@ -94,7 +103,7 @@ $ sudo sh KneronDFUT.sh --help [Update model file to flash memory in dongles] --model-to-flash : [argument required] self pointed model file path (.nef) - --type : [argument required] type of device ("KL520", "KL630", or "KL720") + --type : [argument required] type of device ("KL520", "KL630", "KL720", or "KL730") --port : [argument required] port id set ("all" or specified multiple port ids "13,537") [Enable Graphic User Interface] @@ -108,7 +117,7 @@ $ sudo sh KneronDFUT.sh --help ## 3. Install Driver for Windows -When you execute any kind of update on Kneron DFUT, it will check whether the driver of KL520, KL630 or KL720 has been installed on Windows. If the driver has not been installed, Kneron DFUT will install the driver before any update. +When you execute any kind of update on Kneron DFUT, it will check whether the driver of KL520, KL630, KL720, or KL730 has been installed on Windows. If the driver has not been installed, Kneron DFUT will install the driver before any update. Note: Kneron DFUT only check and install driver when it was executed on Windows. @@ -418,3 +427,115 @@ $ sudo sh KneronDFUT.sh ``` SCPU and NCPU firmware file for KL720 can be found in **${PLUS_FOLDER}/res/firmware/KL720/** + +--- + +## 9. [KL730] Update to USB Boot Mode + +### 9.1 Use GUI to Update AI Device + +```bash +$ sudo sh KneronDFUT.sh +``` + +1. Select **KL730** Tab. + +2. Select the KL730 devices to be update to USB Boot Mode. + +3. Select **Update to USB Boot** + +4. Push **Run** button. + + ![](../imgs/dfut_kl730_usb_boot.png) + + +### 9.2 Use Command Line to Update AI Device + +1. List all devices + + ```bash + $ sudo sh KneronDFUT.sh --list + ``` + + ```bash + =========================================== + Index: 1 + Port Id: 133 + Kn Number: 0x270A265C + Device Type: KL730 + FW Type: KDP2 + Usb Speed: High-Speed + Connectable: true + =========================================== + ``` + +2. Upgrade the selected KL730 devices using the port id + + ```bash + $ sudo sh KneronDFUT.sh --kl730-usb-boot --port 133 + ``` + + ```bash + Start Update Device with Port Id 133 to USB Boot + + ==== Update of Device with Port Id: 133 Succeeded ==== + + ``` + + +--- + +## 10. [KL730] Update to Flash Boot Mode + +### 10.1 Use GUI to Update AI Device +```bash +$ sudo sh KneronDFUT.sh +``` + +1. Select **KL730** Tab. + +2. Select the KL730 devices to be **Update to Flash Boot** Mode. + +3. Select **Update to Flash Boot** + +4. Manually choose **SCPU firmware file**. + + SCPU firmware file for KL730 can be found in **${PLUS_FOLDER}/res/firmware/KL730/** + +5. Push **Run** button. + + ![](../imgs/dfut_kl730_flash_boot.png) + +### 10.2 Use Command Line to Update AI Device + +1. List all devices + + ```bash + $ sudo sh KneronDFUT.sh --list + ``` + + ```bash + =========================================== + Index: 1 + Port Id: 13 + Kn Number: 0x09011004 + Device Type: KL730 + FW Type: KDP2 + Usb Speed: High-Speed + Connectable: true + =========================================== + ``` + +2. Upgrade the selected KL730 devices using the port id + + ```bash + $ sudo sh KneronDFUT.sh --kl730-flash-boot --port 13 --scpu ${SCPU_FILE_PATH} + ``` + + ```bash + Start Update Device with Port Id 13 to Flash Boot + + ==== Update of Device with Port Id: 13 Succeeded ==== + ``` + + SCPU firmware file for KL730 can be found in **${PLUS_FOLDER}/res/firmware/KL730/** diff --git a/docs/plus_c/introduction/write_model_to_flash.md b/docs/plus_c/introduction/write_model_to_flash.md index a874f8d..4b51d42 100644 --- a/docs/plus_c/introduction/write_model_to_flash.md +++ b/docs/plus_c/introduction/write_model_to_flash.md @@ -24,6 +24,7 @@ There are two ways to load models: - **35 MB** for KL520 - **60 MB** for KL630 - **75 MB** for KL720 + - **350 MB** for KL730 (KL730 SDK default setting: 350MB, and this size can be enlarged in the firmware device tree.) - **Load Model from Flash** @@ -41,6 +42,7 @@ There are two ways to load models: - **32 MB** for KL520 - **55 MB** for KL630 - **70 MB** for KL720 + - **55 MB** for KL730 **Note**: Only one model file (.nef) can be loaded, no matter it was uploaded via USB or loaded from flash. If you want to change the model, please reboot the Kneron AI device. @@ -224,3 +226,57 @@ $ sudo sh KneronDFUT.sh ==== Update Model to Device with Port Id: 262 Succeeded ==== ``` + +--- + +## 6. Write Model Into KL730 + +### 6.1 Use GUI to Write Model into AI Device + +```bash +$ sudo sh KneronDFUT.sh +``` + +1. Select **KL730** Tab. + +2. Select the KL730 devices to write model into. + +3. Select **Update Model to Flash** + +4. Manually choose **Model file**. + +5. Push **Run** button. + + ![](../imgs/dfut_kl730_model.png) + +### 6.2 Use Command Line to Write Model into AI Device + +1. List all devices + + ```bash + $ sudo sh KneronDFUT.sh --list + ``` + + ```bash + =========================================== + Index: 1 + Port Id: 13 + Kn Number: 0x09011004 + Device Type: KL730 + FW Type: KDP2 + Usb Speed: High-Speed + Connectable: true + =========================================== + ``` + +3. Write model into the selected KL520 devices using the port id + + ```bash + $ sudo sh KneronDFUT.sh --model-to-flash ${MODEL_FILE_PATH} --port 13 -- type KL730 + ``` + + ```bash + Start Update Model to Device with Port Id 13 + + ==== Update Model to Device with Port Id: 13 Succeeded ==== + ``` diff --git a/docs/plus_c_api/api_reference_2.3.x/kp_core.h.md b/docs/plus_c_api/api_reference_2.3.x/kp_core.h.md new file mode 100644 index 0000000..f405918 --- /dev/null +++ b/docs/plus_c_api/api_reference_2.3.x/kp_core.h.md @@ -0,0 +1,521 @@ +# 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_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_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_2.3.x/kp_inference.h.md b/docs/plus_c_api/api_reference_2.3.x/kp_inference.h.md new file mode 100644 index 0000000..2593483 --- /dev/null +++ b/docs/plus_c_api/api_reference_2.3.x/kp_inference.h.md @@ -0,0 +1,417 @@ +# 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_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) + + +--- + + + + +## **Functions** +### **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 + + +--- diff --git a/docs/plus_c_api/api_reference_2.3.x/kp_inference_v1.h.md b/docs/plus_c_api/api_reference_2.3.x/kp_inference_v1.h.md new file mode 100644 index 0000000..ac32e82 --- /dev/null +++ b/docs/plus_c_api/api_reference_2.3.x/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_2.3.x/kp_struct.h.md b/docs/plus_c_api/api_reference_2.3.x/kp_struct.h.md new file mode 100644 index 0000000..caedf96 --- /dev/null +++ b/docs/plus_c_api/api_reference_2.3.x/kp_struct.h.md @@ -0,0 +1,1014 @@ +# Kneron PLUS data structure + + + + +**Include Header File:** kp_struct.h + +- Defines + - APP_PADDING_BYTES + - MAX_INPUT_NODE_COUNT + - KDP2_MAGIC_TYPE_COMMAND + - KDP2_MAGIC_TYPE_INFERENCE + - KDP2_MAGIC_TYPE_CUSTOMIZED + - KDP2_MAGIC_TYPE_CHECKPOINT_DATA + - 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_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_normalize_mode_t](#kp_normalize_mode_t) + - [ kp_padding_mode_t](#kp_padding_mode_t) + - [ kp_product_id_t](#kp_product_id_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_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_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_yolo_result_t](#kp_yolo_result_t) +- Unions + - [ fixed_node_output_data_t](#fixed_node_output_data_t) + + +--- + + + + +## **Defines** +| Define | Value | Description | +|:---|:---|:---| +|APP_PADDING_BYTES|28 | Default padding size | +|MAX_INPUT_NODE_COUNT|5 | Supported maximum count of the model input node | +|KDP2_MAGIC_TYPE_COMMAND|0xAB67CD13 | Magic number for data check | +|KDP2_MAGIC_TYPE_INFERENCE|0x11FF22AA | 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 | +|MAX_CROP_BOX|4 | MAX crop count | +|YOLO_GOOD_BOX_MAX|100 | 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_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_NCPU_ERR_BEGIN = 200,| | +|KP_FW_NCPU_INVALID_IMAGE_201 = 201,| | +|KP_FW_NCPU_INPROC_FAILED_202 = 202,| | +|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_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 default, channel/height/width in order | +|KP_CHANNEL_ORDERING_HWC = 2, | TensorFlow style, height/width/channel in 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_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 | +|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 and KL730 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 bits, channel: 4 bits, depth: 8 bits | +|KP_MODEL_TENSOR_DATA_LAYOUT_1W16C8B = 2, | width: 1 bits, channel: 16 bits, depth: 8 bits | +|KP_MODEL_TENSOR_DATA_LAYOUT_16W1C8B = 3, | width: 16 bits, channel: 4 bits, depth: 8 bits | +|KP_MODEL_TENSOR_DATA_LAYOUT_8W1C16B = 4, | width: 8 bits, channel: 1 bits, depth: 16 bits | + + +--- +### **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_KL730 = 0x732, | KL730 USB PID | +|KP_DEVICE_KL630 = 0x630, | KL630 USB PID | +|KP_DEVICE_KL540 = 0x540, | KL540 USB PID | + + +--- +### **kp_reset_mode_t** +typedef enum **kp_reset_mode_t** {...} +> reset mode + +| Enumerator | | +|:---|:--- | +|KP_RESET_REBOOT = 0, | Higheset 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 bord), 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_inf_raw_fixed_node_metadata_t node_metadata[50];| 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_inf_raw_fixed_node_metadata_t node_metadata[50];| 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_inf_raw_fixed_node_metadata_t node_metadata[50];| 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_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[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[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[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| | +|:---|:--- | +|uint32_t width;| node width | +|uint32_t height;| node height | +|uint32_t channel;| node channel | +|int32_t radix;| radix for fixed/floating point conversion | +|float scale;| scale for fixed/floating point conversion | +|float factor;| conversion factor for fixed-point to floating-point conversion - formula: 1 / (scale * (2 ^ radix)) | +|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| | +|:---|:--- | +|uint32_t width;| node width | +|uint32_t height;| node height | +|uint32_t channel;| node channel | +|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| | +|:---|:--- | +|uint32_t height;| node height | +|uint32_t channel;| node channel | +|uint32_t width;| node width, should be aligned to 16 bytes for futher processing due to low level output | +|int32_t radix;| radix for fixed/floating point conversion | +|float scale;| scale for fixed/floating point conversion | +|uint32_t data_layout;| npu memory layout (ref. kp_model_tensor_data_layout_t) | + + +--- +### **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 fixed-poiont values, should be
metadata->width (aligned to 16 bytes) * metadata->height * metadata->channel | +|int8_t *data;| array of fixed-point values| + + +--- +### **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 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| | +|:---|:--- | +|float scale;| scale of node | +|int32_t radix;| radix 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 shape_npu_len;| length of npu shape | +|uint32_t* shape_npu;| npu shape | +|uint32_t shape_onnx_len;| length of onnx shape | +|uint32_t* shape_onnx;| onnx shape | +|uint32_t data_layout;| npu memory layout | +|kp_quantization_parameters_t quantization_parameters;| quantization parameters | + + +--- +### **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 | + + +--- diff --git a/docs/plus_c_api/api_reference_2.3.x/kp_struct_v1.h.md b/docs/plus_c_api/api_reference_2.3.x/kp_struct_v1.h.md new file mode 100644 index 0000000..4814859 --- /dev/null +++ b/docs/plus_c_api/api_reference_2.3.x/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_2.3.x/kp_version.h.md b/docs/plus_c_api/api_reference_2.3.x/kp_version.h.md new file mode 100644 index 0000000..b8aa205 --- /dev/null +++ b/docs/plus_c_api/api_reference_2.3.x/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/V2.3.0/index.md b/docs/plus_python/api_document/V2.3.0/index.md new file mode 100644 index 0000000..3e8086c --- /dev/null +++ b/docs/plus_python/api_document/V2.3.0/index.md @@ -0,0 +1,320 @@ + +# 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_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) + + + * [`QuantizedFixedPointDescriptor`](kp/value.md#kp.QuantizedFixedPointDescriptor) + + + * [`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) + + +* [kp enum](kp/enum.md) + + + * [`ApiReturnCode`](kp/enum.md#kp.ApiReturnCode) + + + * [`ChannelOrdering`](kp/enum.md#kp.ChannelOrdering) + + + * [`FixedPointDType`](kp/enum.md#kp.FixedPointDType) + + + * [`ImageFormat`](kp/enum.md#kp.ImageFormat) + + + * [`ModelTargetChip`](kp/enum.md#kp.ModelTargetChip) + + + * [`ModelTensorDataLayout`](kp/enum.md#kp.ModelTensorDataLayout) + + + * [`NormalizeMode`](kp/enum.md#kp.NormalizeMode) + + + * [`PaddingMode`](kp/enum.md#kp.PaddingMode) + + + * [`ProductId`](kp/enum.md#kp.ProductId) + + + * [`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/V2.3.0/kp/const.md b/docs/plus_python/api_document/V2.3.0/kp/const.md new file mode 100644 index 0000000..84055c4 --- /dev/null +++ b/docs/plus_python/api_document/V2.3.0/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=5 + + 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/V2.3.0/kp/core.md b/docs/plus_python/api_document/V2.3.0/kp/core.md new file mode 100644 index 0000000..f8c8724 --- /dev/null +++ b/docs/plus_python/api_document/V2.3.0/kp/core.md @@ -0,0 +1,666 @@ +# 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_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) + + +* **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 + + + +* **Return type** + + [`None`](https://docs.python.org/3/library/constants.html#None) diff --git a/docs/plus_python/api_document/V2.3.0/kp/enum.md b/docs/plus_python/api_document/V2.3.0/kp/enum.md new file mode 100644 index 0000000..dc0d1c6 --- /dev/null +++ b/docs/plus_python/api_document/V2.3.0/kp/enum.md @@ -0,0 +1,613 @@ +# 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_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_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 + + + + +--- + +### **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. + + * **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 bits, channel: 4 bits, depth: 8 bits. + + * **KP_MODEL_TENSOR_DATA_LAYOUT_1W16C8B** : [`int`](https://docs.python.org/3/library/functions.html#int), default=2 + + Layout - width: 1 bits, channel: 16 bits, depth: 8 bits. + + * **KP_MODEL_TENSOR_DATA_LAYOUT_16W1C8B** : [`int`](https://docs.python.org/3/library/functions.html#int), default=3 + + Layout - width: 16 bits, channel: 4 bits, depth: 8 bits. + + * **KP_MODEL_TENSOR_DATA_LAYOUT_8W1C16B** : [`int`](https://docs.python.org/3/library/functions.html#int), default=4 + + Layout - width: 8 bits, channel: 1 bits, depth: 16 bits. + + + + +--- + +### **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_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.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. + + + + +--- + +### **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/V2.3.0/kp/exception.md b/docs/plus_python/api_document/V2.3.0/kp/exception.md new file mode 100644 index 0000000..0119527 --- /dev/null +++ b/docs/plus_python/api_document/V2.3.0/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/V2.3.0/kp/inference.md b/docs/plus_python/api_document/V2.3.0/kp/inference.md new file mode 100644 index 0000000..5b9334f --- /dev/null +++ b/docs/plus_python/api_document/V2.3.0/kp/inference.md @@ -0,0 +1,343 @@ +# 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) + + +* **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. + + + +* **Return type** + + [`GenericDataInferenceResult`](value.md#kp.GenericDataInferenceResult) + + + +--- + +### 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) + + +* **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. + + + +* **Return type** + + [`GenericImageInferenceResult`](value.md#kp.GenericImageInferenceResult) + + + +--- + +### 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) + + +* **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() + + + +* **Return type** + + [`ProfileData`](value.md#kp.ProfileData) + + + +--- + +### 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) + + +* **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() + + + +* **Return type** + + [`None`](https://docs.python.org/3/library/constants.html#None) + + + +--- + +### 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/V2.3.0/kp/v1/inference.md b/docs/plus_python/api_document/V2.3.0/kp/v1/inference.md new file mode 100644 index 0000000..4cfdf66 --- /dev/null +++ b/docs/plus_python/api_document/V2.3.0/kp/v1/inference.md @@ -0,0 +1,187 @@ +# 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.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.GenericRawBypassPreProcResult` + + GenericRawBypassPreProcResult object contained the received RAW data results. + + + +* **Raises** + + * [`kp.ApiKPException`](../exception.md#kp.ApiKPException) + + +* **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. + + + +* **Return type** + + [`GenericRawBypassPreProcResult`](value.md#kp.v1.GenericRawBypassPreProcResult) + + + +--- + +### 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.inference.generic_raw_inference_bypass_pre_proc_receive() to get the result. +In addition, to have better performance, users can issue multiple +kp.inference.generic_raw_inference_bypass_pre_proc_send() then start to receive results through +kp.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.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.GenericRawResult` + + GenericRawResult object contained the received RAW data results. + + + +* **Raises** + + * [`kp.ApiKPException`](../exception.md#kp.ApiKPException) + + +* **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. + + + +* **Return type** + + [`GenericRawResult`](value.md#kp.v1.GenericRawResult) + + + +--- + +### 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/V2.3.0/kp/v1/value.md b/docs/plus_python/api_document/V2.3.0/kp/v1/value.md new file mode 100644 index 0000000..1a54f25 --- /dev/null +++ b/docs/plus_python/api_document/V2.3.0/kp/v1/value.md @@ -0,0 +1,567 @@ +# 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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** inference_number(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Inference sequence number. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** model_id(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Target inference model ID. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +--- + +### **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. + + + +* **Return type** + + `GenericRawBypassPreProcResultHeader` + + + +#### **_property_** raw_result(: [GenericRawResultNDArray](../value.md#kp.GenericRawResultNDArray)) +kp.GenericRawResultNDArray: Inference raw result buffer. + + + +* **Return type** + + [`GenericRawResultNDArray`](../value.md#kp.GenericRawResultNDArray) + + + +--- + +### **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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### 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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** num_output_node(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Total number of output nodes. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** product_id(: [int](https://docs.python.org/3/library/functions.html#int)) +int: USB PID (Product ID). + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +--- + +### **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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### 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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** image_format(: [ImageFormat](../enum.md#kp.ImageFormat)) +kp.ImageFormat: Inference image format, refer to ImageFormat. + + + +* **Return type** + + [`ImageFormat`](../enum.md#kp.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. + + + +* **Return type** + + [`List`](https://docs.python.org/3/library/typing.html#typing.List)[[`InferenceCropBox`](../value.md#kp.InferenceCropBox)] + + + +#### **_property_** inference_number(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Inference sequence number. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** model_id(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Target inference model ID. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** normalize_mode(: [NormalizeMode](../enum.md#kp.NormalizeMode)) +kp.NormalizeMode: Inference normalization, refer to NormalizeMode. + + + +* **Return type** + + [`NormalizeMode`](../enum.md#kp.NormalizeMode) + + + +#### **_property_** padding_mode(: [PaddingMode](../enum.md#kp.PaddingMode)) +kp.PaddingMode: Preprocess padding mode, none or auto refer to PaddingMode. + + + +* **Return type** + + [`PaddingMode`](../enum.md#kp.PaddingMode) + + + +#### **_property_** resize_mode(: [ResizeMode](../enum.md#kp.ResizeMode)) +kp.ResizeMode: Preprocess resize mode, refer to ResizeMode. + + + +* **Return type** + + [`ResizeMode`](../enum.md#kp.ResizeMode) + + + +#### **_property_** width(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Inference image width. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +--- + +### **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. + + + +* **Return type** + + `GenericRawResultHeader` + + + +#### **_property_** raw_result(: [GenericRawResultNDArray](../value.md#kp.GenericRawResultNDArray)) +kp.GenericRawResultNDArray: Inference raw result buffer. + + + +* **Return type** + + [`GenericRawResultNDArray`](../value.md#kp.GenericRawResultNDArray) + + + +--- + +### **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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### 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 + + + +* **Return type** + + [`HwPreProcInfo`](../value.md#kp.HwPreProcInfo) + + + +#### **_property_** inference_number(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Inference sequence number. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** num_output_node(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Total number of output nodes. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** product_id(: [int](https://docs.python.org/3/library/functions.html#int)) +int: USB PID (Product ID). + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) diff --git a/docs/plus_python/api_document/V2.3.0/kp/value.md b/docs/plus_python/api_document/V2.3.0/kp/value.md new file mode 100644 index 0000000..4131f1a --- /dev/null +++ b/docs/plus_python/api_document/V2.3.0/kp/value.md @@ -0,0 +1,3272 @@ +# 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` : `kp.ModelNefDescriptor`, default=kp.ModelNefDescriptor() + + 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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** input_buffer_size(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Input buffer size for FIFO queue. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** model_size(: [int](https://docs.python.org/3/library/functions.html#int)) +int: DDR space for model. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** result_buffer_count(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Result buffer count for FIFO queue. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** result_buffer_size(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Result buffer size for FIFO queue. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +--- + +### **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. + + + +* **Return type** + + [`str`](https://docs.python.org/3/library/stdtypes.html#str) + + + +#### 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. + + + +* **Return type** + + [`bool`](https://docs.python.org/3/library/functions.html#bool) + + + +#### **_property_** kn_number(: [int](https://docs.python.org/3/library/functions.html#int)) +int: KN number. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** link_speed(: [UsbSpeed](enum.md#kp.UsbSpeed)) +UsbSpeed: Enum for USB speed mode. + + + +* **Return type** + + [`UsbSpeed`](enum.md#kp.UsbSpeed) + + + +#### **_property_** product_id(: [int](https://docs.python.org/3/library/functions.html#int)) +int: USB PID (Product ID). + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_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) + + + +* **Return type** + + [`str`](https://docs.python.org/3/library/stdtypes.html#str) + + + +#### **_property_** vendor_id(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Supposed to be 0x3231. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +--- + +### **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. + + + +* **Return type** + + [`List`](https://docs.python.org/3/library/typing.html#typing.List)[`DeviceDescriptor`] + + + +#### **_property_** device_descriptor_number(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Number of connected devices. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### 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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** content(: DeviceGroupContent) +DeviceGroupContent: A DeviceGroup descriptor. + + + +* **Return type** + + `DeviceGroupContent` + + + +#### 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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +--- + +### **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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_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). + + + +* **Return type** + + [`List`](https://docs.python.org/3/library/typing.html#typing.List)[`GenericInputNodeData`] + + + +#### **_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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** model_id(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Target inference model ID. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +--- + +### **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. + + + +* **Return type** + + `GenericDataInferenceResultHeader` + + + +#### **_property_** raw_result(: GenericRawResultNDArray) +kp.GenericRawResultNDArray: Inference raw result buffer. + + + +* **Return type** + + `GenericRawResultNDArray` + + + +--- + +### **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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### 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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** num_output_node(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Total number of output nodes. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** product_id(: [int](https://docs.python.org/3/library/functions.html#int)) +int: USB PID (Product ID). + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +--- + +### **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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_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). + + + +* **Return type** + + [`List`](https://docs.python.org/3/library/typing.html#typing.List)[`GenericInputNodeImage`] + + + +#### **_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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** model_id(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Target inference model ID. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +--- + +### **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. + + + +* **Return type** + + `GenericImageInferenceResultHeader` + + + +#### **_property_** raw_result(: GenericRawResultNDArray) +kp.GenericRawResultNDArray: Inference raw result buffer. + + + +* **Return type** + + `GenericRawResultNDArray` + + + +--- + +### **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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### 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. + + + +* **Return type** + + [`List`](https://docs.python.org/3/library/typing.html#typing.List)[`HwPreProcInfo`] + + + +#### **_property_** inference_number(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Inference sequence number. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** num_hw_pre_proc_info(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Number of hardware pre-process information. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** num_output_node(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Total number of output nodes. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** product_id(: [int](https://docs.python.org/3/library/functions.html#int)) +int: USB PID (Product ID). + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +--- + +### **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. + + + +* **Return type** + + [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes) + + + +#### **_property_** buffer_size(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Inference data buffer size. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### 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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### 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). + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_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. + + + +* **Return type** + + [`ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray) + + + +#### **_property_** image_format(: [ImageFormat](enum.md#kp.ImageFormat)) +kp.ImageFormat: Inference image format, refer to ImageFormat. + + + +* **Return type** + + [`ImageFormat`](enum.md#kp.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. + + + +* **Return type** + + [`List`](https://docs.python.org/3/library/typing.html#typing.List)[`InferenceCropBox`] + + + +#### **_property_** normalize_mode(: [NormalizeMode](enum.md#kp.NormalizeMode)) +kp.NormalizeMode: Inference normalization, refer to NormalizeMode. + + + +* **Return type** + + [`NormalizeMode`](enum.md#kp.NormalizeMode) + + + +#### **_property_** padding_mode(: [PaddingMode](enum.md#kp.PaddingMode)) +kp.PaddingMode: Preprocess padding mode, none or auto refer to PaddingMode. + + + +* **Return type** + + [`PaddingMode`](enum.md#kp.PaddingMode) + + + +#### **_property_** resize_mode(: [ResizeMode](enum.md#kp.ResizeMode)) +kp.ResizeMode: Preprocess resize mode, refer to ResizeMode. + + + +* **Return type** + + [`ResizeMode`](enum.md#kp.ResizeMode) + + + +#### **_property_** width(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Inference image width (Must apply when using bytes image data). + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +--- + +### **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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### 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) + + + +* **Return type** + + `InferenceCropBox` + + + +#### 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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** img_width(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Image width before hardware pre-process. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** model_input_height(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Model required input height. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** model_input_width(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Model required input width. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** pad_bottom(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Pixels padding on bottom. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** pad_left(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Pixels padding on left. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** pad_right(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Pixels padding on right. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** pad_top(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Pixels padding on top. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** resized_img_height(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Image height after resize. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** resized_img_width(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Image width after resize. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +--- + +### **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. + + + +* **Return type** + + [`bool`](https://docs.python.org/3/library/functions.html#bool) + + + +#### 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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### 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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** width(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Width coordinate of crop box. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** x(: [int](https://docs.python.org/3/library/functions.html#int)) +int: X coordinate of crop box top-left corner. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** y(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Y coordinate of crop box top-left corner. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +--- + +### **class** kp.InferenceFixedNodeOutput(width=0, height=0, channel=0, radix=0, scale=0, factor=0, 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** + + * `width` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Width of output node. + + * `height` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Height of output node. + + * `channel` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Channel of output node. + + * `radix` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Radix for fixed/floating point conversion. + + * `scale` : [`float`](https://docs.python.org/3/library/functions.html#float), default=0 + + float: Scale for fixed/floating point conversion. + + * `factor` : [`float`](https://docs.python.org/3/library/functions.html#float), default=0 + + float: Conversion factor for fixed-point to floating-point conversion - formulation: scale \* (2 ^ radix). + + * `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. (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_** channel(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Channel of output node. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** channels_ordering(: [ChannelOrdering](enum.md#kp.ChannelOrdering)) +kp.ChannelOrdering: Channel ordering of feature map. (Options: KP_CHANNEL_ORDERING_HCW, KP_CHANNEL_ORDERING_CHW) + + + +* **Return type** + + [`ChannelOrdering`](enum.md#kp.ChannelOrdering) + + + +#### **_property_** dtype(: [FixedPointDType](enum.md#kp.FixedPointDType)) +FixedPointDType: fixed-point data type. + + + +* **Return type** + + [`FixedPointDType`](enum.md#kp.FixedPointDType) + + + +#### **_property_** factor(: [float](https://docs.python.org/3/library/functions.html#float)) +float: Conversion factor for fixed-point to floating-point conversion - formulation: scale \* (2 ^ radix). + + + +* **Return type** + + [`float`](https://docs.python.org/3/library/functions.html#float) + + + +#### 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 of output node. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** ndarray(: [ndarray](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray)) +numpy.ndarray: N-dimensional numpy.ndarray of feature map. + + + +* **Return type** + + [`ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray) + + + +#### **_property_** num_data(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Total number of fixed-point values. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** radix(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Radix for fixed/floating point conversion. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** scale(: [float](https://docs.python.org/3/library/functions.html#float)) +float: Scale for fixed/floating point conversion. + + + +* **Return type** + + [`float`](https://docs.python.org/3/library/functions.html#float) + + + +#### to_float_node_output() +Convert fixed-point node output to floating-point node output. + + +* **Returns** + + * **inference_float_node_output** : `kp.InferenceFloatNodeOutput` + + + + +* **Return type** + + `InferenceFloatNodeOutput` + + + +#### **_property_** width(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Width of output node. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +--- + +### **class** kp.InferenceFloatNodeOutput(width=0, height=0, channel=0, num_data=0, data=array([], dtype=float64), channels_ordering=ChannelOrdering.KP_CHANNEL_ORDERING_CHW) +Generic inference node output in floating-point format. + + +* **Attributes** + + * `width` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Width of output node. + + * `height` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Height of output node. + + * `channel` : [`int`](https://docs.python.org/3/library/functions.html#int), default=0 + + int: Channel of output node. + + * `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_** channel(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Channel of output node. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** channels_ordering(: [ChannelOrdering](enum.md#kp.ChannelOrdering)) +kp.ChannelOrdering: Channel ordering of feature map. (Options: KP_CHANNEL_ORDERING_HCW, KP_CHANNEL_ORDERING_CHW) + + + +* **Return type** + + [`ChannelOrdering`](enum.md#kp.ChannelOrdering) + + + +#### 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 of output node. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** ndarray(: [ndarray](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray)) +numpy.ndarray: N-dimensional numpy.ndarray of feature map. + + + +* **Return type** + + [`ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray) + + + +#### **_property_** num_data(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Total number of floating-point values. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** width(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Width of output node. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +--- + +### **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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### 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). + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** metadata(: ModelNefMetadata) +ModelNefMetadata: NEF metadata. + + + +* **Return type** + + `ModelNefMetadata` + + + +#### **_property_** models(: [List](https://docs.python.org/3/library/typing.html#typing.List)[SingleModelDescriptor]) +List[SingleModelDescriptor]: Model descriptors. + + + +* **Return type** + + [`List`](https://docs.python.org/3/library/typing.html#typing.List)[`SingleModelDescriptor`] + + + +#### **_property_** target_chip(: [ModelTargetChip](enum.md#kp.ModelTargetChip)) +ModelTargetChip: Target chip of all models. + + + +* **Return type** + + [`ModelTargetChip`](enum.md#kp.ModelTargetChip) + + + +--- + +### **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. + + + +* **Return type** + + [`str`](https://docs.python.org/3/library/stdtypes.html#str) + + + +#### 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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** nef_schema_version(: NefSchemaVersion) +NefSchemaVersion: Schema version of nef. + + + +* **Return type** + + `NefSchemaVersion` + + + +#### **_property_** platform(: [str](https://docs.python.org/3/library/stdtypes.html#str)) +str: Target device platform USB dongle, 96 board, etc. + + + +* **Return type** + + [`str`](https://docs.python.org/3/library/stdtypes.html#str) + + + +#### **_property_** toolchain_version(: [str](https://docs.python.org/3/library/stdtypes.html#str)) +str: Toolchain version of all models. + + + +* **Return type** + + [`str`](https://docs.python.org/3/library/stdtypes.html#str) + + + +--- + +### **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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** minor(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Minor number. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** revision(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Revision number. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +--- + +### **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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** f0_time(: [float](https://docs.python.org/3/library/functions.html#float)) +float: time of performance monitor mode f0. + + + +* **Return type** + + [`float`](https://docs.python.org/3/library/functions.html#float) + + + +#### **_property_** f1(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Value of performance monitor mode f1. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** f1_time(: [float](https://docs.python.org/3/library/functions.html#float)) +float: time of performance monitor mode f1. + + + +* **Return type** + + [`float`](https://docs.python.org/3/library/functions.html#float) + + + +#### **_property_** f2(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Value of performance monitor mode f2. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** f2_time(: [float](https://docs.python.org/3/library/functions.html#float)) +float: time of performance monitor mode f2. + + + +* **Return type** + + [`float`](https://docs.python.org/3/library/functions.html#float) + + + +#### **_property_** f3(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Value of performance monitor mode f3. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** f3_time(: [float](https://docs.python.org/3/library/functions.html#float)) +float: time of performance monitor mode f3. + + + +* **Return type** + + [`float`](https://docs.python.org/3/library/functions.html#float) + + + +#### **_property_** f4(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Value of performance monitor mode f4. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** f4_time(: [float](https://docs.python.org/3/library/functions.html#float)) +float: time of performance monitor mode f4. + + + +* **Return type** + + [`float`](https://docs.python.org/3/library/functions.html#float) + + + +#### **_property_** f5(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Value of performance monitor mode f5. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** f5_time(: [float](https://docs.python.org/3/library/functions.html#float)) +float: time of performance monitor mode f5. + + + +* **Return type** + + [`float`](https://docs.python.org/3/library/functions.html#float) + + + +#### **_property_** f6(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Value of performance monitor mode f6. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** f6_time(: [float](https://docs.python.org/3/library/functions.html#float)) +float: time of performance monitor mode f6. + + + +* **Return type** + + [`float`](https://docs.python.org/3/library/functions.html#float) + + + +#### **_property_** f7(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Value of performance monitor mode f7. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** f7_time(: [float](https://docs.python.org/3/library/functions.html#float)) +float: time of performance monitor mode f7. + + + +* **Return type** + + [`float`](https://docs.python.org/3/library/functions.html#float) + + + +#### 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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** npu_clock_rate(: [int](https://docs.python.org/3/library/functions.html#int)) +int: NPU clock rate. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +--- + +### **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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_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. + + + +* **Return type** + + [`List`](https://docs.python.org/3/library/typing.html#typing.List)[`NpuPerformanceMonitorStatistics`] + + + +--- + +### **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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_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. + + + +* **Return type** + + [`List`](https://docs.python.org/3/library/typing.html#typing.List)[`ProfileModelStatistics`] + + + +--- + +### **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. + + + +* **Return type** + + [`float`](https://docs.python.org/3/library/functions.html#float) + + + +#### **_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. + + + +* **Return type** + + [`float`](https://docs.python.org/3/library/functions.html#float) + + + +#### **_property_** avg_inference_ms(: [float](https://docs.python.org/3/library/functions.html#float)) +float: Average inference time in milliseconds. + + + +* **Return type** + + [`float`](https://docs.python.org/3/library/functions.html#float) + + + +#### **_property_** avg_post_process_ms(: [float](https://docs.python.org/3/library/functions.html#float)) +float: Average post-process time in milliseconds. + + + +* **Return type** + + [`float`](https://docs.python.org/3/library/functions.html#float) + + + +#### **_property_** avg_pre_process_ms(: [float](https://docs.python.org/3/library/functions.html#float)) +float: Average pre-process time in milliseconds. + + + +* **Return type** + + [`float`](https://docs.python.org/3/library/functions.html#float) + + + +#### **_property_** cpu_op_count(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Number of CPU operation per inference. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### 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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** model_id(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Target inference model ID. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +--- + +### **class** kp.QuantizationParameters(quantized_fixed_point_descriptor_list=[]) +Quantization parameters for tensor. + + +* **Attributes** + + * `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_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. + + + +* **Return type** + + [`List`](https://docs.python.org/3/library/typing.html#typing.List)[`QuantizedFixedPointDescriptor`] + + + +--- + +### **class** kp.QuantizedFixedPointDescriptor(scale=0, radix=0) +Quantization parameters for fixed-point value. + + +* **Attributes** + + * `scale` : [`float`](https://docs.python.org/3/library/functions.html#float), default=0 + + 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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** scale(: [float](https://docs.python.org/3/library/functions.html#float)) +float: Scale for fixed/floating point conversion. + + + +* **Return type** + + [`float`](https://docs.python.org/3/library/functions.html#float) + + + +--- + +### **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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** minor(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Minor number. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** revision(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Revision number. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +--- + +### **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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** minor(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Minor number. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** revision(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Revision number. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +--- + +### **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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** input_nodes(: [List](https://docs.python.org/3/library/typing.html#typing.List)[TensorDescriptor]) +List[TensorDescriptor]: List of model input node tensor information. + + + +* **Return type** + + [`List`](https://docs.python.org/3/library/typing.html#typing.List)[`TensorDescriptor`] + + + +#### **_property_** max_raw_out_size(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Needed raw output buffer size for this model. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** output_nodes(: [List](https://docs.python.org/3/library/typing.html#typing.List)[TensorDescriptor]) +List[TensorDescriptor]: List of model output node tensor information. + + + +* **Return type** + + [`List`](https://docs.python.org/3/library/typing.html#typing.List)[`TensorDescriptor`] + + + +#### **_property_** setup_file_schema_version(: SetupFileSchemaVersion) +SetupFileSchemaVersion: File schema version of setup. + + + +* **Return type** + + `SetupFileSchemaVersion` + + + +#### **_property_** setup_schema_version(: SetupSchemaVersion) +SetupSchemaVersion: Schema version of setup. + + + +* **Return type** + + `SetupSchemaVersion` + + + +#### **_property_** target_chip(: [ModelTargetChip](enum.md#kp.ModelTargetChip)) +ModelTargetChip: Target chip of model. + + + +* **Return type** + + [`ModelTargetChip`](enum.md#kp.ModelTargetChip) + + + +#### **_property_** version(: [int](https://docs.python.org/3/library/functions.html#int)) +int: Version of model. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +--- + +### **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='', shape_npu=[], shape_onnx=[], data_layout=ModelTensorDataLayout.KP_MODEL_TENSOR_DATA_LAYOUT_UNKNOWN, quantization_parameters={'quantized_fixed_point_descriptor_list': {}}) +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. + + * `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. + + * `data_layout` : [`ModelTensorDataLayout`](enum.md#kp.ModelTensorDataLayout), default=ModelTensorDataLayout.KP_MODEL_TENSOR_DATA_LAYOUT_UNKNOWN + + ModelTensorDataLayout: NPU data layout of the tensor. + + * `quantization_parameters` : `QuantizationParameters`, default=QuantizationParameters() + + QuantizationParameters: Quantization parameters f the tensor. + + + + +#### **_property_** data_layout(: [ModelTensorDataLayout](enum.md#kp.ModelTensorDataLayout)) +ModelTensorDataLayout: NPU data layout of the tensor. + + + +* **Return type** + + [`ModelTensorDataLayout`](enum.md#kp.ModelTensorDataLayout) + + + +#### 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. + + + +* **Return type** + + [`int`](https://docs.python.org/3/library/functions.html#int) + + + +#### **_property_** name(: [str](https://docs.python.org/3/library/stdtypes.html#str)) +str: Name of the tensor. + + + +* **Return type** + + [`str`](https://docs.python.org/3/library/stdtypes.html#str) + + + +#### **_property_** quantization_parameters(: QuantizationParameters) +QuantizationParameters: Quantization parameters f the tensor. + + + +* **Return type** + + `QuantizationParameters` + + + +#### **_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). + + + +* **Return type** + + [`List`](https://docs.python.org/3/library/typing.html#typing.List)[[`int`](https://docs.python.org/3/library/functions.html#int)] + + + +#### **_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. + + + +* **Return type** + + [`List`](https://docs.python.org/3/library/typing.html#typing.List)[[`int`](https://docs.python.org/3/library/functions.html#int)] diff --git a/docs/plus_python/api_document/index.md b/docs/plus_python/api_document/index.md index 42a33f3..c0e2b0c 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 - - [V2.2.0](./V2.2.0/) + - [V2.3.0](./V2.3.0/) * Archive + - [V2.2.0](./V2.2.0/) - [V2.1.0](./V2.1.0/) - [V2.0.0](./V2.0.0/) - [V1.3.0](./V1.3.0/) diff --git a/docs/plus_python/getting_start.md b/docs/plus_python/getting_start.md index 73cf2c3..e0236d3 100644 --- a/docs/plus_python/getting_start.md +++ b/docs/plus_python/getting_start.md @@ -1,6 +1,6 @@ # Getting Started -> **Note 1**: We run the examples below under OS Ubuntu 18.04.5 LTS with Kenron KL520/KL720 AI device. +> **Note 1**: We run the examples below under OS Ubuntu 18.04.5 LTS with Kenron KL520/KL630/KL720/KL730 AI device. > **Note 2**: The example below is under the assumption that device is connected and recognized by host machine correctly. For the operations, please refer to section [Install dependency](./introduction/install_dependency.md) @@ -191,6 +191,50 @@ $ sudo sh KneronDFUT.sh --help ==== Update Firmware to Device with Port Id: 262 Succeeded ==== ``` +### 2.4 KL730 + +1. Use GUI to Update AI Device + + ```bash + $ sudo sh KneronDFUT.sh + ``` + + * Select the AI device to be update to KDP2 firmware + + * Push **Run** button + \(**Update to USB Boot** should be checked by default\) + + ![](./imgs/dfut_kl730_usb_boot.png) + +2. Use Command Line to Update AI Device + + ```bash + $ sudo sh KneronDFUT.sh --list + ``` + + ```bash + =========================================== + Index: 1 + Port Id: 13 + Kn Number: 0x19611034 + Device Type: KL730 + FW Type: KDP2 + Usb Speed: Super-Speed + Connectable: true + =========================================== + ``` + + ```bash + $ sudo sh KneronDFUT.sh --kl730-usb-boot --port 13 + ``` + + ```bash + Start Update Device with Port Id 13 to USB Boot + + ==== Update of Device with Port Id: 13 Succeeded ==== + ``` + + --- ## 3. Install Kneron PLUS Python Package @@ -339,7 +383,209 @@ Besides output results in the screen console, it also draws detected objects in ![](./imgs/ex_kdp2_kl520_generic_inference_raw.bmp) -#### 4.1.2 KL720 Generic Inference Example +#### 4.1.2 KL630 Generic Inference Example +The **'KL630DemoGenericImageInferencePostYolo.py'** is an example for showing how it work. + +By default, it runs with a YOLO v5s model NEF and takes an BMP image as input and does post-process in host side. + +```bash +$ python KL630DemoGenericImageInferencePostYolo.py + +[Connect Device] + - Success +[Set Device Timeout] + - Success +[Upload Firmware] + - Success +[Upload Model] + - Success +[Read Image] + - Success +[Starting Inference Work] + - Starting inference loop 50 times + - .................................................. +[Retrieve Inference Node Output ] + - Success +[Yolo V5s Post-Processing] + - Success +[Result] +{ + "class_count": 80, + "box_count": 20, + "box_list": { + "0": { + "x1": 45, + "y1": 71, + "x2": 94, + "y2": 182, + "score": 0.8449, + "class_num": 0 + }, + "1": { + "x1": 59, + "y1": 128, + "x2": 87, + "y2": 203, + "score": 0.5845, + "class_num": 1 + }, + "2": { + "x1": 96, + "y1": 90, + "x2": 131, + "y2": 123, + "score": 0.8682, + "class_num": 2 + }, + "3": { + "x1": 0, + "y1": 79, + "x2": 38, + "y2": 176, + "score": 0.8558, + "class_num": 2 + }, + "4": { + "x1": 111, + "y1": 78, + "x2": 132, + "y2": 91, + "score": 0.7229, + "class_num": 2 + }, + "5": { + "x1": 32, + "y1": 79, + "x2": 53, + "y2": 94, + "score": 0.6963, + "class_num": 2 + }, + "6": { + "x1": 87, + "y1": 76, + "x2": 100, + "y2": 85, + "score": 0.6006, + "class_num": 2 + }, + "7": { + "x1": 52, + "y1": 81, + "x2": 68, + "y2": 95, + "score": 0.5999, + "class_num": 2 + }, + "8": { + "x1": 119, + "y1": 77, + "x2": 223, + "y2": 174, + "score": 0.5981, + "class_num": 2 + }, + "9": { + "x1": 102, + "y1": 77, + "x2": 110, + "y2": 85, + "score": 0.4883, + "class_num": 2 + }, + "10": { + "x1": 82, + "y1": 77, + "x2": 87, + "y2": 82, + "score": 0.3307, + "class_num": 2 + }, + "11": { + "x1": 88, + "y1": 72, + "x2": 104, + "y2": 84, + "score": 0.1816, + "class_num": 2 + }, + "12": { + "x1": 83, + "y1": 76, + "x2": 95, + "y2": 84, + "score": 0.1577, + "class_num": 2 + }, + "13": { + "x1": 55, + "y1": 82, + "x2": 68, + "y2": 90, + "score": 0.155, + "class_num": 2 + }, + "14": { + "x1": 118, + "y1": 78, + "x2": 223, + "y2": 175, + "score": 0.3757, + "class_num": 7 + }, + "15": { + "x1": 194, + "y1": 68, + "x2": 199, + "y2": 74, + "score": 0.3488, + "class_num": 9 + }, + "16": { + "x1": 59, + "y1": 89, + "x2": 92, + "y2": 121, + "score": 0.4136, + "class_num": 24 + }, + "17": { + "x1": 80, + "y1": 92, + "x2": 93, + "y2": 120, + "score": 0.3071, + "class_num": 24 + }, + "18": { + "x1": 47, + "y1": 90, + "x2": 79, + "y2": 123, + "score": 0.177, + "class_num": 24 + }, + "19": { + "x1": 46, + "y1": 94, + "x2": 63, + "y2": 124, + "score": 0.1531, + "class_num": 24 + } + } +} +[Output Result Image] + - Output bounding boxes on 'output_bike_cars_street_224x224.bmp' +``` + +From the console output, it can be observed that the information of models in the NEF is printed, including model ID, raw resolution, input channel, raw image format and raw output size. + +Besides output results in the screen console, it also draws detected objects in a new-created **output_bike_cars_street_224x224.bmp**. + +![](./imgs/ex_kdp2_kl630_generic_inference_raw.bmp) + +#### 4.1.3 KL720 Generic Inference Example The **'KL720DemoGenericImageInferencePostYolo.py'** is an example for showing how it work. By default, it runs with a YOLO v5s model NEF and takes an BMP image as input and does post-process in host side. @@ -465,4 +711,206 @@ From the console output, it can be observed that the information of models in th Besides output results in the screen console, it also draws detected objects in a new-created **output_car_park_barrier_608x608.bmp**. -![](./imgs/ex_kdp2_kl720_generic_inference_raw.bmp) \ No newline at end of file +![](./imgs/ex_kdp2_kl720_generic_inference_raw.bmp) + +#### 4.1.4 KL730 Generic Inference Example +The **'KL730DemoGenericImageInferencePostYolo.py'** is an example for showing how it work. + +By default, it runs with a YOLO v5s model NEF and takes an BMP image as input and does post-process in host side. + +```bash +$ python KL730DemoGenericImageInferencePostYolo.py + +[Connect Device] + - Success +[Set Device Timeout] + - Success +[Upload Firmware] + - Success +[Upload Model] + - Success +[Read Image] + - Success +[Starting Inference Work] + - Starting inference loop 50 times + - .................................................. +[Retrieve Inference Node Output ] + - Success +[Yolo V5s Post-Processing] + - Success +[Result] +{ + "class_count": 80, + "box_count": 20, + "box_list": { + "0": { + "x1": 46, + "y1": 71, + "x2": 93, + "y2": 182, + "score": 0.8372, + "class_num": 0 + }, + "1": { + "x1": 59, + "y1": 129, + "x2": 87, + "y2": 202, + "score": 0.6383, + "class_num": 1 + }, + "2": { + "x1": 96, + "y1": 90, + "x2": 131, + "y2": 123, + "score": 0.8604, + "class_num": 2 + }, + "3": { + "x1": 0, + "y1": 80, + "x2": 38, + "y2": 175, + "score": 0.8552, + "class_num": 2 + }, + "4": { + "x1": 110, + "y1": 78, + "x2": 133, + "y2": 91, + "score": 0.7306, + "class_num": 2 + }, + "5": { + "x1": 32, + "y1": 79, + "x2": 52, + "y2": 95, + "score": 0.7114, + "class_num": 2 + }, + "6": { + "x1": 52, + "y1": 81, + "x2": 68, + "y2": 94, + "score": 0.6152, + "class_num": 2 + }, + "7": { + "x1": 118, + "y1": 79, + "x2": 223, + "y2": 174, + "score": 0.6088, + "class_num": 2 + }, + "8": { + "x1": 87, + "y1": 76, + "x2": 101, + "y2": 85, + "score": 0.5875, + "class_num": 2 + }, + "9": { + "x1": 102, + "y1": 77, + "x2": 110, + "y2": 84, + "score": 0.5383, + "class_num": 2 + }, + "10": { + "x1": 82, + "y1": 77, + "x2": 87, + "y2": 82, + "score": 0.2922, + "class_num": 2 + }, + "11": { + "x1": 45, + "y1": 80, + "x2": 63, + "y2": 95, + "score": 0.2365, + "class_num": 2 + }, + "12": { + "x1": 14, + "y1": 68, + "x2": 27, + "y2": 81, + "score": 0.1773, + "class_num": 2 + }, + "13": { + "x1": 83, + "y1": 77, + "x2": 94, + "y2": 84, + "score": 0.1514, + "class_num": 2 + }, + "14": { + "x1": 116, + "y1": 79, + "x2": 223, + "y2": 175, + "score": 0.4219, + "class_num": 7 + }, + "15": { + "x1": 194, + "y1": 68, + "x2": 199, + "y2": 74, + "score": 0.4651, + "class_num": 9 + }, + "16": { + "x1": 62, + "y1": 90, + "x2": 88, + "y2": 120, + "score": 0.4238, + "class_num": 24 + }, + "17": { + "x1": 46, + "y1": 89, + "x2": 71, + "y2": 123, + "score": 0.3418, + "class_num": 24 + }, + "18": { + "x1": 80, + "y1": 92, + "x2": 93, + "y2": 121, + "score": 0.3196, + "class_num": 24 + }, + "19": { + "x1": 52, + "y1": 82, + "x2": 69, + "y2": 94, + "score": 0.1712, + "class_num": 24 + } + } +} +[Output Result Image] + - Output bounding boxes on 'output_bike_cars_street_224x224.bmp' +``` + +From the console output, it can be observed that the information of models in the NEF is printed, including model ID, raw resolution, input channel, raw image format and raw output size. + +Besides output results in the screen console, it also draws detected objects in a new-created **output_bike_cars_street_224x224.bmp**. + +![](./imgs/ex_kdp2_kl730_generic_inference_raw.bmp) diff --git a/docs/plus_python/imgs/dfut_kl730_flash_boot.png b/docs/plus_python/imgs/dfut_kl730_flash_boot.png new file mode 100644 index 0000000..ee38f80 --- /dev/null +++ b/docs/plus_python/imgs/dfut_kl730_flash_boot.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4c82dea5441768dfea72077d5f8d38039cb469b4dd965eb750a2c3bf3379080d +size 20176 diff --git a/docs/plus_python/imgs/dfut_kl730_model.png b/docs/plus_python/imgs/dfut_kl730_model.png new file mode 100644 index 0000000..f815d3d --- /dev/null +++ b/docs/plus_python/imgs/dfut_kl730_model.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d8545392786e30763e867115920a0dbf852b0420018a5b67b36a744cbd683067 +size 19994 diff --git a/docs/plus_python/imgs/dfut_kl730_usb_boot.png b/docs/plus_python/imgs/dfut_kl730_usb_boot.png new file mode 100644 index 0000000..6193f89 --- /dev/null +++ b/docs/plus_python/imgs/dfut_kl730_usb_boot.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c65d0511770e0c19f57731d99e93bb48d2ca25e1bf2f785a10209ee492a31ee6 +size 20343 diff --git a/docs/plus_python/imgs/ex_kdp2_kl630_generic_inference_raw.bmp b/docs/plus_python/imgs/ex_kdp2_kl630_generic_inference_raw.bmp new file mode 100644 index 0000000..3a005a5 Binary files /dev/null and b/docs/plus_python/imgs/ex_kdp2_kl630_generic_inference_raw.bmp differ diff --git a/docs/plus_python/imgs/ex_kdp2_kl730_generic_inference_raw.bmp b/docs/plus_python/imgs/ex_kdp2_kl730_generic_inference_raw.bmp new file mode 100644 index 0000000..4b01752 Binary files /dev/null and b/docs/plus_python/imgs/ex_kdp2_kl730_generic_inference_raw.bmp differ diff --git a/docs/plus_python/imgs/zadig_install_kl730_driver.png b/docs/plus_python/imgs/zadig_install_kl730_driver.png new file mode 100644 index 0000000..0eabcad --- /dev/null +++ b/docs/plus_python/imgs/zadig_install_kl730_driver.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6472dded4f0a753218f3082736f93dd4efb61845d4da98f5cc55df5aa9f7ab8e +size 21043 diff --git a/docs/plus_python/introduction/install_dependency.md b/docs/plus_python/introduction/install_dependency.md index 07a73e2..9cae02a 100644 --- a/docs/plus_python/introduction/install_dependency.md +++ b/docs/plus_python/introduction/install_dependency.md @@ -100,7 +100,7 @@ Note: This feature is only provided in Kneron PLUS v1.3.0 and above. - Click "Install Driver" button. -2. KL720 +3. KL720 - The application should detect Kneron KL720 device as "Kneron KL720" with USB ID "3231/0200" as shown below: @@ -113,6 +113,17 @@ Note: This feature is only provided in Kneron PLUS v1.3.0 and above. **Note**: After Upgrade Kneron KL720 to KDP2 (ex. via Kneron DFUT), you may need to re-install the driver of KL720, since the USB ID will be changed to "3231/0720". +4. KL730 + + - The application should detect Kneron KL730 device as "Kneron KL730" with USB ID + "3231/0732" as shown below: + + ![](../imgs/zadig_install_kl730_driver.png) + + - Make sure that the Driver field, has WinUSB option selected. + + - Click "Install Driver" button. + ## 3. Update Kneron AI Device USB Permission on Ubuntu/Raspberry Pi * Config USB permission on Ubuntu/Raspberry Pi @@ -126,6 +137,7 @@ Note: This feature is only provided in Kneron PLUS v1.3.0 and above. SUBSYSTEM=="usb",ATTRS{product}=="Kneron KL720l",ATTRS{idVendor}=="3231",ATTRS{idProduct}=="0200",MODE="0666" SUBSYSTEM=="usb",ATTRS{product}=="Kneron KL720",ATTRS{idVendor}=="3231",ATTRS{idProduct}=="0720",MODE="0666" SUBSYSTEM=="usb",ATTRS{product}=="Kneron KL630",ATTRS{idVendor}=="3231",ATTRS{idProduct}=="0630",MODE="0666" + SUBSYSTEM=="usb",ATTRS{product}=="Kneron KL730",ATTRS{idVendor}=="3231",ATTRS{idProduct}=="0732",MODE="0666" ``` and apply the new rules by following commands (Or you may need to restart the service after rebooting the host PC) ```bash diff --git a/docs/plus_python/introduction/introduction.md b/docs/plus_python/introduction/introduction.md index 6aa90b5..e94836a 100644 --- a/docs/plus_python/introduction/introduction.md +++ b/docs/plus_python/introduction/introduction.md @@ -2,7 +2,7 @@ ## Basic Features -**Kneron PLUS** stands for *Platform Library Unified Software* which is a framework comprising new software(SW) and firmware(FW) design for KL520 and KL720 (and alpha for KL630). +**Kneron PLUS** stands for *Platform Library Unified Software* which is a framework comprising new software(SW) and firmware(FW) design for KL520, KL720, and KL630 (and alpha for KL730). In order to run the inference of models on Kneron AI devices, there are three parts of AI application development are required: @@ -31,57 +31,54 @@ Below gives some definitions regarding the Kneron PLUS: The features which PLUS Supported are listed below: -Index | Category | Supported Item | Min Version (KL520/KL720) | Min Version (KL630) [***1***] | KL520 | KL720 | KL630 -------- | :-------------------- | :------------------------------------------------------------------------ | :------------------------ | :---------------------------- | :---: | :---: | :---: -1 | Image Format | RGBA8888 , RAW8 , Packed YCbCr422 (YUYV422) , RGB565 | | | | | -2 | | Planar YUV420 | | | X | X | -3 | System | Firmware In Flash | | | | | -4 | | Model In Flash | | | | | -5 | | Runtime Upload Firmware | | | | X | -6 | | Runtime Upload Model | | | | | -7 | | Software Reset | | | | | -8 | | Software Shutdown (Developing Broad Only) | | | | X | X -9 | | Software Reboot | | | | | -10 | | Scan Devices | | | | | -11 | | Device Log via USB | | | X | | X -12 | | Device Connection : All Devices, Specified Device(s) | | | | | -13 | Inference | Flexible Send / Receive Inference | | | | | -14 | | Multiple Device Auto Dispatch | | | | | -15 | | Enable / Disable Pre-process on Device | | | | | -16 | | Enable / Disable Post-process on Device | | | | | -17 | | Output Floating Point / Fixed Point Result | | | | | -18 | | Enable / Disable Debug Checkpoints | v1.3.0 | | | | -19 | | Enable / Disable Execution Time Profiling | v1.3.0 | | | | -20 | System / Model Info | Get Firmware Version | | | | | -21 | | Get KN Number | | | | | -22 | | Get Model CRC | | | | | -23 | | Get Model Info | | | | | -24 | | Install Device Driver for Windows | v1.3.0 | | | | -25 | Application API | Generic Image Inference | v2.0.0 | | | | -26 | | Generic Data Inference | v2.0.0 | | | | -27 | | Customized Inference (C code only) | | | | | -28 | | User Define API (C code only) | | | | | -29 | System Examples | Get Firmware Info | | | | | -30 | | Get Model Info | | | | | -31 | | Reboot Device | | | | | -32 | | Shutdown Device | | | | X | X -33 | | Device FIFO Queue Config Example | v2.0.0 | | | | -34 | Inference Examples | Generic Image Inference (Raw Output) | v2.0.0 | | | | -35 | | Generic Image Inference (with Crop) | v2.0.0 | | | | -36 | | Generic Image Inference (with Post Process on Host Side) | v2.0.0 | | | | -37 | | Generic Image Inference (Multiple Threads) | v2.0.0 | | | | -38 | | Generic Image Inference (Model in Flash) | v2.0.0 | | | | -39 | | Generic Image Inference (Web Cam with Drop Frame) | v2.0.0 | | | | -40 | | Generic Data Inference (with Pre Process on Host Side) | v2.0.0 | | | | -41 | | User Define API Inference (Yolo with Config Post Process) (C code only) | v1.3.0 | | | | -42 | | Customized Inference with Single Model (C code only) | v2.0.0 for KL720 | | | | -43 | | Customized Inference with Multiple Models (C code only) | v2.0.0 for KL720 | | | | -44 | Debug Examples | Debug Checkpoints Example | v1.3.0 | | | X | X -45 | | Execution Time Profiling Example | v1.3.0 | | | X | X -46 | Model Zoo Examples | Simple examples for pre-trained models | | | | | X - -**Note**: -- [1] If the minimum version is not written, this feature is supported from v2.1.1. +Index | Category | Supported Item | Minimum Version | KL520 | KL720 | KL630 | KL730 +------- | :-------------------- | :------------------------------------------------------------------------ | :---------------- | :---: | :---: | :---: | :---: +1 | Image Format | RGBA8888 , RAW8 , Packed YCbCr422 (YUYV422) , RGB565 | | | | | +2 | | Planar YUV420 | v2.1.0 | X | X | | +3 | System | Firmware In Flash | | | | | +4 | | Model In Flash | | | | | +5 | | Runtime Upload Firmware | | | X | | +6 | | Runtime Upload Model | | | | | +7 | | Software Reset | | | | | +8 | | Software Shutdown (Developing Broad Only) | | | X | X | X +9 | | Software Reboot | | | | | +10 | | Scan Devices | | | | | +11 | | Device Log via USB | | | | | +12 | | Device Connection : All Devices, Specified Device(s) | | | | | +13 | Inference | Flexible Send / Receive Inference | | | | | +14 | | Multiple Device Auto Dispatch | | | | | +15 | | Enable / Disable Pre-process on Device | | | | | +16 | | Enable / Disable Post-process on Device | | | | | +17 | | Output Floating Point / Fixed Point Result | | | | | +18 | | Enable / Disable Debug Checkpoints | | X | X | X | X +19 | | Enable / Disable Execution Time Profiling | v2.1.0 | | | X | X +20 | System / Model Info | Get Firmware Version | | | | | +21 | | Get KN Number | | | | | +22 | | Get Model CRC | | | | | +23 | | Get Model Info | | | | | +24 | | Install Device Driver for Windows | v1.3.0 | | | | +25 | Application API | Generic Image Inference | v2.0.0 | | | | +26 | | Generic Data Inference | v2.0.0 | | | | +27 | | Customized Inference (C code only) | | | | | +28 | | User Define API (C code only) | | | | | +29 | System Examples | Get Firmware Info | | | | | +30 | | Get Model Info | | | | | +31 | | Reboot Device | | | | | +32 | | Shutdown Device | | | X | X | X +33 | | Device Memory Usage Control | v2.0.0 | | | | +34 | Inference Examples | Generic Image Inference (Raw Output) | v2.0.0 | | | | +35 | | Generic Image Inference (with Crop) | v2.0.0 | | | | +36 | | Generic Image Inference (with Post Process on Host Side) | v2.0.0 | | | | +37 | | Generic Image Inference (Multiple Threads) | v2.0.0 | | | | +38 | | Generic Image Inference (Model in Flash) | v2.0.0 | | | | +39 | | Generic Image Inference (Web Cam with Drop Frame) | v2.0.0 | | | | +40 | | Generic Data Inference (with Pre Process on Host Side) | v2.0.0 | | | | +41 | | User Define API Inference (Yolo with Config Post Process) (C code only) | v1.3.0 | | | | +42 | | Customized Inference with Single Model (C code only) | v2.0.0 for KL720 | | | | +43 | | Customized Inference with Multiple Models (C code only) | v2.0.0 for KL720 | | | | +44 | Debug Examples | Debug Checkpoints Example | | X | X | X | X +45 | | Execution Time Profiling Example | | X | X | X | X +46 | Model Zoo Examples | Simple examples for pre-trained models | | | | X | X The following components are contained in Kneron PLUS: @@ -102,21 +99,21 @@ Besides the basic features, there are few advanced features provided in Kneron P **Note**: Most of the advanced features and examples are C code only. Only **Update Kdp2 to Kdp2 Flash Boot** has the python version example. -Index | Category | Supported Item | Min Version (KL520/KL720) | Min Version (KL630) | KL520 | KL720 | KL630 -------- | :-------------------- | :-------------------------------------------------------- | :------------------------ | :-------------------- | :---: | :---: | :---: -1 | System | Runtime Upload Firmware via UART | | | | X | X -2 | | Hico Mode (MIPI image input, Companion Result Output) | | v2.1.1 | | | -3 | Examples | Update Kdp to Kdp2 Usb Boot | | | | X | X -4 | | Update Kdp2 to Kdp2 Usb Boot | | v2.1.1 | | X | -5 | | Update Kdp to Kdp2 Flash Boot | | | | | X -6 | | Update Kdp2 to Kdp2 Flash Boot | | v2.1.1 | | | -7 | | Update Model to Flash | | v2.1.1 | | | -8 | | Upload Firmware via UART | | | | X | X -9 | | Upload Firmware via Usb for No-Flash Device | v2.0.0 | | X | | X -10 | | Read / Write Device Memory | | | | | X -11 | | Access Firmware Log via USB | | | X | | X -12 | | Hico Cam Inference [***1***] [***2***] [***3***] | | v2.1.1 | | | -13 | | Hico ToF Inference (Kneron ToF module is required) | v1.3.0 | | X | | X +Index | Category | Supported Item | Min Version (KL520/KL720) | Min Version (KL630) | KL520 | KL720 | KL630 | KL730 +------- | :-------------------- | :-------------------------------------------------------- | :------------------------ | :-------------------- | :---: | :---: | :---: | :---: +1 | System | Runtime Upload Firmware via UART | | | | X | X | X +2 | | Hico Mode (MIPI image input, Companion Result Output) | | v2.1.1 | | | | X +3 | Examples | Update Kdp to Kdp2 Usb Boot | | | | X | X | X +4 | | Update Kdp2 to Kdp2 Usb Boot | | v2.1.1 | | X | | +5 | | Update Kdp to Kdp2 Flash Boot | | | | | X | X +6 | | Update Kdp2 to Kdp2 Flash Boot | | v2.1.1 | | | | +7 | | Update Model to Flash | | v2.1.1 | | | | +8 | | Upload Firmware via UART | | | | X | X | X +9 | | Upload Firmware via Usb for No-Flash Device | v2.0.0 | | X | | X | X +10 | | Read / Write Device Memory | | | | | X | X +11 | | Access Firmware Log via USB | | | X | | X | X +12 | | Hico Cam Inference [***1***] [***2***] [***3***] | | v2.1.1 | | | | X +13 | | Hico ToF Inference (Kneron ToF module is required) | v1.3.0 | | X | | X | X **Note**: diff --git a/docs/plus_python/introduction/run_examples.md b/docs/plus_python/introduction/run_examples.md index 58ea6bc..7c45c26 100644 --- a/docs/plus_python/introduction/run_examples.md +++ b/docs/plus_python/introduction/run_examples.md @@ -2,7 +2,7 @@ The provided examples are designed to show how to use KP APIs and present Kneron Device features. Error handling, wording and application layer features are not covered. They are open for more creatives. -> **Note 1**: In the inference related examples, we are using KL520 for most demo. If you wish to use KL630 or KL720, just change the prefix of the example name from kl520 to kl630 or kl720. +> **Note 1**: In the inference related examples, we are using KL520 for most demo. If you wish to use KL630, KL720, or KL730, just change the prefix of the example name from kl520 to kl630, kl720, or kl730. > **Note 2**: **[Ubuntu]** Please update Kneron device USB permission before following steps on Ubuntu. See the [Installation ](./install_dependency.md) for details. @@ -118,6 +118,20 @@ Note: This example is only available on Windows 10, and it must be run as Admini - Success ``` +4. For installing the driver for KL730: + + ```bash + $ python3 InstallDriverWindows.py --target KL730 + ``` + + ```bash + [Note] + - You must run this app as administrator on Windows + [Installing Driver] + - [KP_DEVICE_KL730] + - Success + ``` + --- ## 3. Load Firmware and Model Example diff --git a/docs/plus_python/introduction/run_examples_enterprise.md b/docs/plus_python/introduction/run_examples_enterprise.md index da868d7..a8d987a 100644 --- a/docs/plus_python/introduction/run_examples_enterprise.md +++ b/docs/plus_python/introduction/run_examples_enterprise.md @@ -2,7 +2,7 @@ Other than the examples briefed in [Run Examples](./run_examples.md), Kneron PLUS Enterprise also provides few examples for demonstrating the usage of advanced features. -**Note 1**: In the inference related examples, we are using KL520 for most demo. If you wish to use KL630 or KL720, just change the prefix of the example name from kl520 to kl630 or kl720. (There might be no KL520 version, KL630 version or KL720 version on certain examples.) +**Note 1**: In the inference related examples, we are using KL520 for most demo. If you wish to use KL630, KL720, or KL730, just change the prefix of the example name from kl520 to kl630, kl720, or kl730. (There might be no KL520 version, KL630 version, KL720 version, or KL730 version on certain examples.) **Note 2**: Few examples will auto connect multiple devices to run inference. If you put hybrid types of devices on host, the inference may fail. 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 808e664..e855e95 100644 --- a/docs/plus_python/introduction/upgrade_ai_device_to_kdp2.md +++ b/docs/plus_python/introduction/upgrade_ai_device_to_kdp2.md @@ -86,6 +86,15 @@ $ sudo sh KneronDFUT.sh --help --port : [argument required] port id set ("all" or specified multiple port ids "13,537") --scpu : [argument required] self pointed firmware file path (.tar) +[Update dongles to usb boot] (Only works for KL730) + --kl730-usb-boot : [no argument] choose update to Usb Boot + --port : [argument required] port id set ("all" or specified multiple port ids "13,537") + +[Update dongles to usb boot] (Only works for KL730) + --kl730-flash-boot : [no argument] choose update to Flash Boot + --port : [argument required] port id set ("all" or specified multiple port ids "13,537") + --scpu : [argument required] self pointed firmware file path (.tar) + [Update firmware file to flash memory in dongles] (Only works for KL720) --kl720-update : [no argument] choose write firmware to flash memory --port : [argument required] port id set ("all" or specified multiple port ids "13,537") @@ -94,7 +103,7 @@ $ sudo sh KneronDFUT.sh --help [Update model file to flash memory in dongles] --model-to-flash : [argument required] self pointed model file path (.nef) - --type : [argument required] type of device ("KL520", "KL630", or "KL720") + --type : [argument required] type of device ("KL520", "KL630", "KL720", or "KL730") --port : [argument required] port id set ("all" or specified multiple port ids "13,537") [Enable Graphic User Interface] @@ -108,7 +117,7 @@ $ sudo sh KneronDFUT.sh --help ## 3. Install Driver for Windows -When you execute any kind of update on Kneron DFUT, it will check whether the driver of KL520, KL630 or KL720 has been installed on Windows. If the driver has not been installed, Kneron DFUT will install the driver before any update. +When you execute any kind of update on Kneron DFUT, it will check whether the driver of KL520, KL630, KL720, or KL730 has been installed on Windows. If the driver has not been installed, Kneron DFUT will install the driver before any update. Note: Kneron DFUT only check and install driver when it was executed on Windows. @@ -418,3 +427,115 @@ $ sudo sh KneronDFUT.sh ``` SCPU and NCPU firmware file for KL720 can be found in **${PLUS_FOLDER}/res/firmware/KL720/** + +--- + +## 9. [KL730] Update to USB Boot Mode + +### 9.1 Use GUI to Update AI Device + +```bash +$ sudo sh KneronDFUT.sh +``` + +1. Select **KL730** Tab. + +2. Select the KL730 devices to be update to USB Boot Mode. + +3. Select **Update to USB Boot** + +4. Push **Run** button. + + ![](../imgs/dfut_kl730_usb_boot.png) + + +### 9.2 Use Command Line to Update AI Device + +1. List all devices + + ```bash + $ sudo sh KneronDFUT.sh --list + ``` + + ```bash + =========================================== + Index: 1 + Port Id: 133 + Kn Number: 0x270A265C + Device Type: KL730 + FW Type: KDP2 + Usb Speed: High-Speed + Connectable: true + =========================================== + ``` + +2. Upgrade the selected KL730 devices using the port id + + ```bash + $ sudo sh KneronDFUT.sh --kl730-usb-boot --port 133 + ``` + + ```bash + Start Update Device with Port Id 133 to USB Boot + + ==== Update of Device with Port Id: 133 Succeeded ==== + + ``` + + +--- + +## 10. [KL730] Update to Flash Boot Mode + +### 10.1 Use GUI to Update AI Device +```bash +$ sudo sh KneronDFUT.sh +``` + +1. Select **KL730** Tab. + +2. Select the KL730 devices to be **Update to Flash Boot** Mode. + +3. Select **Update to Flash Boot** + +4. Manually choose **SCPU firmware file**. + + SCPU firmware file for KL730 can be found in **${PLUS_FOLDER}/res/firmware/KL730/** + +5. Push **Run** button. + + ![](../imgs/dfut_kl730_flash_boot.png) + +### 10.2 Use Command Line to Update AI Device + +1. List all devices + + ```bash + $ sudo sh KneronDFUT.sh --list + ``` + + ```bash + =========================================== + Index: 1 + Port Id: 13 + Kn Number: 0x09011004 + Device Type: KL730 + FW Type: KDP2 + Usb Speed: Super-Speed + Connectable: true + =========================================== + ``` + +2. Upgrade the selected KL730 devices using the port id + + ```bash + $ sudo sh KneronDFUT.sh --kl730-flash-boot --port 13 --scpu ${SCPU_FILE_PATH} + ``` + + ```bash + Start Update Device with Port Id 13 to Flash Boot + + ==== Update of Device with Port Id: 13 Succeeded ==== + ``` + + SCPU firmware file for KL730 can be found in **${PLUS_FOLDER}/res/firmware/KL730/** diff --git a/docs/plus_python/introduction/write_model_to_flash.md b/docs/plus_python/introduction/write_model_to_flash.md index a874f8d..cbb2d17 100644 --- a/docs/plus_python/introduction/write_model_to_flash.md +++ b/docs/plus_python/introduction/write_model_to_flash.md @@ -24,6 +24,7 @@ There are two ways to load models: - **35 MB** for KL520 - **60 MB** for KL630 - **75 MB** for KL720 + - **350 MB** for KL730 (KL730 SDK default setting: 350MB, and this size can be enlarged in the firmware device tree.) - **Load Model from Flash** @@ -41,6 +42,7 @@ There are two ways to load models: - **32 MB** for KL520 - **55 MB** for KL630 - **70 MB** for KL720 + - **55 MB** for KL730 **Note**: Only one model file (.nef) can be loaded, no matter it was uploaded via USB or loaded from flash. If you want to change the model, please reboot the Kneron AI device. @@ -159,7 +161,7 @@ $ sudo sh KneronDFUT.sh =========================================== ``` -3. Write model into the selected KL520 devices using the port id +3. Write model into the selected KL630 devices using the port id ```bash $ sudo sh KneronDFUT.sh --model-to-flash ${MODEL_FILE_PATH} --port 13 -- type KL630 @@ -224,3 +226,57 @@ $ sudo sh KneronDFUT.sh ==== Update Model to Device with Port Id: 262 Succeeded ==== ``` + +--- + +## 6. Write Model Into KL730 + +### 6.1 Use GUI to Write Model into AI Device + +```bash +$ sudo sh KneronDFUT.sh +``` + +1. Select **KL730** Tab. + +2. Select the KL730 devices to write model into. + +3. Select **Update Model to Flash** + +4. Manually choose **Model file**. + +5. Push **Run** button. + + ![](../imgs/dfut_kl730_model.png) + +### 6.2 Use Command Line to Write Model into AI Device + +1. List all devices + + ```bash + $ sudo sh KneronDFUT.sh --list + ``` + + ```bash + =========================================== + Index: 1 + Port Id: 13 + Kn Number: 0x09011004 + Device Type: KL730 + FW Type: KDP2 + Usb Speed: Super-Speed + Connectable: true + =========================================== + ``` + +3. Write model into the selected KL730 devices using the port id + + ```bash + $ sudo sh KneronDFUT.sh --model-to-flash ${MODEL_FILE_PATH} --port 13 -- type KL730 + ``` + + ```bash + Start Update Model to Device with Port Id 13 + + ==== Update Model to Device with Port Id: 13 Succeeded ==== + ``` 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 37dbb9f..5850b8c 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 @@ -19,6 +19,7 @@ In order to infer without hardware image preprocessing, the input data must do t - `KL520DemoGenericDataInference.py` - `KL630DemoGenericDataInference.py` - `KL720DemoGenericDataInference.py` +- `KL730DemoGenericDataInference.py` ### Inference without Built-In Hardware Image Pre-Processing @@ -125,13 +126,13 @@ In order to infer without hardware image preprocessing, the input data must do t npu_input_buffer = re_layout_data.tobytes() ``` - - For KL630 + - For KL630, KL720 and KL730 > More information about *NPU data layout format*, please refer to [Supported NPU Data Layout Format](../../../plus_c/appendix/supported_npu_data_layout_format.md) ```python # re-layout the data to fit NPU data layout format - # KL630 supported NPU input layout format: 4W4C8B, 1W16C8B, 16W1C8B + # KL630, KL720 and KL730 supported NPU input layout format: 4W4C8B, 1W16C8B, 16W1C8B if kp.ModelTensorDataLayout.KP_MODEL_TENSOR_DATA_LAYOUT_4W4C8B == model_input_data_layout: width_align_base = 4 @@ -176,57 +177,6 @@ In order to infer without hardware image preprocessing, the input data must do t npu_input_buffer = re_layout_data.tobytes() ``` - - For KL720 - - > More information about *NPU data layout format*, please refer to [Supported NPU Data Layout Format](../../../plus_c/appendix/supported_npu_data_layout_format.md) - - ```python - # re-layout the data to fit NPU data layout format - # KL720 supported NPU input layout format: 4W4C8B, 1W16C8B, 16W1C8B - - if kp.ModelTensorDataLayout.KP_MODEL_TENSOR_DATA_LAYOUT_4W4C8B == model_input_data_layout: - width_align_base = 4 - channel_align_base = 4 - elif kp.ModelTensorDataLayout.KP_MODEL_TENSOR_DATA_LAYOUT_1W16C8B == model_input_data_layout: - width_align_base = 1 - channel_align_base = 16 - elif kp.ModelTensorDataLayout.KP_MODEL_TENSOR_DATA_LAYOUT_16W1C8B == model_input_data_layout: - width_align_base = 16 - channel_align_base = 1 - else: - print(' - Error: invalid input NPU layout format {}'.format(str(model_input_data_layout))) - exit(0) - - # calculate width alignment size, channel block count - model_input_width_align = width_align_base * math.ceil(model_input_width / float(width_align_base)) - model_input_channel_block_num = math.ceil(model_input_channel / float(channel_align_base)) - - # create re-layout data container - # KL720 dimension order: CxHxW - re_layout_data = np.zeros((model_input_channel_block_num, - model_input_height, - model_input_width_align, - channel_align_base), dtype=np.int8) - - # fill data in re-layout data container - model_input_channel_block_offset = 0 - for model_input_channel_block_idx in range(model_input_channel_block_num): - model_input_channel_block_offset_end = model_input_channel_block_offset + channel_align_base - model_input_channel_block_offset_end = model_input_channel_block_offset_end if model_input_channel_block_offset_end < model_input_channel else model_input_channel - - re_layout_data[ - model_input_channel_block_idx, - :model_input_height, - :model_input_width, - :(model_input_channel_block_offset_end - model_input_channel_block_offset) - ] = data[:, :, model_input_channel_block_offset:model_input_channel_block_offset_end] - - model_input_channel_block_offset += channel_align_base - - # convert re-layout data to npu inference buffer - npu_input_buffer = re_layout_data.tobytes() - ``` - - Prepare generic data inference input descriptor ```python generic_inference_input_descriptor = kp.GenericDataInferenceDescriptor( diff --git a/docs/plus_python/tutorial/chapter/model_inference_with_image_inference.md b/docs/plus_python/tutorial/chapter/model_inference_with_image_inference.md index d99de40..383ac03 100644 --- a/docs/plus_python/tutorial/chapter/model_inference_with_image_inference.md +++ b/docs/plus_python/tutorial/chapter/model_inference_with_image_inference.md @@ -15,6 +15,7 @@ This tutorial shows how to inference image data by Kneron devices **with built-i - `KL520DemoGenericImageInference.py` - `KL630DemoGenericImageInference.py` - `KL720DemoGenericImageInference.py` +- `KL730DemoGenericImageInference.py` ### Inference general format image: Kneron PLUS support **`BGR565`**, **`BGRA8888`**, **`RAW8 (Grayscale)`** numpy.ndarray (dtype=numpy.uint8, dim=3) image inference. diff --git a/docs/plus_python/tutorial/chapter/model_inference_with_inference_on_cropped_regions.md b/docs/plus_python/tutorial/chapter/model_inference_with_inference_on_cropped_regions.md index 1030e88..8c12a03 100644 --- a/docs/plus_python/tutorial/chapter/model_inference_with_inference_on_cropped_regions.md +++ b/docs/plus_python/tutorial/chapter/model_inference_with_inference_on_cropped_regions.md @@ -16,6 +16,7 @@ The flow in concept: - `KL520DemoGenericImageInferenceCrop.py` - `KL630DemoGenericImageInferenceCrop.py` - `KL720DemoGenericImageInferenceCrop.py` +- `KL730DemoGenericImageInferenceCrop.py` --- diff --git a/docs/plus_python/tutorial/chapter/model_inference_with_inference_with_drop_frame.md b/docs/plus_python/tutorial/chapter/model_inference_with_inference_with_drop_frame.md index a2e739d..8f784a0 100644 --- a/docs/plus_python/tutorial/chapter/model_inference_with_inference_with_drop_frame.md +++ b/docs/plus_python/tutorial/chapter/model_inference_with_inference_with_drop_frame.md @@ -10,6 +10,7 @@ This tutorial shows how to inference model with drop frame configuration - `KL520DemoCamGenericImageInferenceDropFrame.py` - `KL630DemoCamGenericImageInferenceDropFrame.py` - `KL720DemoCamGenericImageInferenceDropFrame.py` +- `KL730DemoCamGenericImageInferenceDropFrame.py` ### Inference with Drop Frame diff --git a/mkdocs.yml b/mkdocs.yml index dafca7d..1e5097c 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -40,6 +40,8 @@ nav: - Create Multiple Models Example for KL630: plus_c/feature_guide/customized_api/create_kl630_multiple_models_example.md - Create Single Model Example for KL720: plus_c/feature_guide/customized_api/create_kl720_single_model_example.md - 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 - 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 @@ -57,13 +59,19 @@ nav: - 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: - - v2.2.x: - - Data Structure: plus_c_api/api_reference_2.2.x/kp_struct.h.md - - Core API: plus_c_api/api_reference_2.2.x/kp_core.h.md - - Inference API: plus_c_api/api_reference_2.2.x/kp_inference.h.md - - (legacy)Data Structure: plus_c_api/api_reference_2.2.x/kp_struct_v1.h.md - - (legacy)Inference API: plus_c_api/api_reference_2.2.x/kp_inference_v1.h.md + - v2.3.x-alpha: + - Data Structure: plus_c_api/api_reference_2.3.x/kp_struct.h.md + - Core API: plus_c_api/api_reference_2.3.x/kp_core.h.md + - Inference API: plus_c_api/api_reference_2.3.x/kp_inference.h.md + - (legacy)Data Structure: plus_c_api/api_reference_2.3.x/kp_struct_v1.h.md + - (legacy)Inference API: plus_c_api/api_reference_2.3.x/kp_inference_v1.h.md - Archive: + - v2.2.x: + - Data Structure: plus_c_api/api_reference_2.2.x/kp_struct.h.md + - Core API: plus_c_api/api_reference_2.2.x/kp_core.h.md + - Inference API: plus_c_api/api_reference_2.2.x/kp_inference.h.md + - (legacy)Data Structure: plus_c_api/api_reference_2.2.x/kp_struct_v1.h.md + - (legacy)Inference API: plus_c_api/api_reference_2.2.x/kp_inference_v1.h.md - v2.1.x: - Data Structure: plus_c_api/api_reference_2.1.x/kp_struct.h.md - Core API: plus_c_api/api_reference_2.1.x/kp_core.h.md @@ -133,7 +141,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 - - V2.2.0 (Latest Version): + - V2.3.0 (Latest Version): + - Index: plus_python/api_document/V2.3.0/index.md + - kp.core: plus_python/api_document/V2.3.0/kp/core.md + - kp.inference: plus_python/api_document/V2.3.0/kp/inference.md + - kp value: plus_python/api_document/V2.3.0/kp/value.md + - kp enum: plus_python/api_document/V2.3.0/kp/enum.md + - kp exception: plus_python/api_document/V2.3.0/kp/exception.md + - kp const: plus_python/api_document/V2.3.0/kp/const.md + - kp.v1 (Legacy Module): + - kp.v1.inference: plus_python/api_document/V2.3.0/kp/v1/inference.md + - kp.v1 value: plus_python/api_document/V2.3.0/kp/v1/value.md + - V2.2.0: - Index: plus_python/api_document/V2.2.0/index.md - kp.core: plus_python/api_document/V2.2.0/kp/core.md - kp.inference: plus_python/api_document/V2.2.0/kp/inference.md