Add explicit copy(x::TrackedArray) method

This commit is contained in:
JohnnyChen 2018-10-09 03:34:41 +08:00
parent 36f5f274a5
commit 27fec15fcc
2 changed files with 4 additions and 0 deletions

View File

@ -43,6 +43,8 @@ end
Base.print_array(io::IO, x::TrackedArray) = Base.print_array(io, data(x))
Base.copy(x::TrackedArray) = copy(data(x))
Base.setindex!(xs::TrackedArray, v, i...) =
error("Can't differentiate `setindex!`")

View File

@ -23,6 +23,8 @@ end
Base.decompose(x::TrackedReal) = Base.decompose(data(x))
Base.copy(x::TrackedArray) = copy(data(x))
Base.convert(::Type{T}, x::TrackedReal{S}) where {T<:Real,S} = convert(T, data(x))
Base.convert(::Type{TrackedReal{T}}, x::TrackedReal{T}) where T = x