-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Should StaticInt
be in Base?
#44518
Comments
Heavy use of Static.jl was cited as one of the reasons for LoopVectorization.jl's bad compile times. Given that latency is perhaps the number one problem with Julia, I do think people should be wary of investing too much in this approach, as they're likely to suffer consequences when they take it far. |
@chriselrod it's important to avoid problems like this, but this approach sounds a little like reinventing the wheel. Since it comes up so often, wouldn't it be better to have a reusable solution, so we don't have to solve each instance independently? I might well be misunderstanding, since I haven't seen details of the replacement you're working on. |
If the replacement completely removes the need to encode the size at the type level for something like |
Sorry, to be clear, it's a replacement for LoopVectorization. |
The replacement is to rewrite in c++ IIUC, right? Presumably we'd like to have whatever it is that makes C++ more amenable to this, In Julia |
If it's decided this shouldn't be in base I'm hoping to get an idea of where the rest of the community should be going with things like traits and corresponding optimizations. Compiler work is super important but I'm worried about requiring any similar additions in the future to be through the compiler. Perhaps this will change, but that sort of coding seems like it requires a lot of extra knowledge to do right. |
This is also important for things like #43642 and related compiler optimizations. @Tokazama What about named dimensions or ragged arrays? xref discussion here https://discourse.julialang.org/t/is-my-understanding-of-julia-correct/76924/33 |
I'm sure there are other collections than dense arrays that could be optimized for some operations and it would be a shame if that could only ever happen in the compiler. If we don't need to worry about static values then it would be great to have named dimensions just be a I'm not saying that using |
Agreed. I highly recommend you check out https://youtu.be/npDCCVIaSVQ to see how a from scratch re-design of array typing solves these issues. I wonder how much we can adapt from that into julia. There are also the issues of making these arrays play nicely with GPU and AD (and as a bonus, shape checking) , which Dex's type system takes into account |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Would
struct StaticInt{N::Int} <: Integer end
be a welcome addition here? Most of what it would involve is found here.It's helpful to have it specifically be a subtype of
Integer
so that it can provide optionally static ranges without the user having to worry about explicitly propagating static information from something likeSArray
or making thedim
argument of something likef(A, dim)
type stable. There are also times it can reduce the number of unique types generated for trait systems. For examplecontiguous_axis
returns aStaticInt
instead ofContiguousAxis{N}
. The benefit of having it in base would be better native support, integration, and propagation of types/traits that useStaticInt
I understand there may be some concern that this overextends the intended use of the type system, and instead the focus should be better constant propagation on the compiler side of things so that something like
SArray
doesn't need this. I'm not sure if the other use cases are also better handled by some future compiler wizardry but I thought I'd at least put it forward.@chriselrod is familiar with the
StaticInt
implementation inStatic.jl
and may have more to add to the discussion.I think @timholy at one point expressed some support for this being in base.
@Keno probably has an opinion on whether this will eventually not be useful to maintain in base given more internal development.
The text was updated successfully, but these errors were encountered: