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

Apply isapprox elementwise #185

Merged
merged 3 commits into from
Jan 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions configs/configs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,26 @@ end

# Verify results.
function verify(cf::Configuration, c_ref, d)
cf.verify(c_ref, d)
cf.verify(c_ref, d, cf.a_type)
end

function verify_default(c_ref, d)
isapprox(c_ref, d)
compare(x, y, T) = error("Unimplemented compare(x, y, T) function for type $T")
compare(x, y, T::Type{<:AbstractFloat}) = isapprox(x, y; rtol=sqrt(eps(T)))
compare(x, y, T::Type{<:Integer}) = (x == y)
compare(x, y, T::Type{Complex{U}}) where {U} = compare(x, y, U)

function verify_default(c_ref, d, T)
all(compare.(c_ref, d, T))
end

function verify_bias(c_ref, d, bias)
c_ref .+ bias ≈ d
function verify_bias(c_ref, d, bias, T)
all(compare.(c_ref .+ bias, d, T))
end

function verify_dual(c_ref, d)
function verify_dual(c_ref, d, T)
c_dual = reinterpret(ForwardDiff.Dual{Float32,Float32,1}, c_ref)
d_dual = reinterpret(ForwardDiff.Dual{Float32,Float32,1}, d)
isapprox(c_dual, d_dual)
all(compare.(c_dual, d_dual, T))
end

function fpu_baseline(a, b, c, d, alpha, beta, transpose_a, transpose_b)
Expand Down Expand Up @@ -282,7 +287,7 @@ macro get_wmma_bias_config()
transpose_b,
mul!,
Epilogue.Bias(pointer(bias)),
(c_h, d) -> verify_bias(c_h, d, bias),
(c_h, d, T) -> verify_bias(c_h, d, bias, T),
Kernel.matmul_pipelined,
nothing)
end end)
Expand Down