diff --git a/mindspore/lite/src/weight_decoder.cc b/mindspore/lite/src/weight_decoder.cc index b90e8e78d10..f1dbeecd8ca 100644 --- a/mindspore/lite/src/weight_decoder.cc +++ b/mindspore/lite/src/weight_decoder.cc @@ -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(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(); diff --git a/mindspore/lite/src/weight_decoder.h b/mindspore/lite/src/weight_decoder.h index 6a564a0cb8a..93231798cdb 100644 --- a/mindspore/lite/src/weight_decoder.h +++ b/mindspore/lite/src/weight_decoder.h @@ -221,7 +221,7 @@ class WeightDecoder { while (static_cast(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(bit_tmp) << k) + uint_result; + uint_result = (static_cast(bit_tmp) << static_cast(k)) + uint_result; unpack_bit_data->pop(); } result = uint_result - static_cast(pow(2, origin_bit - 1));