From 635df698bd95b97ec9a40f6c8fdb459905d97b61 Mon Sep 17 00:00:00 2001 From: Clouds Date: Wed, 18 Aug 2021 15:17:27 +0800 Subject: [PATCH 1/2] fix `Ref{Any}(p::TensorProto)` --- src/read.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/read.jl b/src/read.jl index 0c86c57..2b1e005 100644 --- a/src/read.jl +++ b/src/read.jl @@ -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 """ From ad3dc06babcc41e2803ed4817aa822dfd8c52575 Mon Sep 17 00:00:00 2001 From: Clouds Date: Fri, 20 Aug 2021 13:48:37 +0800 Subject: [PATCH 2/2] fix attribute would change content --- src/read.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/read.jl b/src/read.jl index 2b1e005..3368156 100644 --- a/src/read.jl +++ b/src/read.jl @@ -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