forked from mindspore-Ecosystem/mindspore
fix code check
This commit is contained in:
parent
4e574bc8dd
commit
9dfca91796
|
@ -84,7 +84,7 @@ class MS_API InputAndOutput {
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<CellBase> cell_;
|
std::shared_ptr<CellBase> cell_;
|
||||||
std::vector<InputAndOutput> prev_;
|
std::vector<InputAndOutput> prev_;
|
||||||
int32_t index_;
|
int32_t index_ = 0;
|
||||||
};
|
};
|
||||||
} // namespace mindspore
|
} // namespace mindspore
|
||||||
#endif // MINDSPORE_INCLUDE_API_CELL_H
|
#endif // MINDSPORE_INCLUDE_API_CELL_H
|
||||||
|
|
|
@ -352,8 +352,8 @@ void MSTensor::SetTensorName(const std::string &name) { return SetTensorName(Str
|
||||||
|
|
||||||
using Key = struct Key {
|
using Key = struct Key {
|
||||||
const size_t max_key_len = 32;
|
const size_t max_key_len = 32;
|
||||||
size_t len;
|
size_t len = 0;
|
||||||
unsigned char key[32];
|
unsigned char key[32] = {0};
|
||||||
Key() : len(0) {}
|
Key() : len(0) {}
|
||||||
explicit Key(const char *dec_key, size_t key_len);
|
explicit Key(const char *dec_key, size_t key_len);
|
||||||
};
|
};
|
||||||
|
|
|
@ -74,7 +74,7 @@ bool ParseEncryptData(const Byte *encrypt_data, size_t encrypt_len, std::vector<
|
||||||
}
|
}
|
||||||
int_buf.assign(encrypt_data, encrypt_data + sizeof(int32_t));
|
int_buf.assign(encrypt_data, encrypt_data + sizeof(int32_t));
|
||||||
auto iv_len = ByteToInt(int_buf.data(), int_buf.size());
|
auto iv_len = ByteToInt(int_buf.data(), int_buf.size());
|
||||||
if (iv_len <= 0 || iv_len + sizeof(int32_t) + sizeof(int32_t) > encrypt_len) {
|
if (iv_len <= 0 || static_cast<size_t>(iv_len) + sizeof(int32_t) + sizeof(int32_t) > encrypt_len) {
|
||||||
MS_LOG(ERROR) << "assign len is invalid.";
|
MS_LOG(ERROR) << "assign len is invalid.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,8 @@ bool ParseEncryptData(const Byte *encrypt_data, size_t encrypt_len, std::vector<
|
||||||
}
|
}
|
||||||
|
|
||||||
(*iv).assign(encrypt_data + sizeof(int32_t), encrypt_data + sizeof(int32_t) + iv_len);
|
(*iv).assign(encrypt_data + sizeof(int32_t), encrypt_data + sizeof(int32_t) + iv_len);
|
||||||
if (cipher_len <= 0 || sizeof(int32_t) + iv_len + sizeof(int32_t) + cipher_len > encrypt_len) {
|
if (cipher_len <= 0 ||
|
||||||
|
sizeof(int32_t) + static_cast<size_t>(iv_len) + sizeof(int32_t) + static_cast<size_t>(cipher_len) > encrypt_len) {
|
||||||
MS_LOG(ERROR) << "assign len is invalid.";
|
MS_LOG(ERROR) << "assign len is invalid.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -300,7 +301,7 @@ std::unique_ptr<Byte[]> Decrypt(const std::string &lib_path, size_t *decrypt_len
|
||||||
MS_LOG(ERROR) << "The block_size read from the cipher data must be not negative, but got " << block_size;
|
MS_LOG(ERROR) << "The block_size read from the cipher data must be not negative, but got " << block_size;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (offset + block_size > data_size) {
|
if (offset + static_cast<size_t>(block_size) > data_size) {
|
||||||
MS_LOG(ERROR) << "assign len is invalid.";
|
MS_LOG(ERROR) << "assign len is invalid.";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@ int CalQuantizationParams(schema::QuantParamT *quant_param, double real_min, dou
|
||||||
int GetBucketIndex(const std::vector<int> &dims, int preferred_dim, int data_index) {
|
int GetBucketIndex(const std::vector<int> &dims, int preferred_dim, int data_index) {
|
||||||
int stride = 1;
|
int stride = 1;
|
||||||
int bucket_count = dims[preferred_dim];
|
int bucket_count = dims[preferred_dim];
|
||||||
for (size_t i = preferred_dim + 1; i < dims.size(); i++) {
|
for (size_t i = static_cast<size_t>(preferred_dim + 1); i < dims.size(); i++) {
|
||||||
stride *= dims[i];
|
stride *= dims[i];
|
||||||
}
|
}
|
||||||
if (stride == 0 || bucket_count == 0) {
|
if (stride == 0 || bucket_count == 0) {
|
||||||
|
@ -134,8 +134,11 @@ int CalPerChannelGain(size_t bit_num, const std::vector<int> &dims, int preferre
|
||||||
const int bits_per_byte = 8;
|
const int bits_per_byte = 8;
|
||||||
const int quant_param_size = 32;
|
const int quant_param_size = 32;
|
||||||
int channels = dims.at(preferred_dim);
|
int channels = dims.at(preferred_dim);
|
||||||
CHECK_LESS_RETURN(channels, 1);
|
if (channels < 1) {
|
||||||
size_t bucket_size = elem_count / channels;
|
MS_LOG(ERROR) << "channels must not less 1";
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
size_t bucket_size = static_cast<size_t>(elem_count / channels);
|
||||||
bool do_quant = (quant_param_size * bits_per_byte) / (sizeof(float) * bits_per_byte - bit_num) < bucket_size;
|
bool do_quant = (quant_param_size * bits_per_byte) / (sizeof(float) * bits_per_byte - bit_num) < bucket_size;
|
||||||
if (do_quant) {
|
if (do_quant) {
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
|
@ -157,7 +160,7 @@ int CalWeightQuantBias(const float *raw_datas, size_t elem_count, const std::vec
|
||||||
std::map<int, double> var_raws;
|
std::map<int, double> var_raws;
|
||||||
std::map<int, double> var_dequants;
|
std::map<int, double> var_dequants;
|
||||||
size_t bucket_size = quant_params->size();
|
size_t bucket_size = quant_params->size();
|
||||||
int bucket_volume = elem_count / dims[preferred_dim];
|
int bucket_volume = static_cast<size_t>(elem_count / dims[preferred_dim]);
|
||||||
// Init Map
|
// Init Map
|
||||||
for (size_t i = 0; i < bucket_size; i++) {
|
for (size_t i = 0; i < bucket_size; i++) {
|
||||||
total_raws[i] = 0;
|
total_raws[i] = 0;
|
||||||
|
|
|
@ -59,7 +59,8 @@ int WriteStringsToTensor(Tensor *tensor, const std::vector<StringPack> &string_b
|
||||||
}
|
}
|
||||||
size_t num = string_buffer.size();
|
size_t num = string_buffer.size();
|
||||||
std::vector<int32_t> offset(num + 1);
|
std::vector<int32_t> offset(num + 1);
|
||||||
offset[0] = 4 * (num + 2);
|
const size_t extra_offset_num = 2;
|
||||||
|
offset[0] = static_cast<int32_t>(sizeof(int32_t) * (num + extra_offset_num));
|
||||||
for (size_t i = 0; i < num; i++) {
|
for (size_t i = 0; i < num; i++) {
|
||||||
offset[i + 1] = offset[i] + string_buffer[i].len;
|
offset[i + 1] = offset[i] + string_buffer[i].len;
|
||||||
}
|
}
|
||||||
|
@ -92,7 +93,8 @@ int WriteSeperatedStringsToTensor(Tensor *tensor, const std::vector<std::vector<
|
||||||
}
|
}
|
||||||
size_t num = string_buffer.size();
|
size_t num = string_buffer.size();
|
||||||
std::vector<int32_t> offset(num + 1);
|
std::vector<int32_t> offset(num + 1);
|
||||||
offset[0] = 4 * (num + 2);
|
const size_t extra_offset_num = 2;
|
||||||
|
offset[0] = static_cast<int32_t>(sizeof(int32_t) * (num + extra_offset_num));
|
||||||
std::vector<int> len(num);
|
std::vector<int> len(num);
|
||||||
for (size_t i = 0; i < num; i++) {
|
for (size_t i = 0; i < num; i++) {
|
||||||
len[i] = 0;
|
len[i] = 0;
|
||||||
|
|
Loading…
Reference in New Issue