Skip to content

Conversation

@tam724
Copy link
Contributor

@tam724 tam724 commented Dec 7, 2025

Besides Base.Colon base also uses Base.Slice to indicate complete slices of a dimension (https://github.com/JuliaLang/julia/blob/8fd607a7df9e65ed060c88f32d801c95aa8a573f/base/indices.jl#L382).
For views of GPUArrays, we can treat Slice the same way as Colon and create contiguous arrays (CuArray/.. etc) instead of SubArrays.

Closes JuliaGPU/CUDA.jl#2986

@github-actions
Copy link
Contributor

github-actions bot commented Dec 7, 2025

Your PR requires formatting changes to meet the project's style guidelines.
Please consider running Runic (git runic master) to apply these changes.

Click here to view the suggested changes.
diff --git a/test/testsuite/base.jl b/test/testsuite/base.jl
index 8a5ca85..f6bfd33 100644
--- a/test/testsuite/base.jl
+++ b/test/testsuite/base.jl
@@ -333,19 +333,19 @@ end
       end
 
       @test compare(x->view(x, :, 1:4, 3), AT, rand(Float32, 5, 4, 3))
-      @test compare(x->view(x, Base.Slice(Base.OneTo(5)), 1:4, 3), AT, rand(Float32, 5, 4, 3))
+        @test compare(x -> view(x, Base.Slice(Base.OneTo(5)), 1:4, 3), AT, rand(Float32, 5, 4, 3))
 
       let x = AT(rand(Float32, 5, 4, 3))
         @test_throws BoundsError view(x, :, :, 1:10)
       end
 
-      @testset "selectdim" begin
-        @test compare(x -> selectdim(x, 3, 1), AT, rand(Float32, 2, 2, 2))
-        let x = AT(rand(Float32, 5, 4, 3))
-          @test typeof(selectdim(x, 3, 1)) == typeof(view(x, :, :, 1))         
-          @test typeof(selectdim(x, 2, 1)) == typeof(view(x, :, 1, :))
+        @testset "selectdim" begin
+            @test compare(x -> selectdim(x, 3, 1), AT, rand(Float32, 2, 2, 2))
+            let x = AT(rand(Float32, 5, 4, 3))
+                @test typeof(selectdim(x, 3, 1)) == typeof(view(x, :, :, 1))
+                @test typeof(selectdim(x, 2, 1)) == typeof(view(x, :, 1, :))
+            end
         end
-      end
 
       # bug in parentindices conversion
       let x = AT{Int}(undef, 1, 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Selectdim returns view - CuSparseMatrixCSC defaults to scalar operations on views

1 participant