| @@ -66,6 +66,7 @@ class DequantUtil { | |||||
| if (!channel_first) { | if (!channel_first) { | ||||
| if (input_tensor->shape().size() != 2) { | if (input_tensor->shape().size() != 2) { | ||||
| MS_LOG(ERROR) << "unexpected shape size: " << input_tensor->shape().size(); | MS_LOG(ERROR) << "unexpected shape size: " << input_tensor->shape().size(); | ||||
| free(dequant_datas); | |||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| channels = input_tensor->shape()[1]; | channels = input_tensor->shape()[1]; | ||||
| @@ -290,6 +290,7 @@ OpParameter *PopulatePoolingGradParameter(const void *primitive) { | |||||
| break; | break; | ||||
| default: | default: | ||||
| MS_LOG(ERROR) << "unknown pooling mode: " << poolingGrad_prim->poolingMode(); | MS_LOG(ERROR) << "unknown pooling mode: " << poolingGrad_prim->poolingMode(); | ||||
| free(pooling_param); | |||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| @@ -74,7 +74,9 @@ std::unique_ptr<char[]> ReadFileToBuf(const std::string &filename, size_t *size) | |||||
| return std::unique_ptr<char[]>(nullptr); | return std::unique_ptr<char[]>(nullptr); | ||||
| } | } | ||||
| ifs.close(); | ifs.close(); | ||||
| if (size) *size = fsize; | |||||
| if (size != nullptr) { | |||||
| *size = fsize; | |||||
| } | |||||
| return buf; | return buf; | ||||
| } | } | ||||
| @@ -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_; } | 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) { | for (std::size_t dim = 0; dim != out->shape().size(); ++dim) { | ||||
| if (in->shape().at(mask[dim]) != out->shape().at(dim)) { | if (in->shape().at(mask[dim]) != out->shape().at(dim)) { | ||||
| return false; | return false; | ||||
| @@ -85,7 +86,7 @@ int TransferSession::CompileTransferGraph() { | |||||
| } | } | ||||
| if (match == false && input->shape().size() == 4) { | if (match == false && input->shape().size() == 4) { | ||||
| int nchw2nhwc_mask[4] = {0, 3, 1, 2}; | int nchw2nhwc_mask[4] = {0, 3, 1, 2}; | ||||
| nchw2nhwc_ = CompileFormatTransform(output, input, nchw2nhwc_mask); | |||||
| nchw2nhwc_ = CompileFormatTransform(output, input, nchw2nhwc_mask, 4); | |||||
| match = nchw2nhwc_; | match = nchw2nhwc_; | ||||
| } | } | ||||
| if (true == match) { | if (true == match) { | ||||
| @@ -71,7 +71,7 @@ class TransferSession : public lite::TrainSession { | |||||
| bool is_valid_ = false; | bool is_valid_ = false; | ||||
| private: | 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; | bool nchw2nhwc_ = false; | ||||
| }; | }; | ||||
| } // namespace lite | } // namespace lite | ||||