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

low precision stochastic rounding #411

Closed
madnanabid opened this issue Nov 9, 2023 · 2 comments
Closed

low precision stochastic rounding #411

madnanabid opened this issue Nov 9, 2023 · 2 comments

Comments

@madnanabid
Copy link

grid=randn(FullGaussianGrid{BFloat16sr},16)
spec = spectral(grid);
grid2 = gridded(spec);
spec2 = spectral(grid2);
grid3 = gridded(spec2);

plot(grid3)
ERROR: MethodError: no method matching trunc(::Type{Int64}, ::BFloat16sr)

Closest candidates are:
trunc(::Type{T}, ::Missing) where T
@ Base missing.jl:154
trunc(::Type{T}, ::Rational) where T
@ Base rational.jl:471
trunc(::Type{T}, ::BigFloat) where T<:Union{Signed, Unsigned}
@ Base mpfr.jl:327

@milankl
Copy link
Member

milankl commented Nov 9, 2023

Sorry, this is an error for StochasticRounding.jl, this has nothing to do with SpeedyWeather.jl.

You can fix it locally though simply by defining it

Base.trunc(::Type{T},x::BFloat16sr) where {T<:Integer} = trunc(T,BFloat16(x))

@milankl milankl closed this as completed Nov 9, 2023
@milankl
Copy link
Member

milankl commented Nov 9, 2023

Also we already have that issue open milankl/StochasticRounding.jl#72

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