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] Return 0-dimensional array instead of Ruby numeric object #110

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

Comments

@sonots
Copy link
Contributor

sonots commented Jul 7, 2018

This is a feedback from Cumo implementation.
https://speakerdeck.com/sonots/fast-numerical-computing-and-deep-learning-in-ruby-with-cumo?slide=42

Numo:

irb(main):015: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):016:0> a.sum
=> 66

Cumo:

irb(main):002:0> a = Cumo::Int32.new(3,4).seq
=> Cumo::Int32#shape=[3,4]
[[0, 1, 2, 3],
 [4, 5, 6, 7],
 [8, 9, 10, 11]]
irb(main):003:0> a.sum
=> Cumo::Int64#shape=[]
66

The reason why Cumo returns 0-dimensional array instead of Ruby numeric object is, to avoid cudaMemcpy from GPU to CPU for performance.

For compatibility between Numo and Cumo, I propose to change behavior of Numo to return 0-dimensional NArray directly without converting it into Ruby numeric object.

@sonots sonots changed the title Return 0-dimensional array instead of Ruby numeric object [PROPOSE} Return 0-dimensional array instead of Ruby numeric object Jul 7, 2018
@sonots sonots changed the title [PROPOSE} Return 0-dimensional array instead of Ruby numeric object [PROPOSE] Return 0-dimensional array instead of Ruby numeric object Jul 7, 2018
@sonots sonots changed the title [PROPOSE] Return 0-dimensional array instead of Ruby numeric object [Propose] Return 0-dimensional array instead of Ruby numeric object Jul 7, 2018
@giuse
Copy link

giuse commented Jul 7, 2018

I second this proposition. Had a long discussion on the mathematical reasons behind it in issue #91 (which incidentally would be solved by this).

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

2 participants