Enzyme
Enzyme copied to clipboard
Failure in compilation
I am trying to apply Enzyme on a program, but there are 2 functions that can not be differentiated( can not compile). Could you please give some help? Thank you very much! input.zip
Even though you named them *.ll, they are rather bitcode files (.bc). I don't have an llvm-13.0.1 disassembler at hand rn. If you could provide the Enzyme error message I could have a quick look.
could not deduce type of integer %13 = bitcast double* %12 to i8*, !dbg !302 num:2400 q:{[]:Pointer}
warning: ssor.c:61:5: failed to deduce type of value %13 = bitcast double* %12 to i8*, !dbg !302
opt: /workspace/Enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:5110: ConcreteType TypeResults::firstPointer(size_t, llvm::Value*, bool, bool) const: Assertion `0 && "could not deduce type of integer"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0. Program arguments: opt input.ll -load=/workspace/Enzyme/enzyme/build/Enzyme/LLVMEnzyme-13.so -enzyme -o output.ll -S -enable-new-pm=0
1. Running pass 'Enzyme Pass' on module 'input.ll'.
#0 0x00007f690fe58791 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib/x86_64-linux-gnu/libLLVM-13.so.1+0xd95791)
#1 0x00007f690fe56940 llvm::sys::RunSignalHandlers() (/lib/x86_64-linux-gnu/libLLVM-13.so.1+0xd93940)
#2 0x00007f690fe58c92 (/lib/x86_64-linux-gnu/libLLVM-13.so.1+0xd95c92)
#3 0x00007f690f0b53c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
#4 0x00007f690eba818b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4618b)
#5 0x00007f690eb87859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x25859)
#6 0x00007f690eb87729 (/lib/x86_64-linux-gnu/libc.so.6+0x25729)
#7 0x00007f690eb98f36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
#8 0x00007f690c9881f7 TypeResults::firstPointer(unsigned long, llvm::Value*, bool, bool) const (/workspace/Enzyme/enzyme/build/Enzyme/LLVMEnzyme-13.so+0x9be1f7)
#9 0x00007f690c81607d AdjointGenerator<AugmentedReturn const*>::visitMemSetCommon(llvm::CallInst&) (/workspace/Enzyme/enzyme/build/Enzyme/LLVMEnzyme-13.so+0x84c07d)
#10 0x00007f690c7eefe9 AdjointGenerator<AugmentedReturn const*>::visitMemSetInst(llvm::MemSetInst&) (/workspace/Enzyme/enzyme/build/Enzyme/LLVMEnzyme-13.so+0x824fe9)
#11 0x00007f690c77244d llvm::InstVisitor<AdjointGenerator<AugmentedReturn const*>, void>::delegateCallInst(llvm::CallInst&) (/workspace/Enzyme/enzyme/build/Enzyme/LLVMEnzyme-13.so+0x7a844d)
#12 0x00007f690c72e02d llvm::InstVisitor<AdjointGenerator<AugmentedReturn const*>, void>::visitCall(llvm::CallInst&) (/workspace/Enzyme/enzyme/build/Enzyme/LLVMEnzyme-13.so+0x76402d)
#13 0x00007f690c7178d5 llvm::InstVisitor<AdjointGenerator<AugmentedReturn const*>, void>::visit(llvm::Instruction&) (/workspace/Enzyme/enzyme/build/Enzyme/LLVMEnzyme-13.so+0x74d8d5)
#14 0x00007f690c7057c9 llvm::InstVisitor<AdjointGenerator<AugmentedReturn const*>, void>::visit(llvm::Instruction*) (/workspace/Enzyme/enzyme/build/Enzyme/LLVMEnzyme-13.so+0x73b7c9)
#15 0x00007f690c6cd87b EnzymeLogic::CreatePrimalAndGradient(ReverseCacheKey const&&, TypeAnalysis&, AugmentedReturn const*, bool) (/workspace/Enzyme/enzyme/build/Enzyme/LLVMEnzyme-13.so+0x70387b)
#16 0x00007f690c67c4d5 (anonymous namespace)::Enzyme::HandleAutoDiff(llvm::CallInst*, llvm::TargetLibraryInfo&, DerivativeMode, bool) Enzyme.cpp:0:0
#17 0x00007f690c6815ad (anonymous namespace)::Enzyme::lowerEnzymeCalls(llvm::Function&, bool&, std::set<llvm::Function*, std::less<llvm::Function*>, std::allocator<llvm::Function*> >&) Enzyme.cpp:0:0
#18 0x00007f690c6829e4 (anonymous namespace)::Enzyme::runOnModule(llvm::Module&) Enzyme.cpp:0:0
#19 0x00007f690ff8d4f8 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/lib/x86_64-linux-gnu/libLLVM-13.so.1+0xeca4f8)
#20 0x00000000004343bc main (/usr/lib/llvm-13/bin/opt+0x4343bc)
#21 0x00007f690eb890b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
#22 0x000000000041f5ee _start (/usr/lib/llvm-13/bin/opt+0x41f5ee)
make: *** [Makefile:22: output.ll] Aborted (core dumped)
The issue is that Enzyme is not sure about the type of one of your variables. That might be a bug in Enzyme or a result of your algorithm modifying a variable without actually using it afterwards. If you can provide a cpp example it would be easier to tell.
For now you can try to compile using -enzyme-loose-types
.
This could potentially lead to incorrect gradients, but it helps with getting started.
Thank you very much, I'll try
Hello,
I tried to add "-enzyme-loose-types", and the compilation succeed, but how can I confirm that whether the gradients are correct?
In fact, I suspect there are some wrong results in my program, but what can I do to fix this possibly?Or what should I provide for you to fix this?
And if there are bugs causing incorrect gradients, when can these bugs be fixed?