clean codex

This commit is contained in:
hangangqiang 2021-05-10 19:34:00 +08:00
parent f10c015be4
commit cf9ade8a63
2 changed files with 7 additions and 3 deletions

View File

@ -234,9 +234,13 @@ int WeightDecoder::DecodeHuffmanCode(const schema::Tensor &src_tensor, lite::Ten
if (!dst_tensor->IsConst() || !src_tensor.enableHuffmanCode()) {
return RET_NO_CHANGE;
}
MS_ASSERT(src_tensor.data() != nullptr);
if (src_tensor.data() == nullptr) {
return RET_NO_CHANGE;
}
auto data = reinterpret_cast<const char *>(src_tensor.data()->data());
MS_ASSERT(data != nullptr);
if (data == nullptr) {
return RET_NO_CHANGE;
}
std::string encode_str(data, src_tensor.data()->size());
dst_tensor->set_data(nullptr);
auto ret = dst_tensor->MallocData();

View File

@ -221,7 +221,7 @@ class WeightDecoder {
while (static_cast<int>(unpack_bit_data->size()) >= origin_bit) {
for (int k = 0; k < origin_bit; k++) {
bool bit_tmp = unpack_bit_data->front();
uint_result = (static_cast<int>(bit_tmp) << k) + uint_result;
uint_result = (static_cast<int>(bit_tmp) << static_cast<unsigned int>(k)) + uint_result;
unpack_bit_data->pop();
}
result = uint_result - static_cast<T2>(pow(2, origin_bit - 1));