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

Missing support for erf (and related I guess) #364

Closed
rcalxrc08 opened this issue Jun 17, 2022 · 5 comments
Closed

Missing support for erf (and related I guess) #364

rcalxrc08 opened this issue Jun 17, 2022 · 5 comments

Comments

@rcalxrc08
Copy link

MWE:

using Enzyme, SpecialFunctions;
first(autodiff(Reverse, erf, Active(0.2)));
@wsmoses
Copy link
Member

wsmoses commented Jun 26, 2022

What system are you on and what is the error message specifically

@rcalxrc08
Copy link
Author

Julia Version 1.7.2
Commit bf53498635 (2022-02-06 15:21 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-12.0.1 (ORCJIT, skylake)

@rcalxrc08
Copy link
Author

ERROR: Enzyme compilation failed.
Current scope:
; ModuleID = 'text'
source_filename = "text"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128-ni:10:11:12:13"
target triple = "x86_64-w64-mingw32"

; Function Attrs: readnone
declare {}*** @julia.get_pgcstack() local_unnamed_addr #0

declare double @.text(double) local_unnamed_addr

define double @julia_erf_2035_inner.1(double %0) local_unnamed_addr !dbg !5 {
entry:
  %1 = call {}*** @julia.get_pgcstack()
  %2 = call double @.text(double %0), !dbg !7
  ret double %2, !dbg !11
}

; Function Attrs: willreturn mustprogress
define double @preprocess_julia_erf_2035_inner.1(double %0) local_unnamed_addr #1 !dbg !12 {
entry:
  %1 = call {}*** @julia.get_pgcstack() #1
  %2 = call double @.text(double %0) #1, !dbg !13
  ret double %2, !dbg !16
}

; Function Attrs: willreturn mustprogress
define internal { double } @diffejulia_erf_2035_inner.1(double %0, double %differeturn) local_unnamed_addr #1 !dbg !17 {
entry:
  %1 = call {}*** @julia.get_pgcstack() #1
  %2 = call double @.text(double %0) #1, !dbg !18
  br label %invertentry, !dbg !21

allocsForInversion:                               ; No predecessors!
  %"'de" = alloca double, align 8
  store double 0.000000e+00, double* %"'de", align 8

invertentry:                                      ; preds = %entry
  store double %differeturn, double* %"'de", align 8
}

attributes #0 = { readnone "enzyme_inactive" }
attributes #1 = { willreturn mustprogress }

!llvm.module.flags = !{!0, !1}
!llvm.dbg.cu = !{!2}

!0 = !{i32 2, !"Dwarf Version", i32 4}
!1 = !{i32 2, !"Debug Info Version", i32 3}
!2 = distinct !DICompileUnit(language: DW_LANG_Julia, file: !3, producer: "julia", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !4, nameTableKind: None)
!3 = !DIFile(filename: "C:\\Users\\Nicola\\.julia\\packages\\SpecialFunctions\\oPGFg\\src\\erf.jl", directory: ".")
!4 = !{}
!5 = distinct !DISubprogram(name: "erf", linkageName: "julia_erf_2035", scope: null, file: !3, line: 13, type: !6, scopeLine: 13, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !4)
!6 = !DISubroutineType(types: !4)
!7 = !DILocation(line: 15, scope: !8, inlinedAt: !9)
!8 = distinct !DISubprogram(name: "_erf;", linkageName: "_erf", scope: !3, file: !3, type: !6, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !4)
!9 = distinct !DILocation(line: 13, scope: !5, inlinedAt: !10)
!10 = distinct !DILocation(line: 0, scope: !5)
!11 = !DILocation(line: 0, scope: !5)
!12 = distinct !DISubprogram(name: "erf", linkageName: "julia_erf_2035", scope: null, file: !3, line: 13, type: !6, scopeLine: 13, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !4)
!13 = !DILocation(line: 15, scope: !8, inlinedAt: !14)
!14 = distinct !DILocation(line: 13, scope: !12, inlinedAt: !15)
!15 = distinct !DILocation(line: 0, scope: !12)
!16 = !DILocation(line: 0, scope: !12)
!17 = distinct !DISubprogram(name: "erf", linkageName: "julia_erf_2035", scope: null, file: !3, line: 13, type: !6, scopeLine: 13, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !4)
!18 = !DILocation(line: 15, scope: !8, inlinedAt: !19)
!19 = distinct !DILocation(line: 13, scope: !17, inlinedAt: !20)
!20 = distinct !DILocation(line: 0, scope: !17)
!21 = !DILocation(line: 0, scope: !17)

No reverse pass found for .text
declare double @.text(double) local_unnamed_addr



Stacktrace:
  [1] julia_error(cstr::Cstring, val::Ptr{LLVM.API.LLVMOpaqueValue}, errtype::Enzyme.API.ErrorType, data::Ptr{Nothing})
    @ Enzyme.Compiler C:\Users\Nicola\.julia\packages\Enzyme\Wanbg\src\compiler.jl:2636
  [2] EnzymeCreatePrimalAndGradient(logic::Enzyme.Logic, todiff::LLVM.Function, retType::Enzyme.API.CDIFFE_TYPE, constant_args::Vector{Enzyme.API.CDIFFE_TYPE}, TA::Enzyme.TypeAnalysis, returnValue::Bool, dretUsed::Bool, mode::Enzyme.API.CDerivativeMode, width::Int64, additionalArg::Ptr{Nothing}, typeInfo::Enzyme.FnTypeInfo, uncacheable_args::Vector{Bool}, augmented::Ptr{Nothing}, atomicAdd::Bool)
    @ Enzyme.API C:\Users\Nicola\.julia\packages\Enzyme\Wanbg\src\api.jl:111
  [3] enzyme!(job::GPUCompiler.CompilerJob{Enzyme.Compiler.EnzymeTarget, Enzyme.Compiler.EnzymeCompilerParams, GPUCompiler.FunctionSpec{typeof(erf), Tuple{Float64}}}, mod::LLVM.Module, primalf::LLVM.Function, adjoint::GPUCompiler.FunctionSpec{typeof(erf), Tuple{Active{Float64}}}, mode::Enzyme.API.CDerivativeMode, width::Int64, parallel::Bool, actualRetType::Type, dupClosure::Bool, wrap::Bool, modifiedBetween::Bool, returnPrimal::Bool)
    @ Enzyme.Compiler C:\Users\Nicola\.julia\packages\Enzyme\Wanbg\src\compiler.jl:3271
  [4] codegen(output::Symbol, job::GPUCompiler.CompilerJob{Enzyme.Compiler.EnzymeTarget, Enzyme.Compiler.EnzymeCompilerParams, GPUCompiler.FunctionSpec{typeof(erf), Tuple{Float64}}}; libraries::Bool, deferred_codegen::Bool, optimize::Bool, ctx::LLVM.Context, strip::Bool, validate::Bool, only_entry::Bool, parent_job::Nothing)
    @ Enzyme.Compiler C:\Users\Nicola\.julia\packages\Enzyme\Wanbg\src\compiler.jl:4156
  [5] _thunk(job::GPUCompiler.CompilerJob{Enzyme.Compiler.EnzymeTarget, Enzyme.Compiler.EnzymeCompilerParams, GPUCompiler.FunctionSpec{typeof(erf), Tuple{Float64}}})
    @ Enzyme.Compiler C:\Users\Nicola\.julia\packages\Enzyme\Wanbg\src\compiler.jl:4562
  [6] cached_compilation(job::GPUCompiler.CompilerJob, key::UInt64, specid::UInt64)
    @ Enzyme.Compiler C:\Users\Nicola\.julia\packages\Enzyme\Wanbg\src\compiler.jl:4600
  [7] #s565#115
    @ C:\Users\Nicola\.julia\packages\Enzyme\Wanbg\src\compiler.jl:4660 [inlined]
  [8] var"#s565#115"(F::Any, Fn::Any, DF::Any, A::Any, TT::Any, Mode::Any, ModifiedBetween::Any, width::Any, specid::Any, ReturnPrimal::Any, ::Any, #unused#::Type, f::Any, df::Any, #unused#::Type, tt::Any, #unused#::Type, #unused#::Type, #unused#::Type, #unused#::Type, #unused#::Any)
    @ Enzyme.Compiler .\none:0
  [9] (::Core.GeneratedFunctionStub)(::Any, ::Vararg{Any})
    @ Core .\boot.jl:580
 [10] thunk
    @ C:\Users\Nicola\.julia\packages\Enzyme\Wanbg\src\compiler.jl:4688 [inlined]
 [11] thunk (repeats 2 times)
    @ C:\Users\Nicola\.julia\packages\Enzyme\Wanbg\src\compiler.jl:4681 [inlined]
 [12] autodiff
    @ C:\Users\Nicola\.julia\packages\Enzyme\Wanbg\src\Enzyme.jl:285 [inlined]
 [13] autodiff(mode::Enzyme.ReverseMode, f::typeof(erf), args::Active{Float64})
    @ Enzyme C:\Users\Nicola\.julia\packages\Enzyme\Wanbg\src\Enzyme.jl:319
 [14] top-level scope
    @ REPL[3]:1

@wsmoses
Copy link
Member

wsmoses commented Feb 17, 2023

We include erf now explicitly in our test set, which appears to pass on all systems. Please reopen if this persists.

@wsmoses wsmoses closed this as completed Mar 6, 2023
@rcalxrc08
Copy link
Author

I am still getting an error, very similar to before:
`ERROR: Enzyme compilation failed.
Current scope:
; ModuleID = 'start'
source_filename = "start"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128-ni:10:11:12:13"
target triple = "x86_64-w64-mingw32"

; Function Attrs: nofree readnone
declare {}*** @julia.get_pgcstack() local_unnamed_addr #0

declare double @.text(double) local_unnamed_addr

define double @julia_erf_1063_inner.1(double %0) local_unnamed_addr #1 !dbg !4 {
entry:
%1 = call {}*** @julia.get_pgcstack()
%2 = call double @.text(double %0), !dbg !7
ret double %2, !dbg !11
}

; Function Attrs: mustprogress willreturn
define double @preprocess_julia_erf_1063_inner.1(double %0) local_unnamed_addr #2 !dbg !12 {
entry:
%1 = call {}*** @julia.get_pgcstack() #3
%2 = call double @.text(double %0) #3, !dbg !13
ret double %2, !dbg !16
}

; Function Attrs: mustprogress willreturn
define internal { double } @diffejulia_erf_1063_inner.1(double %0, double %differeturn) local_unnamed_addr #2 !dbg !17 {
entry:
%1 = call {}*** @julia.get_pgcstack() #3
%2 = call double @.text(double %0) #3, !dbg !18
br label %invertentry, !dbg !21

allocsForInversion: ; No predecessors!
%"'de" = alloca double, align 8
%3 = getelementptr double, double* %"'de", i64 0
store double 0.000000e+00, double* %3, align 8

invertentry: ; preds = %entry
store double %differeturn, double* %"'de", align 8
}

attributes #0 = { nofree readnone "enzyme_inactive" "enzyme_shouldrecompute" "enzymejl_world"="33515" }
attributes #1 = { "enzymejl_mi"="2166193343792" "enzymejl_rt"="140718919899840" "enzymejl_world"="33515" }
attributes #2 = { mustprogress willreturn "enzymejl_mi"="2166193343792" "enzymejl_rt"="140718919899840" "enzymejl_world"="33515" }
attributes #3 = { mustprogress willreturn }

!llvm.module.flags = !{!0, !1}
!llvm.dbg.cu = !{!2}

!0 = !{i32 2, !"Dwarf Version", i32 4}
!1 = !{i32 2, !"Debug Info Version", i32 3}
!2 = distinct !DICompileUnit(language: DW_LANG_Julia, file: !3, producer: "julia", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, nameTableKind: None)
!3 = !DIFile(filename: "C:\Users\Nicola\.julia\packages\SpecialFunctions\QH8rV\src\erf.jl", directory: ".")
!4 = distinct !DISubprogram(name: "erf", linkageName: "julia_erf_1063", scope: null, file: !3, line: 13, type: !5, scopeLine: 13, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !6)
!5 = !DISubroutineType(types: !6)
!6 = !{}
!7 = !DILocation(line: 15, scope: !8, inlinedAt: !9)
!8 = distinct !DISubprogram(name: "_erf;", linkageName: "_erf", scope: !3, file: !3, type: !5, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !6)
!9 = distinct !DILocation(line: 13, scope: !4, inlinedAt: !10)
!10 = distinct !DILocation(line: 0, scope: !4)
!11 = !DILocation(line: 0, scope: !4)
!12 = distinct !DISubprogram(name: "erf", linkageName: "julia_erf_1063", scope: null, file: !3, line: 13, type: !5, scopeLine: 13, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !6)
!13 = !DILocation(line: 15, scope: !8, inlinedAt: !14)
!14 = distinct !DILocation(line: 13, scope: !12, inlinedAt: !15)
!15 = distinct !DILocation(line: 0, scope: !12)
!16 = !DILocation(line: 0, scope: !12)
!17 = distinct !DISubprogram(name: "erf", linkageName: "julia_erf_1063", scope: null, file: !3, line: 13, type: !5, scopeLine: 13, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !6)
!18 = !DILocation(line: 15, scope: !8, inlinedAt: !19)
!19 = distinct !DILocation(line: 13, scope: !17, inlinedAt: !20)
!20 = distinct !DILocation(line: 0, scope: !17)
!21 = !DILocation(line: 0, scope: !17)

No reverse pass found for .text
declare double @.text(double) local_unnamed_addr

Stacktrace:
[1] julia_error(cstr::Cstring, val::Ptr{LLVM.API.LLVMOpaqueValue}, errtype::Enzyme.API.ErrorType, data::Ptr{Nothing}, data2::Ptr{LLVM.API.LLVMOpaqueValue}, B::Ptr{LLVM.API.LLVMOpaqueBuilder})
@ Enzyme.Compiler C:\Users\Nicola.julia\packages\Enzyme\0SYwj\src\compiler.jl:5768
[2] EnzymeCreatePrimalAndGradient(logic::Enzyme.Logic, todiff::LLVM.Function, retType::Enzyme.API.CDIFFE_TYPE, constant_args::Vector{Enzyme.API.CDIFFE_TYPE}, TA::Enzyme.TypeAnalysis, returnValue::Bool, dretUsed::Bool, mode::Enzyme.API.CDerivativeMode, width::Int64, additionalArg::Ptr{Nothing}, forceAnonymousTape::Bool, typeInfo::Enzyme.FnTypeInfo, uncacheable_args::Vector{Bool}, augmented::Ptr{Nothing}, atomicAdd::Bool)
@ Enzyme.API C:\Users\Nicola.julia\packages\Enzyme\0SYwj\src\api.jl:128
[3] enzyme!(job::GPUCompiler.CompilerJob{Enzyme.Compiler.EnzymeTarget, Enzyme.Compiler.EnzymeCompilerParams}, mod::LLVM.Module, primalf::LLVM.Function, TT::Type, mode::Enzyme.API.CDerivativeMode, width::Int64, parallel::Bool, actualRetType::Type, wrap::Bool, modifiedBetween::Tuple{Bool, Bool}, returnPrimal::Bool, jlrules::Vector{String}, expectedTapeType::Type)
@ Enzyme.Compiler C:\Users\Nicola.julia\packages\Enzyme\0SYwj\src\compiler.jl:7581
[4] codegen(output::Symbol, job::GPUCompiler.CompilerJob{Enzyme.Compiler.EnzymeTarget, Enzyme.Compiler.EnzymeCompilerParams}; libraries::Bool, deferred_codegen::Bool, optimize::Bool, toplevel::Bool, strip::Bool, validate::Bool, only_entry::Bool, parent_job::Nothing)
@ Enzyme.Compiler C:\Users\Nicola.julia\packages\Enzyme\0SYwj\src\compiler.jl:9119
[5] codegen
@ C:\Users\Nicola.julia\packages\Enzyme\0SYwj\src\compiler.jl:8723 [inlined]
[6] _thunk(job::GPUCompiler.CompilerJob{Enzyme.Compiler.EnzymeTarget, Enzyme.Compiler.EnzymeCompilerParams}, postopt::Bool)
@ Enzyme.Compiler C:\Users\Nicola.julia\packages\Enzyme\0SYwj\src\compiler.jl:9671
[7] _thunk
@ C:\Users\Nicola.julia\packages\Enzyme\0SYwj\src\compiler.jl:9671 [inlined]
[8] cached_compilation
@ C:\Users\Nicola.julia\packages\Enzyme\0SYwj\src\compiler.jl:9705 [inlined]
[9] (::Enzyme.Compiler.var"#475#476"{DataType, DataType, DataType, Enzyme.API.CDerivativeMode, Tuple{Bool, Bool}, Int64, Bool, Bool, UInt64, DataType})(ctx::LLVM.Context)
@ Enzyme.Compiler C:\Users\Nicola.julia\packages\Enzyme\0SYwj\src\compiler.jl:9768
[10] JuliaContext(f::Enzyme.Compiler.var"#475#476"{DataType, DataType, DataType, Enzyme.API.CDerivativeMode, Tuple{Bool, Bool}, Int64, Bool, Bool, UInt64, DataType})
@ GPUCompiler C:\Users\Nicola.julia\packages\GPUCompiler\YO8Uj\src\driver.jl:47
[11] #s292#474
@ C:\Users\Nicola.julia\packages\Enzyme\0SYwj\src\compiler.jl:9723 [inlined]
[12] var"#s292#474"(FA::Any, A::Any, TT::Any, Mode::Any, ModifiedBetween::Any, width::Any, ReturnPrimal::Any, ShadowInit::Any, World::Any, ABI::Any, ::Any, #unused#::Type, #unused#::Type, #unused#::Type, tt::Any, #unused#::Type, #unused#::Type, #unused#::Type, #unused#::Type, #unused#::Type, #unused#::Any)
@ Enzyme.Compiler .\none:0
[13] (::Core.GeneratedFunctionStub)(::Any, ::Vararg{Any})
@ Core .\boot.jl:602
[14] autodiff
@ C:\Users\Nicola.julia\packages\Enzyme\0SYwj\src\Enzyme.jl:207 [inlined]
[15] autodiff
@ C:\Users\Nicola.julia\packages\Enzyme\0SYwj\src\Enzyme.jl:236 [inlined]
[16] autodiff(mode::ReverseMode{false, FFIABI}, f::typeof(erf), args::Active{Float64})
@ Enzyme C:\Users\Nicola.julia\packages\Enzyme\0SYwj\src\Enzyme.jl:222
[17] top-level scope
@ REPL[2]:1`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants