fix some cases of gradient/jacobian with StaticArrays #1875
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes at least some cases of functions taking and return static arrays being returned as
Array
(and the associated allocations).An example of a case this fixes is
There were two things wrong with the
tupstack
function in currentmain
. The first is thatcat
always returns anArray
. This may be a missing method in StaticArrays, but I suspect that the reason it's missing is that it's hard to statically infer the resulting shape (and it would rely on static inference of the value ofdims
). Suffice it to say, I think it's safe to assume thatcat
can never be used with staticarrays.The second issue is that when
reshape
is used with static arrays, one must useSize
arguments to return a static array, to indicate that the size can be statically inferred.This works in the cases I have tested but looks fragile. I still need to confirm more thoroughly that this does not break any of the higher rank cases.