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

copy!(::Memory{Int}, ::Vector{Int}) causes JET warnings #56634

Open
nsajko opened this issue Nov 21, 2024 · 1 comment
Open

copy!(::Memory{Int}, ::Vector{Int}) causes JET warnings #56634

nsajko opened this issue Nov 21, 2024 · 1 comment
Labels
arrays [a, r, r, a, y, s]

Comments

@nsajko
Copy link
Contributor

nsajko commented Nov 21, 2024

julia> using JET

julia> report_opt(copy!, Tuple{Memory{Int}, Vector{Int}})
═════ 1 possible error found ═════
┌ copy!(dst::Memory{Int64}, src::Vector{Int64}) @ Base ./abstractarray.jl:914
│ runtime dispatch detected: resize!(dst::Memory{Int64}, %12::Int64)
└────────────────────


julia> report_call(copy!, Tuple{Memory{Int}, Vector{Int}})
═════ 1 possible error found ═════
┌ copy!(dst::Memory{Int64}, src::Vector{Int64}) @ Base ./abstractarray.jl:914
│ no matching method found `resize!(::Memory{Int64}, ::Int64)`: resize!(dst::Memory{Int64}, length(src::Vector{Int64})::Int64)
└────────────────────

Should copy! get a specialized method, given that it's not resizable?

The workaround is to call copyto! instead.

@nsajko nsajko added the arrays [a, r, r, a, y, s] label Nov 21, 2024
@nsajko nsajko changed the title copy!(::Memory{Int}, ::Vector{Int}) causes JET warnings since v1.11 copy!(::Memory{Int}, ::Vector{Int}) causes JET warnings Nov 21, 2024
@aviatesk
Copy link
Member

This seems to be more of a design issue with Memory rather than a problem with JET?
Memory is an AbstractVector, but since its size is fixed, it doesn’t support resize!.
Defining a method like resize(::Memory) = error("Memory isn't resizable") could silence JET while also providing a clear error message for users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrays [a, r, r, a, y, s]
Projects
None yet
Development

No branches or pull requests

2 participants