Skip to content

Incosistent index OOB slice behaviour between 1-D and N-D NDArrays. #55

@tjad

Description

@tjad

When slicing out of bounds of 1-D NDArray, an exception occurs correctly.

require 'mxnet'

a = MXNet::NDArray.ones([5])
a[0..7]

git/mxnet.rb/lib/mxnet/ndarray.rb:121:in '_slice' MXNet::Error (MXNetError: Check failed: shape_[0] >= end (5 vs. 8) : Slice end index out of range)

When slicing out of bounds of N-D NDArray, the OOB is ignored and as much as possible of the slice is returned.

require 'mxnet'

a = MXNet::NDArray.ones([5,5])
a[0, 0..7]

[1, 1, 1, 1, 1] <MXNet::NDArray 5 @cpu(0)>

require 'mxnet'

a = MXNet::NDArray.ones([5,5])
a[0..7, 2]

[1, 1, 1, 1, 1] <MXNet::NDArray 5 @cpu(0)>

Consistent error behaviour is expected between these methods.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions