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

Problems with mapreduce(...) #2287

Open
nsiccha opened this issue Jan 30, 2025 · 1 comment
Open

Problems with mapreduce(...) #2287

nsiccha opened this issue Jan 30, 2025 · 1 comment

Comments

@nsiccha
Copy link

nsiccha commented Jan 30, 2025

The following fails:

    using Enzyme
    # As per previous error
    Enzyme.API.strictAliasing!(false)
    g(x) = mapreduce(identity, hcat, eachcol(x))
    f(x) = sum(g(x))
    X = zeros((10,10))
    G = zeros((10,10))
    autodiff(set_runtime_activity(ReverseWithPrimal), Const(f), Active, Duplicated(X,G))

Part of the output:

Cannot deduce type of copy   call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 8 dereferenceable(16) %69, i8* noundef nonnull align 8 dereferenceable(16) %70, i64 noundef 16, i1 noundef false) #77, !dbg !216, !tbaa !154, !alias.scope !156, !noalias !157

Caused by:
Stacktrace:
 [1] checkbounds
   @ ./abstractarray.jl:700
 [2] _setindex!
   @ ./multidimensional.jl:943
 [3] setindex!
   @ ./abstractarray.jl:1395
 [4] _typed_hcat
   @ ./abstractarray.jl:1687
within MethodInstance for Base._typed_hcat(::Type{Float64}, ::Tuple{Matrix{Float64}, SubArray{Float64, 1, Matrix{Float64}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, true}})

The following fails as well, BUT ONLY IN A FRESH SESSION. Rerunning things makes it work for some reason. HOWEVER, for an application using something like the below, rerunning things does not make it work.

begin
    using Enzyme
    Enzyme.API.strictAliasing!(false)
h2(x) = x .- log(sum(exp.(x)))
h1(x) = vcat(
    x[1],
    h2(x[2:3]),
    h2(x[4:6]),
    x[7:end]
)
g(x) = mapreduce(h1, hcat, eachcol(x))
f(x) = sum(g(x))
X = zeros((10,10))
G = zeros((10,10))
autodiff(set_runtime_activity(ReverseWithPrimal), Const(f), Active, Duplicated(X,G))
end

Part of the output:

{[0]:Pointer, [0,-1]:Float@double, [8]:Integer, [9]:Integer, [10]:Integer, [11]:Integer, [12]:Integer, [13]:Integer, [14]:Integer, [15]:Integer, [16]:Integer, [17]:Integer, [18]:Integer, [19]:Integer, [20]:Integer, [21]:Integer, [22]:Integer, [23]:Integer, [24]:Integer, [25]:Integer, [26]:Integer, [27]:Integer, [28]:Integer, [29]:Integer, [30]:Integer, [31]:Integer, [32]:Integer, [33]:Integer, [34]:Integer, [35]:Integer, [36]:Integer, [37]:Integer, [38]:Integer, [39]:Integer}
 canonicalizing 8
{[0]:Pointer, [0,-1]:Float@double, [8]:Integer, [9]:Integer, [10]:Integer, [11]:Integer, [12]:Integer, [13]:Integer, [14]:Integer, [15]:Integer, [16]:Integer, [17]:Integer, [18]:Integer, [19]:Integer, [20]:Integer, [21]:Integer, [22]:Integer, [23]:Integer, [24]:Integer, [25]:Integer, [26]:Integer, [27]:Integer, [28]:Integer, [29]:Integer, [30]:Integer, [31]:Integer, [32]:Integer, [33]:Integer, [34]:Integer, [35]:Integer, [36]:Integer, [37]:Integer, [38]:Integer, [39]:Integer}
 canonicalizing 8
{[0]:Pointer, [0,-1]:Float@double, [8]:Integer, [9]:Integer, [10]:Integer, [11]:Integer, [12]:Integer, [13]:Integer, [14]:Integer, [15]:Integer, [16]:Integer, [17]:Integer, [18]:Integer, [19]:Integer, [20]:Integer, [21]:Integer, [22]:Integer, [23]:Integer, [24]:Integer, [25]:Integer, [26]:Integer, [27]:Integer, [28]:Integer, [29]:Integer, [30]:Integer, [31]:Integer, [32]:Integer, [33]:Integer, [34]:Integer, [35]:Integer, [36]:Integer, [37]:Integer, [38]:Integer, [39]:Integer}
 canonicalizing 8
ERROR: LLVM.LLVMException("Canonicalization failed")
@nsiccha
Copy link
Author

nsiccha commented Jan 30, 2025

Forgot the version: Julia version 1.10.8 + Enzyme version 0.13.28

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

1 participant