Open ranocha opened 3 years ago
It does seem to be wrong. We probably need to have more robust support for ReshapedArrays overall in "stridelayout.jl"
I will give it a shot.
I don't think we can actually guarantee that a ReshapedArray
can combine with its parent strides unless we know that the the reshaped dimensions are contiguous and dense, because otherwise we would need to split strides. For example:
x = Array{Int}(undef, 5, 2, 5, 2);
xv = view(x, :, 1, :, :);
xvr = reshape(xv, 10, 5)
If reshaping was done with static information we could figure this out at compile time, but with the current design of ReshapedArray
we would have to compute all the parent strides and then see if one of the new dimensions is large enough to split parent strides.
These seem to be wrong, I think. Because of
ArrayInterface.strides(u_view) == (10,)
, thestrides
should beArrayInterface.strides(u_reshaped_view1) = (10 #= doesn't matter since there is only one element in this dimension =#, 10)
ArrayInterface.strides(u_reshaped_view1) = (10, 20)
Is that correct?