dfdx / Ghost.jl

The Code Tracer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem with splatting (args...,)

jw3126 opened this issue · comments

using Ghost
using Test
function f(x)
    xs = (1,)
    ys = (xs..., x)
    sum(ys)
end

x = 1
val_truth = f(x)
val_ghost,tape = Ghost.trace(f, x)
@show val_truth
@show val_ghost
println(tape)
@test val_truth == val_ghost

gives:

val_truth = 2
val_ghost = 1
Tape{Dict{Any, Any}}
  inp %1::typeof(Main.MWE.f)
  inp %2::Int64
  %3 = tuple(1)::Tuple{Int64}
  %4 = tuple(%2)::Tuple{Int64}
  %5 = sum(%4)::Int64

For whatever reason I decided that functions in Core starting with _, including the missing Core._apply_iterate(), don't deserve to be treated as primitives 🤦 The fix is on its way.

Merged.