Stream: helpdesk (published)

Topic: Abstract type for GPU Arrays


view this post on Zulip Dale Black (Nov 01 2023 at 23:45):

Is there any abstract type that is a catch-all for GPU arrays? I want to use multiple dispatch on some function that works on Metal or CUDA or AMDGPU and on the CPU works slightly differently. E.g.

function foo(f::AbstractArray)
    return f .+ 1
end

function foo(f::GPUArray)
    return f .+ 2
end

I could rewrite the functions for all of the GPU backends but that seems like a pain if it's not needed

function foo(f::MtlArray)
    return f .+ 2
end

function foo(f::CuArray)
    return f .+ 2
end

...

view this post on Zulip Michael Abbott (Nov 02 2023 at 00:54):

I think you want https://docs.juliahub.com/GPUArraysCore/qiYUe/0.1.2/autodocs/#GPUArraysCore.AbstractGPUArray

view this post on Zulip Dale Black (Nov 02 2023 at 01:18):

I’m away from my computer right now but that looks like it’s exactly what I want


Last updated: Dec 28 2024 at 04:38 UTC