Skip to content

Commit

Permalink
fix v0.6 depwarns
Browse files Browse the repository at this point in the history
  • Loading branch information
jrevels committed Mar 7, 2017
1 parent e54c6cd commit 0456f1a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 21 deletions.
8 changes: 4 additions & 4 deletions src/api/Config.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Base.show(io::IO, cfg::AbstractConfig) = print(io, typeof(cfg).name)
# GradientConfig #
##################

immutable GradientConfig{I} <: AbstractConfig
@compat immutable GradientConfig{I} <: AbstractConfig
input::I
tape::InstructionTape
# disable default outer constructor
GradientConfig(input, tape) = new(input, tape)
(::Type{GradientConfig{I}}){I}(input, tape) = new{I}(input, tape)
end

# "private" convienence constructor
Expand Down Expand Up @@ -54,12 +54,12 @@ end
# JacobianConfig #
##################

immutable JacobianConfig{I,O} <: AbstractConfig
@compat immutable JacobianConfig{I,O} <: AbstractConfig
input::I
output::O
tape::InstructionTape
# disable default outer constructor
JacobianConfig(input, output, tape) = new(input, output, tape)
(::Type{JacobianConfig{I,O}}){I,O}(input, output, tape) = new{I,O}(input, output, tape)
end

# "private" convienence constructor
Expand Down
8 changes: 4 additions & 4 deletions src/api/tape.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ for T in (:GradientTape, :JacobianTape, :HessianTape)
output::O
tape::InstructionTape
# disable default outer constructor
$(T)(func, input, output, tape) = new(func, input, output, tape)
(::Type{$(T){F,I,O}}){F,I,O}(func, input, output, tape) = new{F,I,O}(func, input, output, tape)
end

# "private" convienence constructor
Expand Down Expand Up @@ -62,9 +62,9 @@ end

Base.show{S}(io::IO, t::CompiledTape{S}) = print(io, typeof(t).name, "{$S}($(t.tape.func))")

typealias CompiledGradient{S,T<:GradientTape} CompiledTape{S,T}
typealias CompiledJacobian{S,T<:JacobianTape} CompiledTape{S,T}
typealias CompiledHessian{S,T<:HessianTape} CompiledTape{S,T}
@compat const CompiledGradient{S,T<:GradientTape} = CompiledTape{S,T}
@compat const CompiledJacobian{S,T<:JacobianTape} = CompiledTape{S,T}
@compat const CompiledHessian{S,T<:HessianTape} = CompiledTape{S,T}

Base.length(ct::CompiledTape) = length(ct.tape)

Expand Down
2 changes: 1 addition & 1 deletion src/derivatives/elementwise.jl
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ end
# built-in infix operations #
#############################

typealias TrackedType Union{TrackedArray,TrackedReal}
@compat const TrackedType = Union{TrackedArray,TrackedReal}

# dispatch #
#----------#
Expand Down
12 changes: 8 additions & 4 deletions src/tape.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ end
# ScalarInstruction #
#-------------------#

immutable ScalarInstruction{F,I,O,C} <: AbstractInstruction
@compat immutable ScalarInstruction{F,I,O,C} <: AbstractInstruction
func::F
input::I
output::O
cache::C
# disable default outer constructor
(::Type{ScalarInstruction{F,I,O,C}}){F,I,O,C}(func::F, input::I, output::O, cache::C) = new(func, input, output, cache)
function (::Type{ScalarInstruction{F,I,O,C}}){F,I,O,C}(func, input, output, cache)
return new{F,I,O,C}(func, input, output, cache)
end
end

@inline function _ScalarInstruction{F,I,O,C}(func::F, input::I, output::O, cache::C)
Expand All @@ -47,13 +49,15 @@ end
# SpecialInstruction #
#--------------------#

immutable SpecialInstruction{F,I,O,C} <: AbstractInstruction
@compat immutable SpecialInstruction{F,I,O,C} <: AbstractInstruction
func::F
input::I
output::O
cache::C
# disable default outer constructor
(::Type{SpecialInstruction{F,I,O,C}}){F,I,O,C}(func::F, input::I, output::O, cache::C) = new(func, input, output, cache)
function (::Type{SpecialInstruction{F,I,O,C}}){F,I,O,C}(func, input, output, cache)
return new{F,I,O,C}(func, input, output, cache)
end
end

@inline function _SpecialInstruction{F,I,O,C}(func::F, input::I, output::O, cache::C)
Expand Down
18 changes: 10 additions & 8 deletions src/tracked.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ overcomplicates the API and would incur unneccesary pointer loads during re-vali
making the below implementation preferable.
=#

type TrackedReal{V<:Real,D<:Real,O} <: Real
@compat type TrackedReal{V<:Real,D<:Real,O} <: Real
value::V
deriv::D
tape::InstructionTape
index::Int
origin::O
(::Type{TrackedReal{V,D,O}}){V,D,O}(value, deriv, tape, index, origin) = new(value, deriv, tape, index, origin)
(::Type{TrackedReal{V,D,O}}){V,D,O}(value, deriv, tape) = new(value, deriv, tape, NULL_INDEX)
(::Type{TrackedReal{V,D,O}}){V,D,O}(value, deriv) = new(value, deriv, NULL_TAPE, NULL_INDEX)
(::Type{TrackedReal{V,D,O}}){V,D,O}(value) = new(value, zero(D), NULL_TAPE, NULL_INDEX)
(::Type{TrackedReal{V,D,O}}){V,D,O}(value, deriv, tape, index, origin) = new{V,D,O}(value, deriv, tape, index, origin)
(::Type{TrackedReal{V,D,O}}){V,D,O}(value, deriv, tape) = new{V,D,O}(value, deriv, tape, NULL_INDEX)
(::Type{TrackedReal{V,D,O}}){V,D,O}(value, deriv) = new{V,D,O}(value, deriv, NULL_TAPE, NULL_INDEX)
(::Type{TrackedReal{V,D,O}}){V,D,O}(value) = new{V,D,O}(value, zero(D), NULL_TAPE, NULL_INDEX)
end

TrackedReal{V,D,O}(v::V, a::D, tp::InstructionTape, i::Int, o::O) = TrackedReal{V,D,O}(v, a, tp, i, o)
Expand All @@ -63,14 +63,16 @@ TrackedReal{V,D}(v::V, a::D, tp::InstructionTape = NULL_TAPE) = TrackedReal{V,D,
# TrackedArray #
#--------------#

immutable TrackedArray{V,D,N,VA,DA} <: AbstractArray{TrackedReal{V,D,TrackedArray{V,D,N,VA,DA}},N}
@compat immutable TrackedArray{V,D,N,VA,DA} <: AbstractArray{TrackedReal{V,D,TrackedArray{V,D,N,VA,DA}},N}
value::VA
deriv::DA
tape::InstructionTape
function TrackedArray(value::AbstractArray{V,N}, deriv::AbstractArray{D,N}, tape::InstructionTape)
function (::Type{TrackedArray{V,D,N,VA,DA}}){V,D,N,VA,DA}(value::AbstractArray{V,N},
deriv::AbstractArray{D,N},
tape::InstructionTape)
@assert IndexStyle(value) === IndexLinear()
@assert size(value) === size(deriv)
return new(value, deriv, tape)
return new{V,D,N,VA,DA}(value, deriv, tape)
end
end

Expand Down

0 comments on commit 0456f1a

Please sign in to comment.