hrt_model_exec工具介绍

工具简介

hrt_model_exec 是一个模型执行工具,可直接在开发板上评测模型的推理性能、获取模型信息。 一方面可以让用户拿到模型时实际了解模型真实性能; 另一方面也可以帮助用户了解模型可以做到的速度极限,对于应用调优的目标极限具有指导意义。

hrt_model_exec 工具源码位于 horizon_j6_open_explorer 发布物的 samples/ucp_tutorial/tools/hrt_model_exec 路径下。结构如下所示:

├── include # 头文件 ├── src # 工具源码 ├── build.sh # 编译脚本 ├── build_x86.sh # 编译产生x86工具 ├── build_aarch64.sh # 编译产生aarch64工具 ├── CMakeLists.txt ├── README.md ├── script # aarch64工具运行脚本 └── script_x86 # x86工具运行脚本

hrt_model_exec 工具分别提供了模型推理 infer、模型性能分析 perf 和查看模型信息 model_info 三类功能,如下表:

编号子命令说明
1model_info获取模型信息,如:模型的输入输出信息等。
2infer执行模型推理,获取模型推理结果。
3perf执行模型性能分析,获取性能分析结果。

工具可以通过 -v 或者 --version 命令,查看工具的 dnn 预测库版本号。

hrt_model_exec -v hrt_model_exec --version

参数描述

参数类型说明
model_filestring模型文件路径,多个路径可通过逗号分隔。
model_namestring指定模型中某个模型的名称。
core_idint指定运行核。0:任意核,1:core0;默认为 0。
input_filestring模型输入信息。 输入后缀必须为 PNG/JPG/JPEG/png/jpg/jpeg/bin/txt 中的一种。每个输入之间需要用英文字符的逗号隔开,,如:xxx.jpg,input.txt
input_img_propertiesstring模型图像输入的色彩空间信息。 input_file 中每一个图片类型输入都需要指定一个 Y/UV 类型,每个输入色彩空间之间需要用英文字符的逗号隔开,,如:Y,UV
input_valid_shapestring模型动态 validShape 输入信息。 若模型输入属性 validShape 中含有 -1,则需要将 -1 的部分进行补全,多个 validShape 间通过英文分号间隔。如:--input_valid_shape="1,376,376,1;1,188,188,2"
input_stridestring模型动态 stride 输入信息。 若模型输入属性 stride 中含有 -1,则需要将 -1 的部分进行补全,多个 stride 间通过英文分号间隔。如:--input_stride="144384,384,1,1;72192,384,2,1"
roi_inferbool使能resizer模型推理。若模型存在resizer输入源的输入,需设置为 true,并且配置与输入源一一对应的 input_fileroi 参数。
roistring指定推理resizer模型时所需的roi区域,多个roi之间通过英文分号间隔。如:--roi="2,4,123,125;6,8,111,113"
frame_countint执行模型运行帧数。
dump_intermediatestringdump模型每一层输入和输出。
  • dump_intermediate=0 时,默认dump功能关闭。
  • dump_intermediate=1 时,模型中每一层节点输入数据输出数据以 bin 方式保存, 其中节点输入输出为 stride 数据。
  • dump_intermediate=2 时,模型中每一层节点输入数据和输出数据以 bintxt 两种方式保存,其中节点输入输出为 stride 数据。
  • dump_intermediate=3 时,型中每一层节点输入数据和输出数据以 bintxt 两种方式保存,其中节点输入输出为 valid 数据。
  • enable_dumpbool使能dump模型输入和输出,默认为 false
    dump_precisionint控制txt格式输出float型数据的小数点位数,默认为 9
    dequantize_processbool对模型输出进行反量化处理,在 enable_dumptrue 时生效,默认为 false
    remove_padding_processbool对模型输出进行去padding处理,在 enable_dumptrue 时生效,默认为 false
    dump_formatstringdump模型输入和输出的格式。
    dump_txt_axisint控制txt格式输入输出的换行规则。
    enable_cls_post_processbool使能分类后处理,默认为 false。 子命令为 infer 时配合使用,目前只支持ptq分类模型的后处理,打印分类结果。
    perf_timeint执行模型运行时间。
    thread_numint线程数(并行度),数值可以表示最多有多少个任务在并行处理。
    测试延时,数值需要设置为1,没有资源抢占发生,延时测试更准确。
    测试吞吐,建议设置>2 (BPU核心个数),调整线程数使BPU利用率尽量高,吞吐测试更准确。
    profile_pathstring统计工具日志产生路径,运行产生profiler.log和profiler.csv,分析op耗时和调度耗时。一般设置 --profile_path="." 即可,代表在当前目录下生成日志文件。
    dump_pathstringdump模型输入输出的路径,设置 enable_dumpdump_intermediate 时生效。

    设置profile_path参数且工具正常运行后会产生profiler.log和profiler.csv文件,文件中包括如下参数:

    • perf_result:记录perf结果。
    参数说明
    FPS每秒处理的帧数。
    average_latency指定模型中某个模型平均一帧运行所花费的时间。
    • running_condition:运行环境信息。
    参数说明
    core_id程序运行设置的bpu核。
    frame_count程序运行的总帧数。
    model_name评测模型的名字。
    run_time程序运行时间。
    thread_num程序运行的线程数。
    • model_latency:模型节点耗时统计。
    参数说明
    Node-pad模型输入padding耗时。
    Node-NodeIdx-NodeType-NodeName模型节点耗时信息。注:NodeIdx为模型节点拓扑排序的序号,NodeType为具体的节点类型,如Dequantize,NodeName为具体的节点名称。
    • processor_latency:模型处理器耗时统计。
    参数说明
    BPU_inference_time_cost每帧推理BPU处理器耗时。
    CPU_inference_time_cost每帧推理CPU处理器耗时。
    • task_latency:模型任务耗时统计。
    参数说明
    TaskRunningTime任务实际运行耗时,耗时时间包括UCP框架耗时。

    使用说明

    工具提供三类功能:模型信息获取、单帧推理功能、多帧性能评测。

    运行 hrt_model_exechrt_model_exec -hhrt_model_exec --help 获取工具使用详情。如下所示:

    Usage: hrt_model_exec [Option...] [Parameter] [Option] [instruction] --------------------------------------------------------------------------------------------------------------- -h --help Display this information -v --version Display this version [Option] [Parameter] --------------------------------------------------------------------------------------------------------------- --model_file [string]: Model file paths, separate by comma, each represents one model file path. --model_name [string]: Model name. When model_file has one more model and Subcommand is infer or perf, "model_name" must be specified! --core_id [int] : core id, 0 for any core, 1 for core 0, 2 for core 1, 3 for core 2, 4 for core 3, default is 0. Please confirm the number of bpu cores on the board before setting up. --input_file [string]: Input file paths, separate by comma, each represents one input. The extension of files should be one of [jpg, JPG, jpeg, JPEG, png, PNG, bin, txt] bin for binary such as image data, nv12 or yuv444 etc. txt for plain data such as image info. --roi_infer [bool] : flag for roi infer, The default is false. --roi [string]: roi information. If set roi_infer as resizer, this parameter is required, roi are separated by semicolons. For example: --roi="0,0,124,124;1,1,123,123" --frame_count [int] : frame count for run loop, default 200, valid when perf_time is 0 in perf mode; default 1 for infer mode. --dump_intermediate [string]: dump intermediate layer input and output. The default is 0. Subcommand must be infer. --enable_dump [bool] : flag for dump infer input and output. The default is false. Subcommand must be infer. --dump_precision [int] : Output dump precision for float32/float64 in txt file. Default is 9 decimal places. --dequantize_process [bool] : dequantize the model infer output. The default is false. Subcommand must be infer, enable_dump set as true --remove_padding_process [bool] : remove padding of the model infer output. The default is false. Subcommand must be infer, enable_dump set as true --dump_format [string]: output dump format, only support [bin, txt]. The default is bin. Subcommand must be infer. --dump_txt_axis [int] : The txt file of dump is expanded according to the specified axis; the default is -1, which means there is only one data per line; Subcommand must be perf, dump_format must be txt. range:[0, tensor_dimension]. --enable_cls_post_process [bool] : flag for classfication post process, only for ptq model now. Subcommand must be infer. --perf_time [int] : minute, perf time for run loop, default 0. Subcommand must be perf. --thread_num [int] : thread num for run loop, thread_num range:[1,8], if thread_num > 8, set thread_num = 8. Subcommand must be perf. --profile_path [string]: profile log and csv files path, set to get detail information of model execution. --dump_path [string]: dump file path, --enable_dump or --dump_intermediate will dump model nodes inputs and outputs files. --input_img_properties [string]: Specify the color space of the image type input. Each image needs to specify the color space, separated by commas. The supported color spaces are [Y, UV]. The NV12 type is only used for compatible PYM and Resizer models. --input_valid_shape [string]: Complete the validshape of the model input, allowing only the dynamic part to change. Provide two ways to set: 1. This only needs to be set when the validShape of the model input is dynamic. 2. Set for all inputs. Different inputs are separated by semicolons, and different dimensions are separated by commas. For example: --input_valid_shape="1,376,376,1;1,188,188,2". --input_stride [string]: Complete the stride of the model input, allowing only the dynamic part to change. Provide two ways to set: 1. This only needs to be set when the stride of model input is dynamic. 2. Set for all inputs. Different inputs are separated by semicolons, and different dimensions are separated by commas. For example: --input_stride="144384,384,1,1;72192,384,2,1". [Examples] --------------------------------------------------------------------------------------------------------------- hrt_model_exec model_info | hrt_model_exec infer | hrt_model_exec perf --model_file | --model_file | --model_file --model_name | --model_name | --model_name | --core_id | --core_id | --input_file | --input_file | --input_img_properties | --input_img_properties | --input_valid_shape | --input_valid_shape | --input_stride | --input_stride | --roi_infer | --roi_infer | --roi | --roi | --frame_count | --frame_count | --dump_intermediate | --profile_path | --enable_dump | --perf_time | --dump_precision | --thread_num | --dequantize_process | | --dump_path | | --remove_padding_process | | --dump_format | | --dump_txt_axis | | --enable_cls_post_process |

    model_info

    概述

    该参数用于获取模型信息,模型支持范围:qat模型,ptq模型。该参数与 model_file 一起使用,用于获取模型的详细信息,信息包括模型输入输出信息 hbDNNTensorProperties

    不指定 model_name 输出模型中所有模型信息,指定 model_name 则只输出对应模型的信息。

    示例

    1. 单模型
    hrt_model_exec model_info --model_file=xxx.hbm ../aarch64/bin/hrt_model_exec model_info --model_file=resnet50_224x224_featuremap.hbm I0000 00:00:00.000000 1634 vlog_is_on.cc:197] RAW: Set VLOG level for "*" to 3 Load model to DDR cost 6423.24ms. This model file has 1 model: [resnet50_224x224_featuremap] --------------------------------------------------------------------- [model name]: resnet50_224x224_featuremap [model desc]: {"BUILDER_VERSION": "3.0.3", "HBDK_VERSION": "4.0.12.post0.dev202312251146+8d9d31b", "HBDK_RUNTIME_VERSION": null, "HORIZON_NN_VERSION": "0.22.0.post0.dev202312172213+3c57b998554cf249fa033311501eead62c927392", "CAFFE_MODEL": null, "PROTOTXT": null, "ONNX_MODEL": "/open_explorer/samples/ai_toolchain/horizon_model_convert_sample/01_common/model_zoo/mapper/classification/resnet50/resnet50.onnx", "MARCH": "nash-e", "LAYER_OUT_DUMP": "False", "LOG_LEVEL": null, "WORKING_DIR": "/open_explorer/samples/ai_toolchain/horizon_model_convert_sample/03_classification/03_resnet50/model_output", "MODEL_PREFIX": "resnet50_224x224_featuremap", "OUTPUT_NODES": "", "REMOVE_NODE_TYPE": "", "REMOVE_NODE_NAME": "", "DEBUG_MODE": null, "NODE_INFO": "{}", "INPUT_NAMES": "input", "INPUT_SPACE_AND_RANGE": "regular", "INPUT_TYPE_RT": "featuremap", "INPUT_TYPE_TRAIN": "featuremap", "INPUT_LAYOUT_TRAIN": "NCHW", "INPUT_LAYOUT_RT": "", "NORM_TYPE": "no_preprocess", "MEAN_VALUE": "None", "SCALE_VALUE": "None", "INPUT_SHAPE": "1x3x224x224", "INPUT_BATCH": "", "SEPARATE_BATCH": "False", "CUSTOM_OP_METHOD": null, "CUSTOM_OP_DIR": null, "CUSTOM_OP_REGISTER_FILES": "", "OPTIMIZATION": "", "CALI_TYPE": "default", "CALI_DIR": "/open_explorer/samples/ai_toolchain/horizon_model_convert_sample/03_classification/03_resnet50/calibration_data_bgr", "CAL_DATA_TYPE": "float32", "PER_CHANNEL": "False", "MAX_PERCENTILE": "None", "RUN_ON_CPU": "", "RUN_ON_BPU": "", "ADVICE": 0, "DEBUG": "True", "OPTIMIZATION_LEVEL": "O2", "COMPILE_MODE": "latency", "CORE_NUM": 1, "MAX_TIME_PER_FC": 0, "BALANCE_FACTOR": null, "ABILITY_ENTRY": null, "INPUT_SOURCE": {"input": "ddr"}} input[0]: name: input input source: HB_DNN_INPUT_FROM_DDR valid shape: (1,3,224,224,) aligned shape: (1,3,224,224,) aligned byte size: 602112 tensor type: HB_DNN_TENSOR_TYPE_F32 tensor layout: HB_DNN_LAYOUT_NONE quanti type: NONE stride: (602112,200704,896,4,) output[0]: name: output valid shape: (1,1000,) aligned shape: (1,1000,) aligned byte size: 4096 tensor type: HB_DNN_TENSOR_TYPE_F32 tensor layout: HB_DNN_LAYOUT_NONE quanti type: NONE stride: (4000,4,) ---------------------------------------------------------------------
    1. 多模型(输出所有模型信息)
    hrt_model_exec model_info --model_file=xxx.hbm,xxx.hbm
    1. 多模型--pack模型(输出指定模型信息)
    hrt_model_exec model_info --model_file=xxx.hbm --model_name=xx

    infer

    概述

    该参数用于模型推理,用户自定义输入图片,推理一帧。该参数需要与 input_file 一起使用,指定输入图片路径,工具根据模型信息resize图片,整理模型输入信息。

    程序单线程运行单帧数据,输出模型运行的时间。

    示例

    1. 单模型
    hrt_model_exec infer --model_file=xxx.hbm --input_file=xxx.bin ../aarch64/bin/hrt_model_exec infer --model_file=resnet50_224x224_featuremap.hbm --model_name= --input_file=data.bin I0000 00:00:00.000000 1665 vlog_is_on.cc:197] RAW: Set VLOG level for "*" to 3 Load model to DDR cost 5408.48ms. I0401 21:03:44.551949 1665 function_util.cpp:117] get model handle success I0401 21:03:44.591531 1665 function_util.cpp:123] get model input count success I0401 21:03:44.592371 1665 function_util.cpp:129] get model output count success I0401 21:03:44.595619 1665 function_util.cpp:155] prepare output tensor success file length: 602112 I0401 21:03:44.659796 1665 function_util.cpp:168] read file success! I0401 21:03:44.664801 1665 function_util.cpp:193] Create task success I0401 21:03:55.158859 1665 function_util.cpp:206] task done ---------------------Frame 0 begin--------------------- Infer time: 10498.3 ms ---------------------Frame 0 end---------------------
    1. 多模型
    hrt_model_exec infer --model_file=xxx.hbm,xxx.hbm --model_name=xx --input_file=xxx.jpg
    1. resizer模型

    模型有三个输入,输入源顺序分别为[ddr, resizer, resizer]。

    推理两帧数据,假设第一帧输入为[xx0.bin,xx1.jpg,xx2.jpg],roi为[2,4,123,125;6,8,111,113],第二帧输入为[xx3.bin,xx4.jpg,xx5.jpg],roi为[27,46,143,195;16,28,131,183],则推理命令如下:

    hrt_model_exec infer --roi_infer=true --model_file=xxx.bin --input_file="xx0.bin,xx1.jpg,xx2.jpg,xx3.bin,xx4.jpg,xx5.jpg" --roi="2,4,123,125;6,8,111,113;27,46,143,195;16,28,131,183"
    注解

    多帧输入之间用英文逗号隔离,roi之间使用分号隔离。

    可选参数

    参数说明
    core_id指定模型推理的核id。
    input_img_properties模型图像输入的色彩空间信息。
    input_valid_shape模型动态 validShape 输入信息。
    input_stride模型动态 stride 输入信息。
    roi_infer使能resizer模型推理。
    roiroi_infertrue 时生效,设置推理resizer模型时所需的 roi 区域。
    frame_count设置 infer 运行帧数,单帧重复推理,可与 enable_dump 并用,验证输出一致性,默认为 1
    dump_intermediatedump模型每一层输入数据和输出数据,默认值 0
    enable_dumpdump模型输入和输出数据,默认为 false
    dump_precision控制txt格式输出float型数据的小数点位数,默认为 9
    dequantize_process对模型输出进行反量化处理,在 enable_dumptrue 时生效,默认为 false
    remove_padding_process对模型输出进行去padding处理,在 enable_dumptrue 时生效,默认为 false
    dump_formatdump模型输出文件的类型,可选参数为 bintxt,默认为 bin
    dump_txt_axisdump模型txt格式输出的换行规则;若输出维度为n,则参数范围为[0, n], 默认为 -1,一行一个数据。
    enable_cls_post_process使能分类后处理,目前只支持ptq分类模型,默认 false
    dump_pathdump模型输入输出的路径,设置 enable_dumpdump_intermediate 时生效。

    perf

    概述

    该参数用于测试模型性能。 该模式下,用户无需输入数据,程序根据模型信息自动构造输入tensor,tensor数据为随机数。 程序默认单线程运行200帧数据,当指定perf_time参数时,frame_count参数失效,程序会执行指定时间后退出。 输出模型运行的latency、以及帧率信息。程序每200帧打印一次性能信息: latency的最大、最小、平均值,不足200帧程序运行结束打印一次。

    程序最后输出running相关数据, 包括:程序线程数、帧数、模型推理总时间,模型推理平均latency,帧率信息。

    示例

    1. 单模型
    hrt_model_exec perf --model_file=xxx.hbm ../aarch64/bin/hrt_model_exec perf --model_file=yolov5x_672x672_nv12.hbm --model_name= --frame_count=100 [BPU][[BPU_MONITOR]][INFO]BPULib verison(2, 0, 0)[]! [DNN]: 3.0.7_(4.0.20 HBRT) Load model to DDR cost 3107.75ms. Frame count: 100, Thread Average: 15.260320 ms, thread max latency: 15.845000 ms, thread min latency: 15.195000 ms, FPS: 63.908421 Running condition: Thread number is: 1 Frame count is: 100 Program run time: 1565.202000 ms Perf result: Frame totally latency is: 1526.031982 ms Average latency is: 15.260320 ms Frame rate is: 63.889517 FPS
    1. 多模型
    hrt_model_exec perf --model_file=xxx.hbm,xxx.hbm --model_name=xxx
    1. resizer模型

    模型有三个输入,输入源顺序分别为[ddr, resizer, resizer]。

    推理两帧数据,假设第一帧输入为[xx0.bin,xx1.jpg,xx2.jpg],roi为[2,4,123,125;6,8,111,113],第二帧输入为[xx3.bin,xx4.jpg,xx5.jpg],roi为[27,46,143,195;16,28,131,183],则perf命令如下:

    hrt_model_exec perf --roi_infer=true --model_file=xxx.hbm --input_file="xx0.bin,xx1.jpg,xx2.jpg,xx3.bin,xx4.jpg,xx5.jpg" --roi="2,4,123,125;6,8,111,113;27,46,143,195;16,28,131,183"
    注解

    多帧输入之间用英文逗号隔离,roi之间使用分号隔离。

    可选参数

    参数说明
    core_id指定模型推理的核id。
    input_file模型输入信息,多个可通过逗号分隔。
    input_img_properties模型图像输入的色彩空间信息。
    input_valid_shape模型动态 validShape 输入信息。
    input_stride模型动态 stride 输入信息。
    roi_infer使能resizer模型推理;若模型输入包含resizer源,设置为 true,默认为 false
    roiroi_infertrue 时生效,设置推理resizer模型时所需的 roi 区域以英文分号间隔。
    frame_count设置 perf 运行帧数,当perf_time为0时生效,默认为 200
    dump_intermediatedump模型每一层输入数据和输出数据,默认值 0
    perf_time设置 perf 运行时间,单位:分钟,默认为 0
    thread_num设置程序运行线程数,范围[1, 8], 默认为 1, 设置大于8时按照8个线程处理。
    profile_path统计工具日志产生路径,运行产生profiler.log和profiler.csv,分析op耗时和调度耗时。

    多输入模型说明

    工具 infer 推理功能支持多输入模型的推理,支持图片输入、二进制文件输入以及文本文件输入,输入数据用逗号隔开。 模型的输入信息可以通过 model_info 进行查看。

    示例:

    hrt_model_exec infer --model_file=xxx.hbm --input_file=xxx.jpg,input.txt

    动态输入说明

    若模型的输入是动态的,此时需要您使用 input_valid_shapeinput_stride 参数来补全动态信息。您可以选择以下两种方式指定参数:

    • 只给定动态输入的 validShapestride 信息。
    • 给定所有输入的 validShapestride 信息,非动态输入的信息必须与模型信息保持一致。

    动态输入介绍 章节中的模型为例,您可以通过以下命令运行模型:

    # 只给定动态输入的信息 hrt_model_exec infer --model_file=xxx.hbm --input_file="input_y.bin,input_uv.bin,input_roi.bin" --input_valid_shape="1,220,220,1;1,110,110,2" --input_stride="49280,224,1,1;24640,224,2,1" # 给定所有输入的信息 hrt_model_exec infer --model_file=xxx.hbm --input_file="input_y.bin,input_uv.bin,input_roi.bin" --input_valid_shape="1,220,220,1;1,110,110,2;1,4" --input_stride="49280,224,1,1;24640,224,2,1;16,4"

    图像类型输入说明

    input_file 给定图像输入时,需要使用 input_img_properties 参数来指定您想使用该图片的哪个色彩空间当做模型的输入,目前只支持 YUV 两种色彩空间。

    hrt_model_exec infer --model_file=xxx.hbm --input_file="img.jpg,img.jpg,input_roi.bin" --input_img_properties="Y,UV"

    工具运行说明

    构建

    ucp_tutorial/tools/hrt_model_exec 目录下有预先配置好的编译脚本 build.sh,选项 -a x86-a aarch64 分别支持两种编译方式,您可以使用该脚本并指定编译选项进行编译。 此外,目录中也包含了 build_aarch64.shbuild_x86.sh 两个编译脚本,分别对应了两个编译选项,使用这两个脚本进行编译与使用 build.sh 脚本并指定编译选项等效。

    # 构建板端运行工具 bash -ex build_aarch64.sh # 构建x86端运行工具 bash -ex build_x86.sh

    运行

    构建板端运行工具后,将生成 output_shared_J6_aarch64 文件夹。 您可以将文件夹复制到板端环境中并执行 output_shared_J6_aarch64/script/run_hrt_model_exec.sh 来使用该工具。

    构建x86端运行工具后,将生成 output_shared_J6_x86 文件夹。 您可以在x86端直接执行 output_shared_J6_x86/script_x86/run_hrt_model_exec.sh 来使用该工具。

    run_hrt_model_exec.sh 脚本分为设置环境变量和获取模型信息并推理模型两部分。

    # 设置环境变量 # arch代表架构类型,aarch64或x86 arch=aarch64 bin=../$arch/bin/hrt_model_exec lib=../$arch/lib/ export LD_LIBRARY_PATH=${lib}:${LD_LIBRARY_PATH} # 获取模型信息、推理模型、获取模型性能 ${bin} model_info --model_file=xxx.hbm ${bin} infer --model_file=xxx.hbm --input_file=xxx.bin ${bin} perf --model_file=xxx.hbm --frame_count=200
    注解

    运行前需要修改 run_hrt_model_exec.sh 相应参数,以确保模型和输入文件正确。您还可以灵活使用其他参数来使用更多功能。

    常见问题

    Latency、FPS数据是如何统计的?

    Latency是指单流程推理模型所耗费的平均时间,重在表示在资源充足的情况下推理一帧的平均耗时,体现在上板运行是单核单线程统计;统计方法伪代码如下:

    // Load model and prepare input and output tensor ... // Loop run inference and get latency { int32_t const loop_num{1000}; start = std::chrono::steady_clock::now(); for(int32_t i = 0; i < loop_num; i++){ hbUCPSchedParam sched_param{}; HB_UCP_INITIALIZE_SCHED_PARAM(&sched_param); // create task hbDNNInferV2(&task_handle, output_tensor, input_tensor, dnn_handle); // submit task hbUCPSubmitTask(task_handle, &sched_param); // wait task done hbUCPWaitTaskDone(task_handle, 0); // release task handle hbUCPReleaseTask(task_handle); task_handle = nullptr; } end = std::chrono::steady_clock::now(); latency = (end - start) / loop_num; } // release tensor and model ...

    FPS是指多流程同时进行模型推理平均一秒推理的帧数,重在表示充分使用资源情况下模型的吞吐,体现在上板运行为双核多线程;统计方法是同时起多个线程进行模型推理,计算平均1s推理的总帧数。

    通过Latency推算FPS与工具测出的FPS为什么不一致?

    Latency与FPS的统计情景不同,Latency为单流程(单核单线程)推理,FPS为多流程(多核多线程)推理,因此推算不一致;若统计FPS时将流程(线程)数量设置为 1 ,则通过Latency推算FPS和测出的一致。