You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by ha...@apache.org on 2018/10/25 22:14:55 UTC
[incubator-mxnet] branch master updated: Fix the bug of assigning
large integer to NDArray (#12921)
This is an automated email from the ASF dual-hosted git repository.
haibin 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 ffe551e Fix the bug of assigning large integer to NDArray (#12921)
ffe551e is described below
commit ffe551e7c3ad3accbac1d78b53990a544e1331de
Author: Lin Yuan <ap...@gmail.com>
AuthorDate: Thu Oct 25 15:14:42 2018 -0700
Fix the bug of assigning large integer to NDArray (#12921)
* remove num_labels check in multibox_target
* add unit test
* test both cpu and gpu
* add contrib operator to GPU unit test
* do not test all contrib operator in gpu
* Fix the large int assign problem
---
src/operator/tensor/matrix_op-inl.h | 2 +-
tests/python/unittest/test_ndarray.py | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/operator/tensor/matrix_op-inl.h b/src/operator/tensor/matrix_op-inl.h
index bfee083..e375d64 100644
--- a/src/operator/tensor/matrix_op-inl.h
+++ b/src/operator/tensor/matrix_op-inl.h
@@ -992,7 +992,7 @@ void SliceAssignOpForward(const nnvm::NodeAttrs& attrs,
}
struct SliceAssignScalarParam : public dmlc::Parameter<SliceAssignScalarParam> {
- real_t scalar;
+ double scalar;
nnvm::Tuple<dmlc::optional<int>> begin, end;
nnvm::Tuple<dmlc::optional<int>> step;
DMLC_DECLARE_PARAMETER(SliceAssignScalarParam) {
diff --git a/tests/python/unittest/test_ndarray.py b/tests/python/unittest/test_ndarray.py
index 0044ae3..128dfa6 100644
--- a/tests/python/unittest/test_ndarray.py
+++ b/tests/python/unittest/test_ndarray.py
@@ -1355,6 +1355,17 @@ def test_assign_float_value_to_ndarray():
b[0] = a[0]
assert same(a, b.asnumpy())
+def test_assign_large_int_to_ndarray():
+ """Test case from https://github.com/apache/incubator-mxnet/issues/11639"""
+ a = mx.nd.zeros((4, 1), dtype=np.int32)
+ a[1,0] = int(16800001)
+ a[2,0] = int(16800002)
+ b = a.asnumpy()
+ assert same(b[1,0], 16800001)
+ a = a-1
+ b = a.asnumpy()
+ assert same(b[1,0], 16800000)
+
@with_seed()
def test_assign_a_row_to_ndarray():
"""Test case from https://github.com/apache/incubator-mxnet/issues/9976"""