!14360 fix codex warnings

From: @xutianchun
Reviewed-by: @HilbertDavid,@zhanghaibo5
Signed-off-by: @HilbertDavid
This commit is contained in:
mindspore-ci-bot 2021-03-30 16:55:49 +08:00 committed by Gitee
commit fe33972027
5 changed files with 9 additions and 4 deletions

View File

@ -66,6 +66,7 @@ class DequantUtil {
if (!channel_first) {
if (input_tensor->shape().size() != 2) {
MS_LOG(ERROR) << "unexpected shape size: " << input_tensor->shape().size();
free(dequant_datas);
return nullptr;
}
channels = input_tensor->shape()[1];

View File

@ -290,6 +290,7 @@ OpParameter *PopulatePoolingGradParameter(const void *primitive) {
break;
default:
MS_LOG(ERROR) << "unknown pooling mode: " << poolingGrad_prim->poolingMode();
free(pooling_param);
return nullptr;
}

View File

@ -74,7 +74,9 @@ std::unique_ptr<char[]> ReadFileToBuf(const std::string &filename, size_t *size)
return std::unique_ptr<char[]>(nullptr);
}
ifs.close();
if (size) *size = fsize;
if (size != nullptr) {
*size = fsize;
}
return buf;
}

View File

@ -55,7 +55,8 @@ TransferSession::TransferSession(const char *model_buf_backbone, size_t size_bac
std::vector<tensor::MSTensor *> TransferSession::GetInputs() const { return combined_inputs_; }
bool TransferSession::CompileFormatTransform(tensor::MSTensor *out, tensor::MSTensor *in, int *mask) {
bool TransferSession::CompileFormatTransform(tensor::MSTensor *out, tensor::MSTensor *in, int *mask, size_t mask_len) {
MS_ASSERT(out->shape().size() == mask_len);
for (std::size_t dim = 0; dim != out->shape().size(); ++dim) {
if (in->shape().at(mask[dim]) != out->shape().at(dim)) {
return false;
@ -85,7 +86,7 @@ int TransferSession::CompileTransferGraph() {
}
if (match == false && input->shape().size() == 4) {
int nchw2nhwc_mask[4] = {0, 3, 1, 2};
nchw2nhwc_ = CompileFormatTransform(output, input, nchw2nhwc_mask);
nchw2nhwc_ = CompileFormatTransform(output, input, nchw2nhwc_mask, 4);
match = nchw2nhwc_;
}
if (true == match) {

View File

@ -71,7 +71,7 @@ class TransferSession : public lite::TrainSession {
bool is_valid_ = false;
private:
bool CompileFormatTransform(tensor::MSTensor *out, tensor::MSTensor *in, int *mask);
bool CompileFormatTransform(tensor::MSTensor *out, tensor::MSTensor *in, int *mask, size_t mask_len);
bool nchw2nhwc_ = false;
};
} // namespace lite