Skip to content

Commit

Permalink
Fix the bug of assigning large integer to NDArray (apache#12921)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
apeforest authored and ChaiBapchya committed Oct 30, 2018
1 parent 4e13fce commit 667a51f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/operator/tensor/matrix_op-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 11 additions & 0 deletions tests/python/unittest/test_ndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down

0 comments on commit 667a51f

Please sign in to comment.