Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
simone-silvestri opened this issue Jan 22, 2025 · 1 comment
Labels
arrays Things about the array abstraction. good first issue Good for newcomers

Comments

@simone-silvestri
Copy link

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
@maleadt maleadt added good first issue Good for newcomers arrays Things about the array abstraction. labels Feb 20, 2025
@maleadt
Copy link
Member

maleadt commented Feb 20, 2025

Seems to work with this definition: https://github.com/JuliaGPU/CUDA.jl/blob/2bf90de1dce7fd58d6ad6cf6b8ff4525e0ad6961/src/array.jl#L180-L183

I wonder if we could move this to GPUArrays? Mind taking a stab at this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrays Things about the array abstraction. good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants