You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by zh...@apache.org on 2018/07/03 00:29:01 UTC
[incubator-mxnet] branch master updated: Fix Flaky test
test_multi_proposal_op as in #10186 (#11530)
This is an automated email from the ASF dual-hosted git repository.
zhasheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git
The following commit(s) were added to refs/heads/master by this push:
new 34fafb4 Fix Flaky test test_multi_proposal_op as in #10186 (#11530)
34fafb4 is described below
commit 34fafb441b05811a7ea1c18369a13042e2dba2f2
Author: Joshua Z. Zhang <ch...@gmail.com>
AuthorDate: Mon Jul 2 17:28:52 2018 -0700
Fix Flaky test test_multi_proposal_op as in #10186 (#11530)
* use stable_sort to make it consistent between cpu/gpu
* fix testing logic
* fix
* remove comments
---
src/operator/contrib/multi_proposal.cc | 2 +-
src/operator/contrib/proposal.cc | 2 +-
tests/python/gpu/test_operator_gpu.py | 21 +++++++++++++--------
3 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/src/operator/contrib/multi_proposal.cc b/src/operator/contrib/multi_proposal.cc
index 3793f27..3f5796e 100644
--- a/src/operator/contrib/multi_proposal.cc
+++ b/src/operator/contrib/multi_proposal.cc
@@ -197,7 +197,7 @@ inline void CopyScore(const mshadow::Tensor<cpu, 2>& dets,
inline void ReverseArgsort(const mshadow::Tensor<cpu, 1>& score,
mshadow::Tensor<cpu, 1> *order) {
ReverseArgsortCompl cmpl(score.dptr_);
- std::sort(order->dptr_, order->dptr_ + score.size(0), cmpl);
+ std::stable_sort(order->dptr_, order->dptr_ + score.size(0), cmpl);
}
// reorder proposals according to order and keep the pre_nms_top_n proposals
diff --git a/src/operator/contrib/proposal.cc b/src/operator/contrib/proposal.cc
index c582fb0..fa713bb 100644
--- a/src/operator/contrib/proposal.cc
+++ b/src/operator/contrib/proposal.cc
@@ -192,7 +192,7 @@ inline void CopyScore(const mshadow::Tensor<cpu, 2>& dets,
inline void ReverseArgsort(const mshadow::Tensor<cpu, 1>& score,
mshadow::Tensor<cpu, 1> *order) {
ReverseArgsortCompl cmpl(score.dptr_);
- std::sort(order->dptr_, order->dptr_ + score.size(0), cmpl);
+ std::stable_sort(order->dptr_, order->dptr_ + score.size(0), cmpl);
}
// reorder proposals according to order and keep the pre_nms_top_n proposals
diff --git a/tests/python/gpu/test_operator_gpu.py b/tests/python/gpu/test_operator_gpu.py
index 736a9ee..5622bee 100644
--- a/tests/python/gpu/test_operator_gpu.py
+++ b/tests/python/gpu/test_operator_gpu.py
@@ -1728,7 +1728,6 @@ def test_cross_device_autograd():
assert_almost_equal(dx, x.grad.asnumpy())
-@unittest.skip("JIRA issue: https://issues.apache.org/jira/projects/MXNET/issues/MXNET-130")
@with_seed()
def test_multi_proposal_op():
# paramters
@@ -1737,7 +1736,6 @@ def test_multi_proposal_op():
ratios = (0.5, 1, 2)
rpn_pre_nms_top_n = 12000
rpn_post_nms_top_n = 2000
- threshold = 0.7
rpn_min_size = feature_stride
feat_len = (1000 + 15) // 16
@@ -1768,7 +1766,7 @@ def test_multi_proposal_op():
im_info[i, :] = [im_size[0], im_size[1], im_scale]
return cls_prob, bbox_pred, im_info
- def check_proposal_consistency(op, batch_size):
+ def check_proposal_consistency(op, batch_size, with_nms=False):
'''
op is mx.nd.contrib.Proposal or mx.nd.contrib.MultiProposal
'''
@@ -1782,7 +1780,7 @@ def test_multi_proposal_op():
ratios = ratios,
rpn_pre_nms_top_n = rpn_pre_nms_top_n,
rpn_post_nms_top_n = rpn_post_nms_top_n,
- threshold = threshold,
+ threshold = 0.7 if with_nms else 1.0,
rpn_min_size = rpn_min_size, output_score = True)
gpu_ctx = mx.gpu(0)
@@ -1801,7 +1799,7 @@ def test_multi_proposal_op():
ratios = ratios,
rpn_pre_nms_top_n = rpn_pre_nms_top_n,
rpn_post_nms_top_n = rpn_post_nms_top_n,
- threshold = threshold,
+ threshold = 0.7 if with_nms else 1.0,
rpn_min_size = rpn_min_size, output_score = True)
rois_cpu_np = rois_cpu.asnumpy()
@@ -1810,11 +1808,18 @@ def test_multi_proposal_op():
score_cpu_np = score_cpu.asnumpy()
score_gpu_np = score_gpu.asnumpy()
- assert_almost_equal(score_cpu_np, score_gpu_np, atol = 1e-3, rtol = 1e-3)
- assert_almost_equal(rois_cpu_np, rois_gpu_np, atol = 1e-3, rtol = 1e-3)
+ if not with_nms:
+ assert_almost_equal(score_cpu_np, score_gpu_np, atol = 1e-3, rtol = 1e-3)
+ assert_almost_equal(rois_cpu_np, rois_gpu_np, atol = 1e-3, rtol = 1e-3)
+ else:
+ # no 100% gurantee with nms
+ assert(np.sum(np.abs(score_cpu_np - score_gpu_np) < 1e-3) >= 10)
+ assert(np.sum(np.abs(rois_cpu_np - rois_gpu_np) < 1e-3) >= 40)
check_proposal_consistency(mx.nd.contrib.Proposal, 1)
- check_proposal_consistency(mx.nd.contrib.MultiProposal, 20)
+ check_proposal_consistency(mx.nd.contrib.MultiProposal, 5)
+ check_proposal_consistency(mx.nd.contrib.Proposal, 1, with_nms=True)
+ check_proposal_consistency(mx.nd.contrib.MultiProposal, 5, with_nms=True)
# The following 2 functions launch 0-thread kernels, an error that should be caught and signaled.