欢迎光临散文网 会员登陆 & 注册

FDF互助游戏开发原理丨FDF互助智能合约游戏系统开发(开发规则及详情)

2023-03-07 16:10 作者:bili_16249894763  | 我要投稿

  From Web1.0 to Web3.0,from user read-only to user owned.Web1.0 is a read-only network,a static and one-way network,representing browsers and e-commerce;Web 2.0 pays more attention to user interaction.Users are both browsers and content producers.


The mode of development is from"read"to"write",and the representative products are social media and short video platforms;Web3.0 is the Internet of Value,and Web3.0 is a set of inclusive protocols that provide building blocks for application manufacturers


  void Calibration::_fake_quant_weights(){


  //找到权重中最大值(绝对值)的lamda函数


  auto findAbsMax=[&](const float*weights,const int size){


  float absMax=0;


  for(int i=0;i<size;i++){


  if(std::fabs(weights<i>)>absMax){


  absMax=std::fabs(weights<i>);


  }


  }


  return absMax;


  };


  for(const auto&op:_originaleModel->oplists){


  //跳过指定不需要量化的op,以及非Convolution


  std::vector<std::string>::iterator iter=std::find(_skip_quant_ops.begin(),_skip_quant_ops.end(),op->name);


  if(iter!=_skip_quant_ops.end()){需求及详情I35模式7O98开发O7I8


  continue;


  }


  const auto opType=op->type;


  if(opType!=MNN::OpType_Convolution&&opType!=MNN::OpType_ConvolutionDepthwise){


  continue;


  }开发功能及源码:MrsFu123


  auto param=op->main.AsConvolution2D();


  const int kernelNum=param->common->outputCount;


  std::vector<float>weights=param->weight;


  const int weightSize=weights.size();


  const int kernelSize=weightSize/kernelNum;


  //对每个kernel进行量化


  for(int i=0;i<kernelNum;i++){


  const int offset=i*kernelSize;


  float absMax=findAbsMax(weights.data()+offset,kernelSize);


  float scale=absMax/_weightClampValue;//根据最大值计算缩放因子


  if(absMax<1e-6f){


  scale=absMax;


  }


  for(int j=0;j<kernelSize;j++){


  float value=weights[offset+j];


  float quantValue=std::round(value/scale);//量化到int8的值


  float clampedValue=std::max(std::min(quantValue,_weightClampValue),-_weightClampValue);//小于-127的部分,映射到-127


  float dequantValue=scale*clampedValue;


  param->weight[offset+j]=dequantValue;//反量化


  }


  }


  }


  }


FDF互助游戏开发原理丨FDF互助智能合约游戏系统开发(开发规则及详情)的评论 (共 条)

分享到微博请遵守国家法律