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

Fix the bug of assigning large integer to NDArray #12921

Merged
merged 9 commits into from
Oct 25, 2018
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