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

rational quadratic flows not supporting Float32 input #266

Closed
zuhengxu opened this issue Jun 8, 2023 · 1 comment
Closed

rational quadratic flows not supporting Float32 input #266

zuhengxu opened this issue Jun 8, 2023 · 1 comment

Comments

@zuhengxu
Copy link
Member

zuhengxu commented Jun 8, 2023

Here is a minimal working example:

using Bijectors

K = 10; B = 2
Bijectors.RationalQuadraticSpline(randn(Float32,K), randn(Float32, K), randn(Float32, K-1), B)

which gives the error:

ERROR: MethodError: no method matching Bijectors.RationalQuadraticSpline(::Vector{Float64}, ::Vector{Float64}, ::Vector{Float32})

Closest candidates are:
  Bijectors.RationalQuadraticSpline(::T, ::T, ::T) where T<:(AbstractVector)
   @ Bijectors ~/.julia/packages/Bijectors/Fp0rB/src/bijectors/rational_quadratic_spline.jl:80
  Bijectors.RationalQuadraticSpline(::A, ::A, ::A, ::T2) where {T1, T2, A<:AbstractVector{T1}}
   @ Bijectors ~/.julia/packages/Bijectors/Fp0rB/src/bijectors/rational_quadratic_spline.jl:103

Stacktrace:
 [1] Bijectors.RationalQuadraticSpline(widths::Vector{Float32}, heights::Vector{Float32}, derivatives::Vector{Float32}, B::Int64)
   @ Bijectors ~/.julia/packages/Bijectors/Fp0rB/src/bijectors/rational_quadratic_spline.jl:109
 [2] top-level scope
   @ ~/Research/NF-playground/NF-examples/neural_spline_flow/nsf_layer.jl:55

This is because https://github.com/TuringLang/Bijectors.jl/blob/dd8a24b02feccc8f1bef180e7419fb03a61ba82f/src/bijectors/rational_quadratic_spline.jl#LL99C1-L107C4 (line 103--104) is not type stable--- .- 0.5 returns Float64 instead Float32, while line 105 maintains Float32. This is probablematic because the three fields of RationalQuadraticSpline{T} has to be the same type.

Same issue applies to https://github.com/TuringLang/Bijectors.jl/blob/dd8a24b02feccc8f1bef180e7419fb03a61ba82f/src/bijectors/rational_quadratic_spline.jl#LL109C1-L123C4

@torfjelde
Copy link
Member

Solved by #267

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