add ZeroType back

This commit is contained in:
Dhairya Gandhi 2019-10-08 17:17:36 +05:30
parent a1e826b888
commit f3904b4e04

View File

@ -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 ...