-
Notifications
You must be signed in to change notification settings - Fork 41
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
Base.sizeof does not support non byte-aligned type sizes #492
Comments
Please post issues with information beyond a link. The issue seems to be "sizeof(i1)"? @wsmoses do you want 0 or 1 for the sizeof a thing that is less than a byte? |
Julia's |
Sorry, here is an MWE with Enzyme v0.13.19: julia> import Enzyme
julia> sumdiff(x) = sum(diff(x));
julia> x, dx = float.(1:5), float.(6:10);
julia> Enzyme.hvp(sum, x, dx) # works
5-element Vector{Float64}:
0.0
0.0
0.0
0.0
0.0
julia> Enzyme.hvp(sumdiff, x, dx) # fails
ERROR: InexactError: Int64(0.125)
Stacktrace:
[1] Int64
@ ./float.jl:994 [inlined]
[2] sizeof
@ ~/.julia/packages/LLVM/wMjUU/src/datalayout.jl:91 [inlined]
[3] should_recurse(typ2::Any, arg_t::LLVM.LLVMType, byref::GPUCompiler.ArgumentCC, dl::LLVM.DataLayout)
@ Enzyme.Compiler ~/.julia/packages/Enzyme/ottqJ/src/absint.jl:208
[4] abs_typeof(arg::LLVM.Value, partial::Bool, seenphis::Set{LLVM.PHIInst})
@ Enzyme.Compiler ~/.julia/packages/Enzyme/ottqJ/src/absint.jl:601
[5] abs_typeof(arg::LLVM.Value, partial::Bool, seenphis::Set{LLVM.PHIInst})
@ Enzyme.Compiler ~/.julia/packages/Enzyme/ottqJ/src/absint.jl:710
[6] abs_typeof
@ ~/.julia/packages/Enzyme/ottqJ/src/absint.jl:283 [inlined]
[7] codegen(output::Symbol, job::GPUCompiler.CompilerJob{…}; libraries::Bool, deferred_codegen::Bool, optimize::Bool, toplevel::Bool, strip::Bool, validate::Bool, only_entry::Bool, parent_job::Nothing)
@ Enzyme.Compiler ~/.julia/packages/Enzyme/ottqJ/src/compiler.jl:4255
[8] codegen
@ ~/.julia/packages/Enzyme/ottqJ/src/compiler.jl:3218 [inlined]
[9] _thunk(job::GPUCompiler.CompilerJob{Enzyme.Compiler.EnzymeTarget, Enzyme.Compiler.EnzymeCompilerParams}, postopt::Bool)
@ Enzyme.Compiler ~/.julia/packages/Enzyme/ottqJ/src/compiler.jl:5265
[10] cached_compilation(job::GPUCompiler.CompilerJob)
@ Enzyme.Compiler ~/.julia/packages/Enzyme/ottqJ/src/compiler.jl:5306
[11] thunkbase(mi::Core.MethodInstance, World::UInt64, FA::Type{…}, A::Type{…}, TT::Type, Mode::Enzyme.API.CDerivativeMode, width::Int64, ModifiedBetween::NTuple{…} where N, ReturnPrimal::Bool, ShadowInit::Bool, ABI::Type, ErrIfFuncWritten::Bool, RuntimeActivity::Bool)
@ Enzyme.Compiler ~/.julia/packages/Enzyme/ottqJ/src/compiler.jl:5410
[12] thunk_generator(world::UInt64, source::LineNumberNode, FA::Type, A::Type, TT::Type, Mode::Enzyme.API.CDerivativeMode, Width::Int64, ModifiedBetween::NTuple{…} where N, ReturnPrimal::Bool, ShadowInit::Bool, ABI::Type, ErrIfFuncWritten::Bool, RuntimeActivity::Bool, self::Any, fakeworld::Any, fa::Type, a::Type, tt::Type, mode::Type, width::Type, modifiedbetween::Type, returnprimal::Type, shadowinit::Type, abi::Type, erriffuncwritten::Type, runtimeactivity::Type)
@ Enzyme.Compiler ~/.julia/packages/Enzyme/ottqJ/src/compiler.jl:5562
[13] autodiff
@ ~/.julia/packages/Enzyme/ottqJ/src/Enzyme.jl:640 [inlined]
[14] autodiff
@ ~/.julia/packages/Enzyme/ottqJ/src/Enzyme.jl:544 [inlined]
[15] autodiff
@ ~/.julia/packages/Enzyme/ottqJ/src/Enzyme.jl:516 [inlined]
[16] hvp!
@ ~/.julia/packages/Enzyme/ottqJ/src/sugar.jl:1105 [inlined]
[17] hvp(f::typeof(sumdiff), x::Vector{Float64}, v::Vector{Float64})
@ Enzyme ~/.julia/packages/Enzyme/ottqJ/src/sugar.jl:1072
[18] top-level scope
@ ~/Work/GitHub/Julia/DifferentiationInterface.jl/DifferentiationInterface/test/playground.jl:7
Some type information was truncated. Use `show(err)` to see complete types. |
@maleadt we can potentially round up to the nearest byte? |
That seems questionable. We already have a bunch of code that does things like:
Simply returning a Float doesn't help either, because the above would result in |
I think a good solution might be a kwargument to optionally round up |
Hi there! Sorry that I don't have a pure LLVM MWE but Billy told me to open an issue here for this bug I found with Enzyme:
sizeof
when differentiatingBase.diff
EnzymeAD/Enzyme.jl#2168Is it the right place to fix this?
The text was updated successfully, but these errors were encountered: