Skip to content

BitVector failure #1523

@mhauru

Description

@mhauru
using Zygote: Zygote

struct VNV{TVal}
    vals::TVal
    bv::BitVector
end

f(x) = VNV(x, BitVector(undef, 1)).vals
Zygote.pullback(f, [1.0])

The above fails with

ERROR: LoadError: ArgumentError: new: too few arguments (expected 3)
Stacktrace:
  [1] __new__
    @ ~/.julia/packages/Zygote/nsBv0/src/tools/builtins.jl:9 [inlined]
  [2] adjoint
    @ ~/.julia/packages/Zygote/nsBv0/src/lib/lib.jl:296 [inlined]
  [3] _pullback
    @ ~/.julia/packages/ZygoteRules/M4xmc/src/adjoint.jl:67 [inlined]
  [4] BitArray
    @ ./bitarray.jl:39 [inlined]
  [5] _pullback(::Zygote.Context{false}, ::Type{BitVector}, ::UndefInitializer, ::Int64)
    @ Zygote ~/.julia/packages/Zygote/nsBv0/src/compiler/interface2.jl:0
  [6] f
    @ ~/projects/DynamicPPL.jl/tmp_zygote_bug.jl:10 [inlined]
  [7] _pullback(ctx::Zygote.Context{false}, f::typeof(Main.TmpZygoteBug.f), args::Vector{Float64})
    @ Zygote ~/.julia/packages/Zygote/nsBv0/src/compiler/interface2.jl:0
  [8] pullback(f::Function, cx::Zygote.Context{false}, args::Vector{Float64})
    @ Zygote ~/.julia/packages/Zygote/nsBv0/src/compiler/interface.jl:90
  [9] pullback(f::Function, args::Vector{Float64})
    @ Zygote ~/.julia/packages/Zygote/nsBv0/src/compiler/interface.jl:88
 [10] top-level scope
    @ ~/projects/DynamicPPL.jl/tmp_zygote_bug.jl:11
 [11] include(fname::String)
    @ Base.MainInclude ./client.jl:489
 [12] top-level scope
    @ REPL[3]:1
in expression starting at /Users/mhauru/projects/DynamicPPL.jl/tmp_zygote_bug.jl:1

on v0.6.70.

Switching to e.g. Vector{Bool} rather than a BitVector works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ChainRulesadjoint -> rrule, and further integration

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions