编译生成物说明 ==================================================================================== 本章节介绍Lyngor编译生成物中主要JSON文件的字段信息,便于理解和比较不同模型的具体信息。 net_params.json ------------------------------------------------------------------------------------ ``net_params.json`` 是网络的描述信息。 ``net_params.json`` 字段说明如下: :: { "version": "202207141006", // 内部版本号 "target": "apu", // 编译是选择的设备 "is_map": true, // 是否调用map,用户用时一般均为true "chip_num": 1, // 编译时使用的芯片个数,当前版本仅能为1 "net_num": 1, // 编译产生的网络数量 "parallel_mode": "DP", // 并行模式,DP为数据并行,MP为模型并行 "run_batch": 1, // 运行时batch数量 "cpu_arch": "arm", // cpu架构,用户使用时均为arm "cc": "aarch64-linux-gnu-g++", // 使用的交叉编译器,当前值为默认值,可更新 "file_name": { // 生成物对应的名字 "cpu_lib": "deploy_lib.so", // cpu库文件名字 "cpu_graph": "deploy_graph.json", // cpu json文件名字 "cpu_params": "deploy_param.params", // cpu参数文件名字 "apu_lib": "apu_lib.bin", // op图名字 "io_config": "top_graph.json" // 图信息文件名字 }, "net:": null, // 网络切分信息,一般为空 "is_dynamic_shape": false, // 是否使用动态shape编译 "build_mode": "abc" // 编译模式,cnn为abc,类脑稀疏模式为hop } top_graph.json ------------------------------------------------------------------------------------ ``top_graph.json`` 是计算图的描述信息。 ``top_graph.json`` 字段说明如下: :: { "main": { // 主网络名字 "inputs": { // 网络总输入 "input_ids": { // 当前网络名为input_ids的输入 "shape": "(1, 128)", // input_ids输入形状 "dtype": "int16", // input_ids输入类型 "batch": 1 // input_ids输入batch数 }, "token_type_ids": { "shape": "(1, 128)", "dtype": "int16", "batch": 1 }, "attention_mask": { "shape": "(1, 128)", "dtype": "int16", "batch": 1 } } }, "outputs": { // 网络总输出 "apu_0:0": { // apu_0子网络的第一个输出 "shape": "(1, 128, 128)", // 输出形状 "dtype": "float16" // 输出类型 }, "apu_0:1": { "shape": "(1, 128)", "dtype": "float16" } }, "apu_0": { // 当前第一个子网络apu_0 "inputs": { // apu_0子网络总输入 "input_ids": { "shape": "(1, 128)", "dtype": "int16", "batch": 1 }, "token_type_ids": { "shape": "(1, 128)", "dtype": "int16", "batch": 1 }, "attention_mask": { "shape": "(1, 128)", "dtype": "int16", "batch": 1 } }, "outputs": { // apu_0子网络总输入 "apu_0:0": { "shape": "(1, 128, 128)", "dtype": "float16" }, "apu_0:1": { "shape": "(1, 128)", "dtype": "float16" } }, "is_abc": "true", // 是否为abc模型,目前版本可忽略 "version": "202207141006" // lyngor编译版本 } } apu.json ------------------------------------------------------------------------------------ ``apu.json`` 是SDK运行模型时使用的配置信息。 ``apu.json`` 字段说明如下: :: { "apu_x": { "batch_size": 1, // 模型编译输入batch数 "cmd_size": 512, // cmd.bin字节大小,256 bytes整数倍 "crmem_load_base_addr": 983008, // ddr load基地址,可动态配置dat.bin写入ddr位置 "image_size": 16128640, // core.bin字节大小,sub_image_size之和 "inputs": { // 模型输入相关参数 "datai0": { // 输入节点 "dtype": "uint8", // 输入数据类型uint8 "name": "data", // 输入节点名称 "shape": "[1, 64, 64, 3]", // 输入节点维度 "shape_ex": [ // 输入节点维度 1, 64, 64, 3 ], "size": 12288 // 输入节点元素个数 } }, "n_slice": 1, // 模型实际支持bacth数 "outputs": { // 模型输出相关参数 "datao0": { // 输出节点0 "dtype": "float16", // 输出数据类型fp16 "name": "\_\_&@!%output0", // 输出节点名称 "shape": "[1, 1, 1, 1000]", // 输出节点维度 "shape_ex": [ // 输出节点维度 1, 1, 1, 1000 ], "size": 1000 // 输出节点元素个数 } }, "sub_image_size": "[16128640]", // core.bin字节大小 多chip时,存在多个值 "sub_image_size_ex": 16128640, // core.bin字节大小 } } 在多分辨率模型场景中,包含分辨率index、noc配置,具体描述如下: :: "coremem_res_index_addr": 4092, // core内分辨率index保存地址 "coremem_res_pc_offset": 7, // core内分辨率pc偏移值loadnn前,将index + offset结果写入index保存地址 "resolution_config": { // 多分辨率配置 "res0": { // 分辨率0配置 "core_phy_id": [ // 需要配置分辨率index的core物理id … // 此处省略core id ], "noc_config": { // 所有core路由noc配置,每个core配置31条lut // loadnn之后,startnn之前配置 // 不同分辨率下,模型noc有差异,需要重新配置 "core_noc_0": [ … // 此处省略lut配置 ], … // 此处省略其它core noc配置 "core_noc_29": [ … // 此处省略lut配置 ], "core_noc_reg_addr": 1572864 // noc寄存器起始地址,每个寄存器占8字节, // 按8字节倍数偏移,写入全部lut配置 }, "shape": [ // 分辨率0 输入节点维度 1, 112, 112, 3 ] }, "res1": { // 分辨率1配置 "core_phy_id": [ // 需要配置分辨率index的core物理id … // 此处省略core id ], "noc_config": { // 所有core路由noc配置,每个core配置31条lut // loadnn之后,startnn之前配置 // 不同分辨率下,模型noc有差异,需要重新配置 "core_noc_0": [ … // 此处省略lut配置 ], … // 此处省略其它core noc配置 "core_noc_9": [ … // 此处省略lut配置 ], "core_noc_reg_addr": 1572864 // noc寄存器起始地址,每个寄存器占8字节, // 按8字节倍数偏移,写入全部lut配置 }, "shape": [ // 分辨率1 输入节点维度 1, 64, 64, 3 ] } }, "resolution_num": 2, // 分辨率总数量