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

scatter and gather support element type of idx to be CartesianIndex #308

Merged
merged 9 commits into from
Apr 21, 2021

Conversation

yuehhua
Copy link
Member

@yuehhua yuehhua commented Apr 7, 2021

No description provided.

src/gather.jl Outdated Show resolved Hide resolved
src/gather.jl Outdated Show resolved Hide resolved
@DhairyaLGandhi
Copy link
Member

One complaint that would be good to address is that NNlib should not be exporting gather and scatter. They are pretty generic names which may mean different things in different contexts. scatter for plotting - for ex

@CarloLucibello
Copy link
Member

CarloLucibello commented Apr 8, 2021

unexporting gather and scatter is a breaking change, if we go with that the change should be done in another PR and the release marked as breaking

@yuehhua
Copy link
Member Author

yuehhua commented Apr 8, 2021

However, scatter and gather are both essential low-level operations in computer science. These two operations here are to mimic the behavior of gather-scatter.
It is essential that convolution and inner product is to CNN what scatter and gather is to GNN.

@DhairyaLGandhi
Copy link
Member

Exporting them is a bug, which should come under semver. It isn't changing the behaviour of the functions itself.

@ChrisRackauckas
Copy link
Member

The fact that it interferes with Plots.jl means that many online tutorials of Flux are broken by exporting it (at least, if they use scatter plots). That's pretty breaking. That at least deserves a major release, a blog post, and a bunch of downstream issues / comments around blogs to help people get updated. The exporting of such a common term with known breakage against libraries that are commonly used with Flux is such a huge breaking change that I am kind of shocked it went through without more consideration.

@CarloLucibello
Copy link
Member

ok, I'm filing a PR removing the exports and tagging a patch release

@DhairyaLGandhi
Copy link
Member

Ref the offending PR #255

@yuehhua
Copy link
Member Author

yuehhua commented Apr 15, 2021

@DhairyaLGandhi @CarloLucibello Is this ready to go?

src/scatter.jl Outdated Show resolved Hide resolved
src/scatter.jl Outdated Show resolved Hide resolved
src/gather.jl Outdated Show resolved Hide resolved
@CarloLucibello
Copy link
Member

besides the slight simplification I suggested this seems ready to go

@CarloLucibello
Copy link
Member

Almost there, could add at least one test

@DhairyaLGandhi
Copy link
Member

Seems like we can get rid of _view?

@yuehhua
Copy link
Member Author

yuehhua commented Apr 15, 2021

I noticed that I forgot to support gather and I add support for that.

return dims
end

typelength(::Type{<:Number}) = 1
typelength(::Type{<:NTuple{M}}) where M = M
function _check_dims(X::AbstractArray{Tx,Nx},
Copy link
Member

Choose a reason for hiding this comment

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

Seems like we can unify the two methods with just converting the Cartesian indices once?

Copy link
Member

Choose a reason for hiding this comment

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

these are very low-level methods, we should not do any allocation

@CarloLucibello CarloLucibello merged commit b1633f5 into FluxML:master Apr 21, 2021
@yuehhua yuehhua deleted the cartesian branch April 21, 2021 15:34
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.

4 participants