-
-
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
WIP: redesign of cat #10155
WIP: redesign of cat #10155
Conversation
catndims(x::AbstractArray) = ndims(x) | ||
catndims(x) = 1 | ||
|
||
cat_similar(x::AbstractArray, T, sz) = similar(full(x), T, sz) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I follow this, so take these with a big grain of salt:
- Do we really want to require
full
to be implemented for allAbstractArray
s (or is this used in special circumstances?) - It would be lovely if this didn't require actual intantiation of
full(x)
, since in the end it's presumably about types and sizes. OTOH, since we don't havefull_type(x), full_size(x)
maybe there isn't a good alternative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, this behaviour was taken over from the old code. I think the full should be omitted. There was a discussion recently that similar itself should take care of returning an array of a suitable type, i.e. one that has setindex!
I've never dived into the |
02cb581
to
098ace6
Compare
I am able to reproduce the error in |
Some further update on trying to understand why this doesn't pass the test. Base.runtests(["copy","parallel"]) with the following error
While I am currently not able to find the best way to reproduce the following, I was able to run the code around line 62 of dims = (20,20,20)
d = drandn(dims);
da = convert(Array, d);
dms=1
mapreducedim(t -> t*t, +, d, dms) which then led to an error in one of the workers of the form Unfortunately, I have no clue how the current cat redesign triggers this behavior in this delicate way. |
79f48c6
to
dbbccfa
Compare
dbbccfa
to
0e65e4f
Compare
Finally got this to works thanks to convertalypse being solved. However, I am going to close this in favor of a new PR that explains the latest status. |
This PR contains a complete redesign of
(h)(v)cat
, partially to make them more efficient, partially to make the code more consistent. Thetest/perf/cat/perf.jl
results give this on master:and this with the new design
The current design is more modular and doesn't require treading special cases separately; it's all handled via multiple dispatch. I need to implement some more performance test (e.g. for catting just numbers), but from the above it's clear that (for those tests)
vcat
andcat
are much faster.hvcat
is slightly faster.hcat
seems to be a tad slower for thesmall
case but not for thelarge
case. The currenthcat
code contains some fairly specific instructions for this.I have also reverted the generalized
cat
behavior for diagonal catting, but reinstated it under the namedcat
, once suggested by @jiahao . This automatically provides a generalblkdiag
implementation.I still need to add documentation.