mcabbott / mcabbott/TensorCast.jl
Slices and CuArrays
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 142
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Description
@MasonProtter points out that, somewhat to my surprise, mapslices-like things work on the GPU:
julia> using Zygote, TensorCast, CuArrays, BenchmarkTools
julia> CuArrays.allowscalar(false)
julia> let X = randn(10, 10, 10, 10, 10)
Xcu = cu(X)
f(A::AbstractArray{T, 4}) where {T} = reshape(sum(A, dims=(3,4)), size(A,1), size(A, 2))
g(X) = @cast y[i, j, k] := f(X[:, :, :, :, k])[i, j]
h_cu(a) = sum(g(a * Xcu))
h_cpu(a)= sum(g(a * X))
@show length(X)
@btime $h_cu'(1)
@btime $h_cpu'(1)
end
length(X) = 100000
1.660 ms (4676 allocations: 200.19 KiB)
747.911 μs (374 allocations: 3.84 MiB)
351.3479618616162
julia> @pretty @cast y[i, j, k] := f(X[:, :, :, :, k])[i, j]
begin
local armadillo = sliceview(X, (:, :, :, :, *))
local porpoise = @__dot__(f(armadillo))
local jaguar = red_glue(porpoise, (:, :, *))
y = jaguar
end
It would be nice to (1) make sure this doesn't break, e.g. with #17, (2) understand which cases work or whether some don't, and (3) ideally make it fast?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the Julia GPU reproduction in the issue and inspect the @cast expansion through sliceview, @dot, and red_glue. Check the cases that work or fail, including compatibility with #17, then verify that supported CuArrays paths remain correct and assess whether the generated operations can be made faster.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- performance, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100