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

Use Static.jl to implement elements of Ones and Zeros? #176

Closed
oschulz opened this issue Apr 6, 2022 · 5 comments
Closed

Use Static.jl to implement elements of Ones and Zeros? #176

oschulz opened this issue Apr 6, 2022 · 5 comments

Comments

@oschulz
Copy link

oschulz commented Apr 6, 2022

Currently, we have

Ones(5)[1] isa Float64

Using Static.jl, the elements of Ones could be static(1) or static(1.0), which would propagate the fact that the number is static deeper into calculations and could enable better compiler optimizations.

Static.jl is a comparatively lightweight dependency on top of FillArrays, load-time impact would probably be minor:

julia> @time using FillArrays
  0.398913 seconds (764.83 k allocations: 46.937 MiB, 72.11% compilation time)

julia> @time using Static
  0.062017 seconds (93.65 k allocations: 5.420 MiB)
@dlfivefifty
Copy link
Member

Can't you just use Fill(static(1),n) for this?

@oschulz
Copy link
Author

oschulz commented Apr 6, 2022

Can't you just use Fill(static(1),n) for this?

I typically will. But Fill often get's lost e.g. by vcat (which I'll have to use a lot):

julia> vcat(Fill(static(1), 5), Fill(static(1), 5))
10-element Vector{StaticInt{1}}:

Speaking of which, explicit support for Static.jl would allow us to specialize things like vcat to return a Fill.

@dlfivefifty
Copy link
Member

I just think Ones{T} is a very different thing than what you want.

@dlfivefifty
Copy link
Member

Note this issue is basically the same as #104 so I'm closing this

@oschulz
Copy link
Author

oschulz commented Apr 6, 2022

I just think Ones{T} is a very different thing than what you want.

You were right, I want Ones{StaticInt} and Ones{StaticFloat64}, not Ones{Int} and Ones{Float64} - sorry for the misunderstanding.

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

No branches or pull requests

2 participants