-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Improve docs for vcat
, cat
, etc.
#46429
Conversation
Before we canonize #43334 applies in a narrow subset of cases. #46003 would apply in some others. But really, we still lack a generic function for concatenation of iterables. |
These specialisations probably cannot be removed, so at least they should be clearly documented, including the precise signature which triggers them. If I'm not mistaken you have to look at I agree they are hard to discover, and fragile. Similar code could certainly be written for an efficient eager Many other rules are possible. If I understand right, #46003 proposes a rule with a julia> A = [rand(2,3) for _ in 1:4, _ in 1:5];
julia> awfulstack(A) == hvcat(5, permutedims(A)...)
true
julia> using TensorCast
julia> awfulstack(A) == @cast out[(i,I), (j,J)] := A[I,J][i,j]
true
julia> stack(A) == @cast out[i,j,I,J] := A[I,J][i,j]
true
julia> awfulstack(A) == @cast out[(i,I), (j,J)] := stack(A)[i,j,I,J]
true On a uniform-size array of arrays like |
Technically, removing these performance shortcuts would be non-breaking since the fallback is still operable. That said, reversion to the fallback would impact performance very negatively and for that reason I imagine we'd keep them for a long time anyway. I expect that, if we do ever manage a more generic function, these specialization could still exist (for legacy reasons) although be replaced by forwarding to that function. So, with that in mind and with the lack of an in-progress PR to create the aforementioned generalization, I'll retract my reservations about documenting them. |
Besides performance there are quirks like this which would probably break things:
Perhaps we could make |
Bump... pinging @ViralBShah as he liked it in August? |
Thanks. I will come around to this soon. In general, I feel anything that is an improvement and is correct in a docs PR should be merged. |
This wants to:
reduce(vcat, A)
underreduce
and undervcat
, and state exactly what types they accept. As far as I know this was documented nowhere besidesmethods(reduce)
.stack
from #43334 as an alternative where appropriate, including undereachslice
andmapslices
.vcat
,hcat
. They are about the same length, but try not to print out things likeb = [6 7; 8 9; 10 11; 12 13; 14 15]
too often, instead illustrating more uses, from simple to complex.cat(A...; dims)
, and avoid saying the word "stacked" there.