SNPE教程2-量化

写在前面

官方手册上和量化相关的内容:

  1. quantizing a model: https://developer.qualcomm.com/sites/default/files/docs/snpe/model_conversion.html
  2. 工具snpe-dlc-quantize:https://developer.qualcomm.com/sites/default/files/docs/snpe/tools.html#tools_snpe-dlc-quantize
  3. 何时使用量化:
    https://developer.qualcomm.com/sites/default/files/docs/snpe/quantized_models.html

量化过程

  1. 工具位置
    $SNPE_ROOT/bin/x86_64-linux-clang
  2. 命令行下输入命令进行转换
    ./snpe-dlc-quantize --input_dlc inception_v3.dlc --input_list /home/node2/snpe/inception_demo/data/cropped/raw_list.txt
    
    snpe-dlc-quantize命令参数简要解析:
    [-h,——help]显示帮助信息。
    [——version]显示版本信息。
    [——input_dlc]包含定点编码模型的dlc容器的路径应该生成元数据。这个参数是必需的。
    [——input_list]指定试验输入的文件的路径。这个文件应该是纯文本文件,每行包含一个或多个绝对文件路径。这些档案将被用作试验设置。每个路径都指向一个包含一个试验输入的二进制文件“原始”格式,无需任何进一步修改即可被SNPE使用。这与向snpe-net运行的应用程序提供输入的方式类似。
    [——output_dlc = < val >]应该写入包含元数据的量化模型容器的路径。如果省略此参数,量化模型将写入_quantized.dlc。
    
  3. 出现报错
    ./snpe-dlc-quantize: error while loading shared libraries: libomp.so: cannot open shared object file: No such file or directory
    
    查找libomp.so的位置:ind / -name libomp.so 2>/dev/null
    将得到的位置加入环境变量:
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/node2/snpe/snpe-1.40.0.2130/lib/x86_64-linux-clang
  4. 重复2中的命令,量化转换成功
    [INFO] InitializeStderr: DebugLog initialized.
    [INFO] Writing intermediate model
    [WARNING] NetworkTopology::populateNetworkDesc network desc inputs is empty. Does this network have data/input layer?
    [INFO] Setting activation for layer: input:0 and buffer: input:0
    [INFO] bw: 8, min: -1.000000, max: 0.992188, delta: 0.007812, offset: -128.000000
    [INFO] Setting activation for layer: InceptionV3/InceptionV3/Conv2d_1a_3x3/convolution and buffer: InceptionV3/InceptionV3/Conv2d_1a_3x3/BatchNorm/batchnorm/add_1:0
    [INFO] bw: 8, min: -10.426631, max: 10.674884, delta: 0.082751, offset: -126.000000
    [INFO] Setting activation for layer: InceptionV3/InceptionV3/Conv2d_1a_3x3/Relu and buffer: InceptionV3/InceptionV3/Conv2d_1a_3x3/Relu:0
    [INFO] bw: 8, min: 0.000000, max: 10.647199, delta: 0.041754, offset: 0.000000
    [INFO] Setting activation for layer: InceptionV3/InceptionV3/Conv2d_2a_3x3/convolution and buffer: InceptionV3/InceptionV3/Conv2d_2a_3x3/BatchNorm/batchnorm/add_1:0
    [INFO] bw: 8, min: -8.310483, max: 8.508352, delta: 0.065956, offset: -126.000000
    [INFO] Setting activation for layer: InceptionV3/InceptionV3/Conv2d_2a_3x3/Relu and buffer: InceptionV3/InceptionV3/Conv2d_2a_3x3/Relu:0
    [INFO] bw: 8, min: 0.000000, max: 8.484724, delta: 0.033273, offset: 0.000000
    [INFO] Setting activation for layer: InceptionV3/InceptionV3/Conv2d_2b_3x3/convolution and buffer: InceptionV3/InceptionV3/Conv2d_2b_3x3/BatchNorm/batchnorm/add_1:0
    [INFO] bw: 8, min: -9.289681, max: 10.616778, delta: 0.078065, offset: -119.000000
    [INFO] Setting activation for layer: InceptionV3/InceptionV3/Conv2d_2b_3x3/Relu and buffer: InceptionV3/InceptionV3/Conv2d_2b_3x3/Relu:0
    [INFO] bw: 8, min: 0.000000, max: 10.628510, delta: 0.041680, offset: 0.000000
    [INFO] Setting activation for layer: InceptionV3/InceptionV3/MaxPool_3a_3x3/MaxPool and buffer: InceptionV3/InceptionV3/MaxPool_3a_3x3/MaxPool:0
    [INFO] bw: 8, min: 0.000000, max: 10.628510, delta: 0.041680, offset: 0.000000
    [INFO] Setting activation for layer: InceptionV3/InceptionV3/Conv2d_3b_1x1/convolution and buffer: InceptionV3/InceptionV3/Conv2d_3b_1x1/BatchNorm/batchnorm/add_1:0
    [INFO] bw: 8, min: -6.303848, max: 11.557054, delta: 0.070043, offset: -90.000000
    

你可能感兴趣的:(SNPE,边缘计算)