Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Propose] Stop making a view of NArray at #aref (or Stop using idx) #108

Open
sonots opened this issue Jul 7, 2018 · 1 comment
Open

Comments

@sonots
Copy link
Contributor

sonots commented Jul 7, 2018

In Numo, advanced indexing returns a view of a Numo NArray.

irb(main):007:0> a = Numo::Int32.new(3,4).seq
=> Numo::Int32#shape=[3,4]
[[0, 1, 2, 3],
 [4, 5, 6, 7],
 [8, 9, 10, 11]]
irb(main):012:0> a[a > 5]
=> Numo::Int32(view)#shape=[6]
[6, 7, 8, 9, 10, 11]

In Numpy, advanced indexing returns a new ndarray.

>>> a = numpy.arange(12).reshape(3,4)
>>> b = a[a > 5]
>>> b
array([ 6,  7,  8,  9, 10, 11])
>>> a
array([[ 0,  1,  2,  3],
       [ 4,  5,  6,  7],
       [ 8,  9, 10, 11]])
>>> b[0] = 1
>>> b
array([ 1,  7,  8,  9, 10, 11])
>>> a
array([[ 0,  1,  2,  3],
       [ 4,  5,  6,  7],
       [ 8,  9, 10, 11]])

I propose Numo to work similarly with NumPy.

By stopping to make a view of NArray at #[], we can remove NDF_INDEX_LOOP, or all of codes using idx internally, and results in making very simple implementation.


This is a kind of feedback from Cumo.
In Cumo, idx C array must be transferred from CPU to GPU when we want to use it in CUDA Kernel.
Also, we have to copy back from GPU to CPU when we want to use it in CPU side.

It made implementation of Cumo very complex. I want to stop using idx.

@sonots sonots changed the title Stop making a view of NArray at #aref (or Stop using idx) [Propose] Stop making a view of NArray at #aref (or Stop using idx) Jul 7, 2018
@sonots
Copy link
Contributor Author

sonots commented Jul 7, 2018

I talked with @masa16, and we agreed that making the behavior same with NumPy ndarray.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant