-
Notifications
You must be signed in to change notification settings - Fork 195
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
Separate const ndarray from const data; remove view and ro. #498
Conversation
I haven't reviewed this in detail yet, but I am wondering: what's the rationale for removing |
The alternate PR addresses what I thought could be non-intuitive aspects of I was wondering whether you think that I think that I guess, philosophically, I was struggling with how to conceptualize Anyway, I'm just brainstorming because it's fun, and I'm happy to help, if I can. |
I don't see how this change improves the library.
You are also right that this is essentially an implementation of |
PS: I am open to supporting |
PR #491 fully supports views and const-correctness. This draft can be closed. I would be happy to follow up with a separate PR to support |
It's annoying to break other people's code. If possible, I would like to support |
For the sake of discussion and in the interest of design space exploration, suppose we eliminated the ndarray
view()
function. Maybe this is OK for a nano-sized binding library. Developers would have to write code like this:An advantage of the above is that it takes advantage of the known
c_contig
and ought to be even more efficient than using a view, because the viewoperator()
contains multiplications:The
fill
function above is probably not suitable for OpenMP parallelization, but that is easily fixed:Above can parallelize over slabs (the
i
index) and avoid multiplications on each node for thej
andk
loops.I guess I'm suggesting that developers write their code without
view()
and customize for their situation.The advantage to
nb::ndarray
is that we don't have to consider what happens when template arguments toview()
are examined before the template arguments tondarray
.Another thought I'd like to offer for your consideration is removing
nb::ro
and asking developers to writendarray<const void>
instead ofndarray<nb::ro>
. This eliminates having to think about the right thing to do if bothro
and a scalar element type both appear as template arguments (which can happen in different orders).