tensorrtx
tensorrtx copied to clipboard
从wts文件读取权重数据,应该是hex的float值, 为什么存储在 uint32_t中啊
问一下下面这段代码中, 是从wts文件读取权重数据,应该是hex的float值, 为什么存储在 uint32_t中啊?
while (count--) { Weights wt{ DataType::kFLOAT, nullptr, 0 }; uint32_t size;
// Read name and type of blob
std::string name;
input >> name >> std::dec >> size;
wt.type = DataType::kFLOAT;
// Load blob
uint32_t* val = reinterpret_cast<uint32_t*>(malloc(sizeof(val) * size));
for (uint32_t x = 0, y = size; x < y; ++x) {
input >> std::hex >> val[x];
}
wt.values = val;
wt.count = size;
weightMap[name] = wt;
}
这里是二进制转换,用uint32_t存储二进制值,这个二进制值实际表示的是float
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.