@@ -324,18 +324,12 @@ using OffsetArrays
324324 B = A .== 0 ;
325325 D1 = view (A, 1 : 2 : 3 , :, :); # first dimension is discontiguous
326326 D2 = view (A, :, 2 : 2 : 4 , :); # first dimension is contiguous
327- C1 = reinterpret (reshape, Float64, PermutedDimsArray (Array {Complex{Float64}} (undef, 3 ,4 ,5 ), (2 ,1 ,3 )));
328- C2 = reinterpret (reshape, Complex{Float64}, PermutedDimsArray (view (A,1 : 2 ,:,:), (1 ,3 ,2 )));
329- C3 = reinterpret (reshape, Complex{Float64}, PermutedDimsArray (Wrapper (reshape (view (x, 1 : 24 ), (2 ,3 ,4 ))), (1 ,3 ,2 )));
330327
331328 @test @inferred (ArrayInterface. defines_strides (x))
332329 @test @inferred (ArrayInterface. defines_strides (A))
333330 @test @inferred (ArrayInterface. defines_strides (D1))
334331 @test ! @inferred (ArrayInterface. defines_strides (view (A, :, [1 ,2 ],1 )))
335332 @test @inferred (ArrayInterface. defines_strides (DenseWrapper{Int,2 ,Matrix{Int}}))
336- @test @inferred (ArrayInterface. defines_strides (C1))
337- @test @inferred (ArrayInterface. defines_strides (C2))
338- @test @inferred (ArrayInterface. defines_strides (C3))
339333
340334 @test @inferred (device (A)) === ArrayInterface. CPUPointer ()
341335 @test @inferred (device (B)) === ArrayInterface. CPUIndex ()
@@ -352,9 +346,6 @@ using OffsetArrays
352346 @test @inferred (device (OffsetArray (@MArray (zeros (2 ,2 ,2 )),8 ,- 2 ,- 5 ))) === ArrayInterface. CPUPointer ()
353347 @test isnothing (device (" Hello, world!" ))
354348 @test @inferred (device (DenseWrapper{Int,2 ,Matrix{Int}})) === ArrayInterface. CPUPointer ()
355- @test @inferred (device (C1)) === ArrayInterface. CPUPointer ()
356- @test @inferred (device (C2)) === ArrayInterface. CPUPointer ()
357- @test @inferred (device (C3)) === ArrayInterface. CPUPointer ()
358349 #=
359350 @btime ArrayInterface.contiguous_axis($(reshape(view(zeros(100), 1:60), (3,4,5))))
360351 0.047 ns (0 allocations: 0 bytes)
@@ -380,9 +371,6 @@ using OffsetArrays
380371 @test @inferred (contiguous_axis (PermutedDimsArray (DummyZeros (3 ,4 ), (2 , 1 )))) === nothing
381372 @test @inferred (contiguous_axis (view (DummyZeros (3 ,4 ), 1 , :))) === nothing
382373 @test @inferred (contiguous_axis (view (DummyZeros (3 ,4 ), 1 , :)' )) === nothing
383- @test @inferred (contiguous_axis (C1)) === StaticInt (1 )
384- @test @inferred (contiguous_axis (C2)) === StaticInt (0 )
385- @test @inferred (contiguous_axis (C3)) === StaticInt (2 )
386374
387375 @test @inferred (ArrayInterface. contiguous_axis_indicator (@SArray (zeros (2 ,2 ,2 )))) == (true ,false ,false )
388376 @test @inferred (ArrayInterface. contiguous_axis_indicator (A)) == (true ,false ,false )
@@ -397,9 +385,6 @@ using OffsetArrays
397385 @test @inferred (ArrayInterface. contiguous_axis_indicator (@view (PermutedDimsArray (A,(3 ,1 ,2 ))[:,1 : 2 ,1 ])' )) == (true ,false )
398386 @test @inferred (ArrayInterface. contiguous_axis_indicator (@view (PermutedDimsArray (A,(3 ,1 ,2 ))[:,1 : 2 ,[1 ,3 ,4 ]]))) == (false ,true ,false )
399387 @test @inferred (ArrayInterface. contiguous_axis_indicator (DummyZeros (3 ,4 ))) === nothing
400- @test @inferred (ArrayInterface. contiguous_axis_indicator (C1)) == (true ,false ,false ,false )
401- @test @inferred (ArrayInterface. contiguous_axis_indicator (C2)) == (false ,false )
402- @test @inferred (ArrayInterface. contiguous_axis_indicator (C3)) == (false ,true )
403388
404389 @test @inferred (contiguous_batch_size (@SArray (zeros (2 ,2 ,2 )))) === ArrayInterface. StaticInt (0 )
405390 @test @inferred (contiguous_batch_size (A)) === ArrayInterface. StaticInt (0 )
@@ -412,9 +397,6 @@ using OffsetArrays
412397 @test @inferred (contiguous_batch_size (@view (PermutedDimsArray (A,(3 ,1 ,2 ))[2 : 3 ,2 ,:]))) === ArrayInterface. StaticInt (- 1 )
413398 @test @inferred (contiguous_batch_size (@view (PermutedDimsArray (A,(3 ,1 ,2 ))[2 : 3 ,2 ,:])' )) === ArrayInterface. StaticInt (- 1 )
414399 @test @inferred (contiguous_batch_size (@view (PermutedDimsArray (A,(3 ,1 ,2 ))[:,1 : 2 ,1 ])' )) === ArrayInterface. StaticInt (0 )
415- @test @inferred (contiguous_batch_size (C1)) === ArrayInterface. StaticInt (0 )
416- @test @inferred (contiguous_batch_size (C2)) === ArrayInterface. StaticInt (0 )
417- @test @inferred (contiguous_batch_size (C3)) === ArrayInterface. StaticInt (0 )
418400
419401 @test @inferred (stride_rank (@SArray (zeros (2 ,2 ,2 )))) == (1 , 2 , 3 )
420402 @test @inferred (stride_rank (A)) == (1 ,2 ,3 )
@@ -434,9 +416,6 @@ using OffsetArrays
434416 @test @inferred (stride_rank (DummyZeros (3 ,4 )' )) === nothing
435417 @test @inferred (stride_rank (PermutedDimsArray (DummyZeros (3 ,4 ), (2 , 1 )))) === nothing
436418 @test @inferred (stride_rank (view (DummyZeros (3 ,4 ), 1 , :))) === nothing
437- @test @inferred (stride_rank (C1)) == (1 ,3 ,2 ,4 )
438- @test @inferred (stride_rank (C2)) == (2 ,1 )
439- @test @inferred (stride_rank (C3)) == (2 ,1 )
440419
441420
442421 #=
@@ -464,9 +443,6 @@ using OffsetArrays
464443 @test @inferred (ArrayInterface. is_column_major (@view (PermutedDimsArray (A,(3 ,1 ,2 ))[:,1 : 2 ,1 ])' )) === True ()
465444 @test @inferred (ArrayInterface. is_column_major (@view (PermutedDimsArray (A,(3 ,1 ,2 ))[:,2 ,1 ])' )) === False ()
466445 @test @inferred (ArrayInterface. is_column_major (2.3 )) === False ()
467- @test @inferred (ArrayInterface. is_column_major (C1)) === False ()
468- @test @inferred (ArrayInterface. is_column_major (C2)) === False ()
469- @test @inferred (ArrayInterface. is_column_major (C3)) === False ()
470446
471447 @test @inferred (dense_dims (@SArray (zeros (2 ,2 ,2 )))) == (true ,true ,true )
472448 @test @inferred (dense_dims (A)) == (true ,true ,true )
@@ -492,9 +468,6 @@ using OffsetArrays
492468 @test @inferred (dense_dims (PermutedDimsArray (DummyZeros (3 ,4 ), (2 , 1 )))) === nothing
493469 @test @inferred (dense_dims (view (DummyZeros (3 ,4 ), :, 1 ))) === nothing
494470 @test @inferred (dense_dims (view (DummyZeros (3 ,4 ), :, 1 )' )) === nothing
495- @test @inferred (dense_dims (C1)) == (true ,true ,true ,true )
496- @test @inferred (dense_dims (C2)) == (false ,false )
497- @test @inferred (dense_dims (C3)) == (true ,true )
498471
499472 C = Array {Int8} (undef, 2 ,2 ,2 ,2 );
500473 doubleperm = PermutedDimsArray (PermutedDimsArray (C,(4 ,2 ,3 ,1 )), (4 ,2 ,1 ,3 ));
@@ -506,6 +479,43 @@ using OffsetArrays
506479 Am = @MMatrix rand (2 ,10 );
507480 @test @inferred (ArrayInterface. strides (view (Am,1 ,:))) === (StaticInt (2 ),)
508481
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
509519end
510520
511521@testset " Static-Dynamic Size, Strides, and Offsets" begin
0 commit comments