DAY6(Auto_quantization build&quantize)

Auto_quantization

  • build:
    ir contains net_property and op_list and weights_dict
    save net property and op list
    op attributes initialized with the weight/bias/scale/shift/lut from the IR (???)
    infer the class num from IR
    forward parameters(reverse_rgb, precision, batch_size, input_scale, input_mean) and build inference op

  • quantize:
    read from the statistical max and min files (or calibrate the max and min)
    update quantize parameters(quantize_method, precision_bits, weight_bits, bias_bits, activation_bits, feature_bits, accum_bits)
    and crop to relu6
    use min_max_values and num_bits, quantize_method to calculate scale and zp

  • self.op_dict_{meta_op.id:meta_op}

  • cur_op.quantize(reshape op)
    cur_op is a class can be directed to different op class based on name
    saved to input scale, output scale, etc

n= 2 **(num_bits-1)-1 (if signed)/ 2 **num_bits -1 (if unsigned)
Symetric:
scale= n/abs_max
zp= np.zeros_like(scale)

  • build inference op

去掉concat操作

  • 在每一层中有不同分支具有不同的scale系数
  • concat操作合并分支
  • 将不同分支的scale系数调成一样后在硬件层面实现
  • 每一层的scale可看_int8.txt文件
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值