Browse Source

!11031 fix resize converted i64 and wrong height

From: @zhaozhenlong
Reviewed-by: @zhang_xue_tong,@hangangqiang
Signed-off-by: @zhang_xue_tong
tags/v1.2.0-rc1
mindspore-ci-bot Gitee 4 years ago
parent
commit
c3dbbd144e
2 changed files with 8 additions and 6 deletions
  1. +2
    -2
      mindspore/lite/src/runtime/kernel/arm/base/resize_base.cc
  2. +6
    -4
      mindspore/lite/tools/converter/parser/onnx/onnx_slice_parser.cc

+ 2
- 2
mindspore/lite/src/runtime/kernel/arm/base/resize_base.cc View File

@@ -62,12 +62,12 @@ int ResizeBaseCPUKernel::CheckParameters() {
MS_LOG(INFO) << "Out shape is not assigned";
const_shape_ = false;
} else {
new_height_ = reinterpret_cast<int32_t *>(out_shape)[0];
new_height_ = out_tensors_.at(0)->shape()[1];
if (new_height_ < 1) {
MS_LOG(ERROR) << "Resize new_height should >= 1, but got " << new_height_;
return RET_INVALID_OP_ATTR;
}
new_width_ = reinterpret_cast<int32_t *>(out_shape)[1];
new_width_ = out_tensors_.at(0)->shape()[2];
if (new_width_ < 1) {
MS_LOG(ERROR) << "Resize new_width should >= 1, but got " << new_width_;
return RET_INVALID_OP_ATTR;


+ 6
- 4
mindspore/lite/tools/converter/parser/onnx/onnx_slice_parser.cc View File

@@ -15,6 +15,7 @@
*/

#include "tools/converter/parser/onnx/onnx_slice_parser.h"
#include <algorithm>
#include <functional>
#include <memory>
#include <numeric>
@@ -36,31 +37,32 @@ lite::PrimitiveC *OnnxSliceParser::ParseLitePrimitive(const onnx::GraphProto &on
std::vector<int> ends;
std::vector<int> axes;
std::vector<int> steps;
constexpr int64_t int_32_max = INT32_MAX;
for (const auto &onnx_node_attr : onnx_node.attribute()) {
const auto &attribute_name = onnx_node_attr.name();
if (attribute_name == "starts") {
const int num = onnx_node_attr.ints_size();
starts.clear();
for (int i = 0; i < num; ++i) {
starts.push_back(static_cast<int>(onnx_node_attr.ints()[i]));
starts.push_back(static_cast<int>(std::min(onnx_node_attr.ints()[i], int_32_max)));
}
} else if (attribute_name == "axes") {
const int num = onnx_node_attr.ints_size();
axes.clear();
for (int i = 0; i < num; ++i) {
axes.push_back(static_cast<int>(onnx_node_attr.ints()[i]));
axes.push_back(static_cast<int>(std::min(onnx_node_attr.ints()[i], int_32_max)));
}
} else if (attribute_name == "ends") {
const int num = onnx_node_attr.ints_size();
ends.clear();
for (int i = 0; i < num; ++i) {
ends.push_back(static_cast<int>(onnx_node_attr.ints()[i]));
ends.push_back(static_cast<int>(std::min(onnx_node_attr.ints()[i], int_32_max)));
}
} else if (attribute_name == "steps") {
const int num = onnx_node_attr.ints_size();
steps.clear();
for (int i = 0; i < num; ++i) {
steps.push_back(static_cast<int>(onnx_node_attr.ints()[i]));
steps.push_back(static_cast<int>(std::min(onnx_node_attr.ints()[i], int_32_max)));
}
}
}


Loading…
Cancel
Save