Skip to content

Commit de0b230

Browse files
committed
cleanup hashing
1 parent 8cc74b6 commit de0b230

File tree

4 files changed

+4
-3
lines changed

4 files changed

+4
-3
lines changed

src/batched_reals.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ unbatch(br::BatchedReal; dims=1) = reshape(br.vals, ntuple(_->1, dims-1)..., :)
3535
unbatch(r::Real; dims=nothing) = r
3636
Base.show(io::IO, br::BatchedReal) = print(io, "Batched", br.vals)
3737
(::Type{T})(br::BatchedReal) where {T<:Real} = batch(T.(br.vals))
38-
Base.hash(bv::BatchedReal, h::UInt) = foldr(hash, (typeof(bv), bv.vals), init=h)
38+
hash(bv::BatchedReal, h::UInt64) = foldr(hash, (typeof(bv), bv.vals), init=h)
3939

4040

4141
# used to denote a batch of things, no other functionality

src/dataset.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ end
1818
copy(ds::DS) where {DS<:DataSet} =
1919
DS(((k==:_super ? copy(v) : v) for (k,v) in pairs(fields(ds)))...)
2020

21-
hash(ds::DataSet, h::UInt64) = hash(typeof(ds), foldr(hash, fieldvalues(ds), init=h))
21+
hash(ds::DataSet, h::UInt64) = foldr(hash, (typeof(ds), fieldvalues(ds)...), init=h)
2222

2323
# needed until fix to https://github.com/FluxML/Zygote.jl/issues/685
2424
Zygote.grad_mut(ds::DataSet) = Ref{Any}((;(propertynames(ds) .=> nothing)...))

src/field_tuples.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ white_noise(ξ::FieldTuple, rng::AbstractRNG) = FieldTuple(map(f -> white_noise(
109109

110110
# # promote before recursing for these
111111
dot(a::FieldTuple, b::FieldTuple) = reduce(+, map(dot, getfield.(promote(a,b),:fs)...), init=0)
112-
hash(ft::FieldTuple, h::UInt) = foldr(hash, (typeof(ft), ft.fs))
112+
hash(ft::FieldTuple, h::UInt64) = foldr(hash, (typeof(ft), ft.fs), init=h)
113113

114114
# logdet & trace
115115
logdet(L::Diagonal{<:Union{Real,Complex}, <:FieldTuple}) = reduce(+, map(logdetDiagonal, L.diag.fs), init=0)

src/specialops.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ SymmetricFuncOp(op::Function) = SymmetricFuncOp(op=op)
122122
adjoint(L::FuncOp) = FuncOp(L.opᴴ,L.op,L.op⁻ᴴ,L.op⁻¹)
123123
inv(L::FuncOp) = FuncOp(L.op⁻¹,L.op⁻ᴴ,L.op,L.opᴴ)
124124
adapt_structure(to, L::FuncOp) = FuncOp(adapt(to, fieldvalues(L))...)
125+
hash(L::FuncOp, h::UInt64) = foldr(hash, (typeof(L), fieldvalues(L)...), init=h)
125126

126127

127128
### BandPassOp

0 commit comments

Comments
 (0)