forked from mindspore-Ecosystem/mindspore
master lite train codex clean
This commit is contained in:
parent
7b6822b9d4
commit
a2ed372ccd
|
@ -479,5 +479,4 @@ int Model::Export(Model *model, const char *filename) {
|
|||
return chmod(filename, S_IRUSR);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace mindspore::lite
|
||||
|
|
|
@ -20,11 +20,13 @@
|
|||
#include "src/huffman_decode.h"
|
||||
|
||||
namespace mindspore::lite {
|
||||
constexpr int kBit8 = 8;
|
||||
constexpr int kBit32 = 32;
|
||||
std::vector<bool> StringToBitVector(const std::string &str) {
|
||||
std::vector<bool> vec(str.size() * 8);
|
||||
std::vector<bool> vec(str.size() * kBit8);
|
||||
size_t index = 0;
|
||||
for (auto ch : str) {
|
||||
for (size_t shift = 8; shift > 0; shift--) {
|
||||
for (size_t shift = kBit8; shift > 0; shift--) {
|
||||
vec[index++] = (ch >> (shift - 1)) & 0x1;
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +49,7 @@ STATUS IndexingDecompress(const schema::Tensor &src_tensor, Tensor *dst_tensor)
|
|||
if (unique_value_cnt == 0) {
|
||||
unique_value_cnt = 1 << bit_num;
|
||||
}
|
||||
// parse unique_value_set;
|
||||
// parse unique_value_set
|
||||
std::vector<int> unique_values;
|
||||
for (size_t i = 0; i < unique_value_cnt; i++) {
|
||||
int unique_value = 0;
|
||||
|
@ -81,7 +83,7 @@ STATUS IndexingDecompress(const schema::Tensor &src_tensor, Tensor *dst_tensor)
|
|||
return RET_NULL_PTR;
|
||||
}
|
||||
auto dst_data = dst_tensor->data_c();
|
||||
if (bit_num <= 8) {
|
||||
if (bit_num <= kBit8) {
|
||||
ret = UnIndexTensorData<int8_t>(unique_values, unique_value_index_vec, dst_data, dst_tensor->Size());
|
||||
} else {
|
||||
ret = UnIndexTensorData<int16_t>(unique_values, unique_value_index_vec, dst_data, dst_tensor->Size());
|
||||
|
@ -102,15 +104,15 @@ STATUS SparseDecompress(const schema::Tensor &src_tensor, Tensor *dst_tensor) {
|
|||
size_t index = 0;
|
||||
// parse coor_best_bit
|
||||
size_t coor_best_bit = 0;
|
||||
for (size_t i = 0; i < 8; i++) {
|
||||
for (size_t i = 0; i < kBit8; i++) {
|
||||
bool bit = bit_vec[index++];
|
||||
coor_best_bit |= bit << (8 - i - 1);
|
||||
coor_best_bit |= bit << (kBit8 - i - 1);
|
||||
}
|
||||
// parse nz_cnt
|
||||
size_t nz_cnt = 0;
|
||||
for (size_t i = 0; i < 32; i++) {
|
||||
for (size_t i = 0; i < kBit32; i++) {
|
||||
bool bit = bit_vec[index++];
|
||||
nz_cnt |= bit << (32 - i - 1);
|
||||
nz_cnt |= bit << (kBit32 - i - 1);
|
||||
}
|
||||
// parse unique_value cnt
|
||||
size_t unique_value_cnt = 0;
|
||||
|
@ -167,7 +169,7 @@ STATUS SparseDecompress(const schema::Tensor &src_tensor, Tensor *dst_tensor) {
|
|||
}
|
||||
auto dst_data = dst_tensor->data_c();
|
||||
|
||||
if (bit_num <= 8) {
|
||||
if (bit_num <= kBit8) {
|
||||
ret = UnSparseTensorData<int8_t>(unique_values, unique_value_index_vec, coor_vec, src_tensor.quantParams(),
|
||||
elem_cnt, coor_best_bit, dst_data, dst_tensor->Size());
|
||||
} else {
|
||||
|
|
|
@ -230,15 +230,8 @@ STATUS BatchNormConvertScalePass::GetTransParam(MetaGraphT *graph, const std::un
|
|||
return RET_OK;
|
||||
}
|
||||
|
||||
// BatchNorm weight Tensor definition:
|
||||
// caffe
|
||||
// estimated_mean --0
|
||||
// estimated_variance --1
|
||||
// tensorflow
|
||||
// scale -- 0
|
||||
// bias --1
|
||||
// estimated_mean --2
|
||||
// estimated_variance --3
|
||||
// caffe:estimated_mean:0 estimated_variance:1
|
||||
// tensorflow scale:0,bias:1,estimated_mean:2,estimated_variance:3
|
||||
STATUS BatchNormConvertScalePass::GetBnWeightTensors(MetaGraphT *graph, BNWeightTensors *bnWeightTensors,
|
||||
const std::unique_ptr<CNodeT> &bnNode) {
|
||||
MS_ASSERT(graph != nullptr);
|
||||
|
|
|
@ -143,7 +143,7 @@ STATUS WeightQuantizer::DoMulQuantize(const CNodePtr &cnode) {
|
|||
|
||||
auto status = RET_ERROR;
|
||||
auto per_channel = true;
|
||||
if (i == 3) {
|
||||
if (i == kInputSize2) {
|
||||
per_channel = false;
|
||||
}
|
||||
if (type_id_ == kNumberTypeInt8) {
|
||||
|
|
Loading…
Reference in New Issue