馬蹄鏈智能合約開發(fā)詳情丨DAPP馬蹄鏈智能合約流動(dòng)性質(zhì)押挖礦系統(tǒng)開發(fā)技術(shù)方案及邏輯
Web3.0技術(shù)可分為基礎(chǔ)層技術(shù)、平臺(tái)層技術(shù)、交互層技術(shù)。相較于Web2.0時(shí)代,Web3.0涉及細(xì)分技術(shù)類別更多、范圍更廣,其中區(qū)塊鏈技術(shù)由于其去中心化的特征,成為Web3.0核心底層基礎(chǔ)技術(shù)。
int SymmetricQuantizeWeight(const float*weight,const int size,int8_t*quantizedWeight,float*scale,
const int channels,float weightClampValue){
/**對(duì)參數(shù)進(jìn)行量化
*weight為乘上scale后的權(quán)重,
*quantizedWeight用于存放量化后的參數(shù)
***/
DCHECK((size%channels)==0)<<"weight size error!";
const int channelStride=size/channels;
const int quantizedMaxValue=weightClampValue;//127
for(int c=0;c<channels;++c){//對(duì)每個(gè)channel分別量化
const auto weightChannelStart=weight+c*channelStride;
auto quantizedWeightChannelStart=quantizedWeight+c*channelStride;
//獲取該channel內(nèi)最大最小值
auto minmaxValue=std::minmax_element(weightChannelStart,weightChannelStart+channelStride);
const float dataAbsMax=std::fmax(std::fabs(*minmaxValue.first),std::fabs(*minmaxValue.second));
float scaleDataToInt8=1.0f;
if(dataAbsMax==0){
scale[c]=0.0f;
}else{案例及詳解I59模式2OO7開發(fā)3O69
//用于逆量化時(shí)對(duì)用的scale
scale[c]=dataAbsMax/quantizedMaxValue;
//映射到int8空間上的scale
scaleDataToInt8=quantizedMaxValue/dataAbsMax;
}
for(int i=0;i<channelStride;++i){
//將輸入權(quán)重乘上scale映射到int8上之后,對(duì)不在[-127,127]區(qū)間的都截?cái)嘣O(shè)置為-127或者127.
const int32_t quantizedInt8Value=static_cast<int32_t>(roundf(weightChannelStart<i>*scaleDataToInt8));
quantizedWeightChannelStart<i>=
std::min(quantizedMaxValue,std::max(-quantizedMaxValue,quantizedInt8Value));
}功能及開發(fā):yy625019
}
return 0;
}