shared conversions
This commit is contained in:
parent
b2baf512e1
commit
bf3db99bc1
@ -6,9 +6,6 @@ end
|
|||||||
|
|
||||||
Batch(xs) = Batch(Storage(xs))
|
Batch(xs) = Batch(Storage(xs))
|
||||||
|
|
||||||
convert{T,S}(::Type{Batch{T,S}},storage::S) =
|
|
||||||
Batch{T,S}(storage)
|
|
||||||
|
|
||||||
# TODO: figure out how to express this as a generic convert
|
# TODO: figure out how to express this as a generic convert
|
||||||
function rebatch(xs)
|
function rebatch(xs)
|
||||||
dims = ndims(xs)-1
|
dims = ndims(xs)-1
|
||||||
@ -35,9 +32,6 @@ end
|
|||||||
|
|
||||||
Seq(xs) = Seq(Storage(xs))
|
Seq(xs) = Seq(Storage(xs))
|
||||||
|
|
||||||
convert{T,S}(::Type{Seq{T,S}},storage::S) =
|
|
||||||
Seq{T,S}(storage)
|
|
||||||
|
|
||||||
BatchSeq{T<:Seq} = Batch{T}
|
BatchSeq{T<:Seq} = Batch{T}
|
||||||
|
|
||||||
function rebatchseq(xs)
|
function rebatchseq(xs)
|
||||||
|
@ -31,13 +31,12 @@ typename(b::Type{<:BatchLike}) =
|
|||||||
Juno.trim(collect(b)))
|
Juno.trim(collect(b)))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
convert{T,S}(B::Type{<:BatchLike{T,S}},storage::S) = B(storage)
|
||||||
|
|
||||||
struct Storage{T,S} <: BatchLike{T,S}
|
struct Storage{T,S} <: BatchLike{T,S}
|
||||||
data::S
|
data::S
|
||||||
end
|
end
|
||||||
|
|
||||||
convert{T,S}(::Type{Storage{T,S}},storage::S) =
|
|
||||||
Storage{T,S}(storage)
|
|
||||||
|
|
||||||
allequal(xs) = all(x -> x == first(xs), xs)
|
allequal(xs) = all(x -> x == first(xs), xs)
|
||||||
|
|
||||||
function (::Type{Storage{T,S}}){T,S}(xs, storage::S)
|
function (::Type{Storage{T,S}}){T,S}(xs, storage::S)
|
||||||
|
Loading…
Reference in New Issue
Block a user