From 8e06259dc4d13b3f91bcd1383cefc9821aa3a0b6 Mon Sep 17 00:00:00 2001 From: Joe Greener Date: Wed, 3 Aug 2022 15:53:55 +0100 Subject: [PATCH] test repeated indexing --- test/cuda.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/cuda.jl b/test/cuda.jl index 5cb1c8cdc..403ff553a 100644 --- a/test/cuda.jl +++ b/test/cuda.jl @@ -140,3 +140,9 @@ end @test_skip gradient((x,y) -> sum(vcat(x,y)), 1f0, r, 2f0, r)[2] isa CUDA.CuArray{Float32} end +@testset "repeated indexing" begin + f(a) = sum(view(a, [1, 1, 2])) + a = CUDA.CuArray([1.0f0, 1.0f0, 1.0f0]) + @test f(a) == 3.0f0 + @test Array(gradient(f, a)[1]) == [2.0f0, 1.0f0, 0.0f0] +end