!7579 [MS][LITE]fix onnx pool parser, fixed striped_sclice memory out of bounds

Merge pull request !7579 from gongdaguo/fix_pool
This commit is contained in:
mindspore-ci-bot 2020-10-22 09:57:56 +08:00 committed by Gitee
commit da0be40224
3 changed files with 17 additions and 7 deletions

View File

@ -254,18 +254,17 @@ int StridedSlice::InferShape(std::vector<lite::Tensor *> inputs, std::vector<lit
auto input = inputs.at(0);
outputs.front()->set_data_type(input->data_type());
outputs[0]->SetFormat(input->GetFormat());
if (!GetInferFlag()) {
return RET_OK;
}
MS_ASSERT(input != nullptr);
auto input_shape = input->shape();
std::vector<int> output_shape;
auto inferflag = GetInferFlag();
if (inputs.size() == kStridedSliceInputNum) {
ndim_ = static_cast<int>(GetBegin().size());
for (int i = 0; i < ndim_; i++) {
in_shape_.emplace_back(input_shape.at(i));
if (inferflag) {
in_shape_.emplace_back(input_shape.at(i));
}
begins_.emplace_back((GetBegin())[i]);
ends_.emplace_back((GetEnd())[i]);
strides_.emplace_back((GetStride())[i]);
@ -282,7 +281,9 @@ int StridedSlice::InferShape(std::vector<lite::Tensor *> inputs, std::vector<lit
}
ndim_ = begin_tensor->ElementsNum();
for (int i = 0; i < ndim_; ++i) {
in_shape_.emplace_back(input_shape.at(i));
if (inferflag) {
in_shape_.emplace_back(input_shape.at(i));
}
begins_.emplace_back(begin_data[i]);
ends_.emplace_back(end_data[i]);
strides_.emplace_back(stride_data[i]);
@ -310,6 +311,10 @@ int StridedSlice::InferShape(std::vector<lite::Tensor *> inputs, std::vector<lit
ApplyEndMask();
ApplyEllipsisMask();
if (!inferflag) {
return RET_OK;
}
std::vector<int> output_shape;
output_shape.clear();
output_shape.resize(in_shape_.size());

View File

@ -1,6 +1,7 @@
mtk_detect-mbv2-shortcut-400-400-simplified.onnx
mtk_emotions-d2012-75.8%.onnx
mtk_face_features_v3.onnx
emotion-ferplus-8.onnx
ml_face_3d.onnx
gts_version-RFB-320_simplified.onnx
mnist-8.onnx

View File

@ -94,7 +94,11 @@ STATUS OnnxPoolParser::Parse(const onnx::GraphProto &onnx_graph, const onnx::Nod
}
}
if (attribute_name == "ceil_mode") {
attr->roundMode = schema::RoundMode_CEIL;
if (onnx_node_attr.f() == 0) {
attr->roundMode = schema::RoundMode_FLOOR;
} else {
attr->roundMode = schema::RoundMode_CEIL;
}
}
if (attribute_name == "dilations") {
MS_LOG(ERROR) << "pooling op not support dilations now";