From f3904b4e0490bdd7a1b60c16bfc86372736f6cfa Mon Sep 17 00:00:00 2001 From: Dhairya Gandhi Date: Tue, 8 Oct 2019 17:17:36 +0530 Subject: [PATCH] add ZeroType back --- src/utils.jl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/utils.jl b/src/utils.jl index 246c30d7..a42c37d5 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -139,6 +139,19 @@ function throttle(f, timeout; leading=true, trailing=false) end end +import Base: +, reshape, size + +struct ZeroType{T} <: Number + size::T +end + ++(a::Number, ::ZeroType) = a ++(::ZeroType, a::Number) = a +size(xs::ZeroType) = xs.size +reshape(::ZeroType, args...) = ZeroType(args) +@adjoint reshape(xs::ZeroType, dims...) = + ZeroType(dims), Δ -> (ZeroType(size(xs)), map(_ -> nothing, dims)...) + """ @jit ...