diff --git a/lite/kernels/host/matrix_nms_compute.cc b/lite/kernels/host/matrix_nms_compute.cc index b5c381e3f91df2cb20bf8317f3b430c373b42567..2fe4e6f9723a6bd5933f3c6638b9492c0cdac137 100644 --- a/lite/kernels/host/matrix_nms_compute.cc +++ b/lite/kernels/host/matrix_nms_compute.cc @@ -273,8 +273,8 @@ void MatrixNmsCompute::Run() { auto out_dim = box_dim + 2; Tensor boxes_slice, scores_slice; - size_t num_out = 0; - std::vector offsets = {0}; + int64_t num_out = 0; + std::vector offsets = {0}; std::vector detections; std::vector indices; detections.reserve(out_dim * num_boxes * batch_size); @@ -298,23 +298,25 @@ void MatrixNmsCompute::Run() { post_threshold, use_gaussian, gaussian_sigma); - offsets.push_back(offsets.back() + static_cast(num_out)); + offsets.push_back(offsets.back() + num_out); } - uint64_t num_kept = offsets.back(); + int64_t num_kept = offsets.back(); if (num_kept == 0) { outs->Resize({0, out_dim}); + outs->mutable_data(); index->Resize({0, 1}); + index->mutable_data(); } else { - outs->Resize({static_cast(num_kept), out_dim}); - index->Resize({static_cast(num_kept), 1}); + outs->Resize({num_kept, out_dim}); + index->Resize({num_kept, 1}); std::copy( detections.begin(), detections.end(), outs->mutable_data()); std::copy(indices.begin(), indices.end(), index->mutable_data()); } LoD lod; - lod.emplace_back(offsets); + lod.emplace_back(std::vector(offsets.begin(), offsets.end())); outs->set_lod(lod); index->set_lod(lod); }