ObjectIdDict -> IdDict

This commit is contained in:
Mike J Innes 2018-07-12 20:56:51 +01:00
parent 297bb5f44e
commit 474f578517
3 changed files with 6 additions and 6 deletions

View File

@ -79,14 +79,14 @@ function Base.show(io::IO, ps::Params)
end
struct Grads
grads::ObjectIdDict
grads::IdDict{Any,Any}
end
Base.show(io::IO, ps::Grads) = println(io, "Grads(...)")
Grads() = Grads(ObjectIdDict())
Grads() = Grads(IdDict())
Grads(ps::Params) = Grads(ObjectIdDict(tracker(p) => init_grad(data(p)) for p in ps))
Grads(ps::Params) = Grads(IdDict(tracker(p) => init_grad(data(p)) for p in ps))
Base.getindex(g::Grads, x::Tracked) = g.grads[x]
function Base.getindex(g::Grads, x)

View File

@ -1,6 +1,6 @@
struct IdSet{T} <: AbstractSet{T}
dict::ObjectIdDict
IdSet{T}() where T = new(ObjectIdDict())
dict::IdDict{T,Nothing}
IdSet{T}() where T = new(IdDict{T,Nothing}())
end
Base.eltype{T}(::IdSet{T}) = T

View File

@ -16,7 +16,7 @@ end
isleaf(x) = isempty(children(x))
function mapleaves(f, x; cache = ObjectIdDict())
function mapleaves(f, x; cache = IdDict())
haskey(cache, x) && return cache[x]
cache[x] = isleaf(x) ? f(x) : mapchildren(x -> mapleaves(f, x, cache = cache), x)
end