Skip to content

Unexpected behavior of deepcopy of an OffsetArray{<:Any, <:Any, <:MtlArray} #523

@simone-silvestri

Description

@simone-silvestri

Playing around with Metal I can across some unexpected behavior with OffsetArrays of MtlArrays concerning deepcopy:

julia> a = MtlArray(zeros(Float32, 2));

julia> a = OffsetArray(a, -1);

julia> b = deepcopy(a);

julia> fill!(b, 1);

julia> a
2-element OffsetArray(::MtlVector{Float32, Metal.PrivateStorage}, 0:1) with eltype Float32 with indices 0:1:
 1.0
 1.0

Note that this does not happen on pure MtlArrays

julia> a = MtlArray(zeros(Float32, 2));

julia> b = deepcopy(a);

julia> fill!(b, 1);

julia> a
4-element OffsetArray(::MtlVector{Float32, Metal.PrivateStorage}, 0:3) with eltype Float32 with indices 0:3:
 0.0
 0.0

Nor with OffsetArrays of other types:

julia> a = OffsetArray(zeros(2), -1);

julia> b = deepcopy(a);

julia> fill!(b, 1);

julia> a
2-element OffsetArray(::Vector{Float64}, 0:1) with eltype Float64 with indices 0:1:
 0.0
 0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    arraysThings about the array abstraction.good first issueGood for newcomers

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions