Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

fix #18927 #18972

Merged
merged 2 commits into from
Aug 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/operator/contrib/bounding_box-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,11 @@ void BipartiteMatchingForward(const nnvm::NodeAttrs& attrs,
const BipartiteMatchingParam& param = nnvm::get<BipartiteMatchingParam>(attrs.parsed);
Stream<xpu> *s = ctx.get_stream<xpu>();
mxnet::TShape dshape = inputs[0].shape_;
CHECK(mxnet::shape_is_known(dshape)) << "Found unknown shape in BipartiteMatchingForward, "
<< "received: " << dshape;
if (dshape.Size() == 0) {
return; // noop for unknown shape or empty array
}
int row = dshape[dshape.ndim() - 2];
int col = dshape[dshape.ndim() - 1];
int batch_size = dshape.Size() / row / col;
Expand Down
5 changes: 5 additions & 0 deletions src/operator/contrib/bounding_box.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ DMLC_REGISTER_PARAMETER(BoxDecodeParam);

NNVM_REGISTER_OP(_contrib_box_nms)
.add_alias("_contrib_box_non_maximum_suppression")
.add_alias("_npx_box_nms")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi @zhreshold I added these ops to npx

.describe(R"code(Apply non-maximum suppression to input.

The output will be sorted in descending order according to `score`. Boxes with
Expand Down Expand Up @@ -118,6 +119,7 @@ NNVM_REGISTER_OP(_backward_contrib_box_nms)
.add_arguments(BoxNMSParam::__FIELDS__());

NNVM_REGISTER_OP(_contrib_box_iou)
.add_alias("_npx_box_iou")
.describe(R"doc(Bounding box overlap of two arrays.
The overlap is defined as Intersection-over-Union, aka, IOU.
- lhs: (a_1, a_2, ..., a_n, 4) array
Expand Down Expand Up @@ -159,6 +161,7 @@ NNVM_REGISTER_OP(_backward_contrib_box_iou)
.add_arguments(BoxOverlapParam::__FIELDS__());

NNVM_REGISTER_OP(_contrib_bipartite_matching)
.add_alias("_npx_bipartite_matching")
.describe(R"doc(Compute bipartite matching.
The matching is performed on score matrix with shape [B, N, M]
- B: batch_size
Expand Down Expand Up @@ -206,6 +209,7 @@ NNVM_REGISTER_OP(_backward_contrib_bipartite_matching)
.add_arguments(BipartiteMatchingParam::__FIELDS__());

NNVM_REGISTER_OP(_contrib_box_encode)
.add_alias("_npx_box_encode")
.describe(R"doc(Encode bounding boxes training target with normalized center offsets.
Input bounding boxes are using corner type: `x_{min}, y_{min}, x_{max}, y_{max}`.) array
)doc" ADD_FILELINE)
Expand All @@ -228,6 +232,7 @@ NNVM_REGISTER_OP(_contrib_box_encode)
.add_argument("stds", "NDArray-or-Symbol", "(4,) Std value to be divided from encoded values");

NNVM_REGISTER_OP(_contrib_box_decode)
.add_alias("_npx_box_decode")
.describe(R"doc(Decode bounding boxes training target with normalized center offsets.
Input bounding boxes are using corner type: `x_{min}, y_{min}, x_{max}, y_{max}`
or center type: `x, y, width, height.) array
Expand Down
25 changes: 25 additions & 0 deletions tests/python/unittest/test_smoke.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

from mxnet import np, npx, use_np
from common import setup_module, teardown_module

@use_np
def test_18927():
"""test for no error when dealing with zero-size array in bipartite matching"""
arr = np.random.rand(0,2)
npx.bipartite_matching(arr, threshold=0.1)