@@ -320,17 +320,17 @@ using OffsetArrays
320
320
x = zeros (100 );
321
321
# R = reshape(view(x, 1:100), (10,10));
322
322
# A = zeros(3,4,5);
323
- A = Wrapper (reshape (view (x, 1 : 60 ), (3 ,4 ,5 )))
323
+ A = Wrapper (reshape (view (x, 1 : 60 ), (3 ,4 ,5 )));
324
324
B = A .== 0 ;
325
- D1 = view (A, 1 : 2 : 3 , :, :) # first dimension is discontiguous
326
- D2 = view (A, :, 2 : 2 : 4 , :) # first dimension is contiguous
325
+ D1 = view (A, 1 : 2 : 3 , :, :); # first dimension is discontiguous
326
+ D2 = view (A, :, 2 : 2 : 4 , :); # first dimension is contiguous
327
327
328
328
@test @inferred (ArrayInterface. defines_strides (x))
329
329
@test @inferred (ArrayInterface. defines_strides (A))
330
330
@test @inferred (ArrayInterface. defines_strides (D1))
331
331
@test ! @inferred (ArrayInterface. defines_strides (view (A, :, [1 ,2 ],1 )))
332
332
@test @inferred (ArrayInterface. defines_strides (DenseWrapper{Int,2 ,Matrix{Int}}))
333
-
333
+
334
334
@test @inferred (device (A)) === ArrayInterface. CPUPointer ()
335
335
@test @inferred (device (B)) === ArrayInterface. CPUIndex ()
336
336
@test @inferred (device (- 1 : 19 )) === ArrayInterface. CPUIndex ()
@@ -346,7 +346,6 @@ using OffsetArrays
346
346
@test @inferred (device (OffsetArray (@MArray (zeros (2 ,2 ,2 )),8 ,- 2 ,- 5 ))) === ArrayInterface. CPUPointer ()
347
347
@test isnothing (device (" Hello, world!" ))
348
348
@test @inferred (device (DenseWrapper{Int,2 ,Matrix{Int}})) === ArrayInterface. CPUPointer ()
349
-
350
349
#=
351
350
@btime ArrayInterface.contiguous_axis($(reshape(view(zeros(100), 1:60), (3,4,5))))
352
351
0.047 ns (0 allocations: 0 bytes)
@@ -372,7 +371,7 @@ using OffsetArrays
372
371
@test @inferred (contiguous_axis (PermutedDimsArray (DummyZeros (3 ,4 ), (2 , 1 )))) === nothing
373
372
@test @inferred (contiguous_axis (view (DummyZeros (3 ,4 ), 1 , :))) === nothing
374
373
@test @inferred (contiguous_axis (view (DummyZeros (3 ,4 ), 1 , :)' )) === nothing
375
-
374
+
376
375
@test @inferred (ArrayInterface. contiguous_axis_indicator (@SArray (zeros (2 ,2 ,2 )))) == (true ,false ,false )
377
376
@test @inferred (ArrayInterface. contiguous_axis_indicator (A)) == (true ,false ,false )
378
377
@test @inferred (ArrayInterface. contiguous_axis_indicator (B)) == (true ,false ,false )
@@ -417,6 +416,8 @@ using OffsetArrays
417
416
@test @inferred (stride_rank (DummyZeros (3 ,4 )' )) === nothing
418
417
@test @inferred (stride_rank (PermutedDimsArray (DummyZeros (3 ,4 ), (2 , 1 )))) === nothing
419
418
@test @inferred (stride_rank (view (DummyZeros (3 ,4 ), 1 , :))) === nothing
419
+
420
+
420
421
#=
421
422
@btime ArrayInterface.is_column_major($(PermutedDimsArray(A,(3,1,2))))
422
423
0.047 ns (0 allocations: 0 bytes)
@@ -478,6 +479,43 @@ using OffsetArrays
478
479
Am = @MMatrix rand (2 ,10 );
479
480
@test @inferred (ArrayInterface. strides (view (Am,1 ,:))) === (StaticInt (2 ),)
480
481
482
+ if VERSION ≥ v " 1.6.0-DEV.1581" # reinterpret(reshape,...) tests
483
+ C1 = reinterpret (reshape, Float64, PermutedDimsArray (Array {Complex{Float64}} (undef, 3 ,4 ,5 ), (2 ,1 ,3 )));
484
+ C2 = reinterpret (reshape, Complex{Float64}, PermutedDimsArray (view (A,1 : 2 ,:,:), (1 ,3 ,2 )));
485
+ C3 = reinterpret (reshape, Complex{Float64}, PermutedDimsArray (Wrapper (reshape (view (x, 1 : 24 ), (2 ,3 ,4 ))), (1 ,3 ,2 )));
486
+
487
+ @test @inferred (ArrayInterface. defines_strides (C1))
488
+ @test @inferred (ArrayInterface. defines_strides (C2))
489
+ @test @inferred (ArrayInterface. defines_strides (C3))
490
+
491
+ @test @inferred (device (C1)) === ArrayInterface. CPUPointer ()
492
+ @test @inferred (device (C2)) === ArrayInterface. CPUPointer ()
493
+ @test @inferred (device (C3)) === ArrayInterface. CPUPointer ()
494
+
495
+ @test @inferred (contiguous_batch_size (C1)) === ArrayInterface. StaticInt (0 )
496
+ @test @inferred (contiguous_batch_size (C2)) === ArrayInterface. StaticInt (0 )
497
+ @test @inferred (contiguous_batch_size (C3)) === ArrayInterface. StaticInt (0 )
498
+
499
+ @test @inferred (stride_rank (C1)) == (1 ,3 ,2 ,4 )
500
+ @test @inferred (stride_rank (C2)) == (2 ,1 )
501
+ @test @inferred (stride_rank (C3)) == (2 ,1 )
502
+
503
+ @test @inferred (contiguous_axis (C1)) === StaticInt (1 )
504
+ @test @inferred (contiguous_axis (C2)) === StaticInt (0 )
505
+ @test @inferred (contiguous_axis (C3)) === StaticInt (2 )
506
+
507
+ @test @inferred (ArrayInterface. contiguous_axis_indicator (C1)) == (true ,false ,false ,false )
508
+ @test @inferred (ArrayInterface. contiguous_axis_indicator (C2)) == (false ,false )
509
+ @test @inferred (ArrayInterface. contiguous_axis_indicator (C3)) == (false ,true )
510
+
511
+ @test @inferred (ArrayInterface. is_column_major (C1)) === False ()
512
+ @test @inferred (ArrayInterface. is_column_major (C2)) === False ()
513
+ @test @inferred (ArrayInterface. is_column_major (C3)) === False ()
514
+
515
+ @test @inferred (dense_dims (C1)) == (true ,true ,true ,true )
516
+ @test @inferred (dense_dims (C2)) == (false ,false )
517
+ @test @inferred (dense_dims (C3)) == (true ,true )
518
+ end
481
519
end
482
520
483
521
@testset " Static-Dynamic Size, Strides, and Offsets" begin
0 commit comments