Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/read.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

# Convenience function to allow for things like Array(tp) or CuArray(tp)
# Not sure if this counts as type piracy...
(::Type{T})(p::TensorProto) where T = array(p) |> T
(::Type{Ref{T}})(p::TensorProto) where T = array(p) |> T |> Ref
(::Type{T})(p::TensorProto) where T <: AbstractArray = array(p) |> T
(::Type{Ref{T}})(p::TensorProto) where T <: AbstractArray = array(p) |> T |> Ref


"""
Expand Down Expand Up @@ -67,9 +67,9 @@ function attribute(p::AttributeProto)
if (p._type != 0)
field = [:f, :i, :s, :t, :g, :floats, :ints, :strings, :tensors, :graphs][p._type]
if field === :s
return Symbol(p.name) => String(getfield(p, field))
return Symbol(p.name) => String(copy(getfield(p, field)))
elseif field === :strings
return Symbol(p.name) => String.(getfield(p, field))
return Symbol(p.name) => String.(copy.(getfield(p, field)))
end
return Symbol(p.name) => getfield(p, field)
end
Expand Down