Skip to content
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

Convert range type in reduced_index #34770

Merged
merged 2 commits into from
Feb 21, 2020
Merged

Convert range type in reduced_index #34770

merged 2 commits into from
Feb 21, 2020

Conversation

timholy
Copy link
Sponsor Member

@timholy timholy commented Feb 15, 2020

BACKPORTING NOTE: consensus is to backport the first commit but not the second.

The reduced_indices and reduced_indices0 methods sometimes assert that the return axes type is the same as the input. Consequently, the implementation of reduced_index had better return a range of the same type as the input.

This corrects the error in JuliaArrays/OffsetArrays.jl#92. I'll put a workaround in OffsetArrays.jl too.

The second commit consistently asserts type-equality in reduced_indices. This is a bit more aggressive, and if we backport it's possible we should backport the first but not the second. The potential problem is that it makes these methods more fragile in cases where reduced_index is broken. IMO, this is a good thing because it increases the odds that errors will be caught early. Moreover, it ensures that the return type is inferrable in cases where the reduction is over the first dimension but constant-propagation fails to detect this. However, for the LTS release this should be tested for trouble.

The `reduced_indices` and `reduced_indices0` methods sometimes assert
that the return axes type is the same as the input.
Consequently, the implementation of `reduced_index` had better
return a range of the same type as the input.

This corrects the error in
JuliaArrays/OffsetArrays.jl#92.
I'll put a workaround in OffsetArrays.jl too.
This risks making these routines more fragile in cases where
`reduced_index` is broken. However, this can be viewed as a good
thing because it increases the odds that errors will be caught early.

Moreover, it ensures that the return type is inferrable in cases
where the reduction is over the first dimension but constant-propagation
fails to detect this.
@timholy
Copy link
Sponsor Member Author

timholy commented Feb 15, 2020

@nanosoldier runtests(ALL, vs=":master")

@nanosoldier
Copy link
Collaborator

Something went wrong when running your job:

SystemError("opening file \"/home/maleadt/.julia/dev/NewPkgEval/deps/Versions.toml\"", 28, nothing)

cc @maleadt

@maleadt
Copy link
Member

maleadt commented Feb 17, 2020

I think my home folder ran out of space, and then the server crashed. Let's try again:

@nanosoldier runtests(ALL, vs=":master")

@nanosoldier
Copy link
Collaborator

Your package evaluation job has completed - possible new issues were detected. A full report can be found here. cc @maleadt

@@ -20,7 +20,7 @@ reduced_indices0(a::AbstractArray, region) = reduced_indices0(axes(a), region)
function reduced_indices(inds::Indices{N}, d::Int) where N
d < 1 && throw(ArgumentError("dimension must be ≥ 1, got $d"))
if d == 1
return (reduced_index(inds[1]), tail(inds)...)
return (reduced_index(inds[1]), tail(inds)...)::typeof(inds)
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we backport this without these assertions? That is, I think this patch is good for master (and perhaps even back porting to 1.4) but I don't think we should add assertions in a back port — especially not for a backport to 1.0.

Copy link
Sponsor Member

@mbauman mbauman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve, but hesitant about backporting with the new type assertions added

@timholy
Copy link
Sponsor Member Author

timholy commented Feb 21, 2020

Agreed (I shared the same sentiment in the OP). It will be easy because the type asserts are a separate commit from the other changes.

@timholy timholy merged commit 3f0b8c9 into master Feb 21, 2020
@timholy timholy deleted the teh/oa92 branch February 21, 2020 22:05
@mbauman
Copy link
Sponsor Member

mbauman commented Feb 21, 2020

I should read better. Hah. 👍

@timholy
Copy link
Sponsor Member Author

timholy commented Feb 21, 2020

It just shows how insightful your review was 😄. Thanks for taking a look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants