@@ -303,6 +303,7 @@ using OffsetArrays
303
303
# R = reshape(view(x, 1:100), (10,10));
304
304
# A = zeros(3,4,5);
305
305
A = Wrapper (reshape (view (x, 1 : 60 ), (3 ,4 ,5 )))
306
+ B = A .== 0 ;
306
307
D1 = view (A, 1 : 2 : 3 , :, :) # first dimension is discontiguous
307
308
D2 = view (A, :, 2 : 2 : 4 , :) # first dimension is contiguous
308
309
@@ -312,6 +313,8 @@ using OffsetArrays
312
313
@test ! @inferred (ArrayInterface. defines_strides (view (A, :, [1 ,2 ],1 )))
313
314
314
315
@test @inferred (device (A)) === ArrayInterface. CPUPointer ()
316
+ @test @inferred (device (B)) === ArrayInterface. CPUIndex ()
317
+ @test @inferred (device (- 1 : 19 )) === ArrayInterface. CPUIndex ()
315
318
@test @inferred (device ((1 ,2 ,3 ))) === ArrayInterface. CPUIndex ()
316
319
@test @inferred (device (PermutedDimsArray (A,(3 ,1 ,2 )))) === ArrayInterface. CPUPointer ()
317
320
@test @inferred (device (view (A, 1 , :, 2 : 4 ))) === ArrayInterface. CPUPointer ()
@@ -330,6 +333,8 @@ using OffsetArrays
330
333
=#
331
334
@test @inferred (contiguous_axis (@SArray (zeros (2 ,2 ,2 )))) === ArrayInterface. StaticInt (1 )
332
335
@test @inferred (contiguous_axis (A)) === ArrayInterface. StaticInt (1 )
336
+ @test @inferred (contiguous_axis (B)) === ArrayInterface. StaticInt (1 )
337
+ @test @inferred (contiguous_axis (- 1 : 19 )) === ArrayInterface. StaticInt (1 )
333
338
@test @inferred (contiguous_axis (D1)) === ArrayInterface. StaticInt (- 1 )
334
339
@test @inferred (contiguous_axis (D2)) === ArrayInterface. StaticInt (1 )
335
340
@test @inferred (contiguous_axis (PermutedDimsArray (A,(3 ,1 ,2 )))) === ArrayInterface. StaticInt (2 )
@@ -350,6 +355,8 @@ using OffsetArrays
350
355
351
356
@test @inferred (ArrayInterface. contiguous_axis_indicator (@SArray (zeros (2 ,2 ,2 )))) == (true ,false ,false )
352
357
@test @inferred (ArrayInterface. contiguous_axis_indicator (A)) == (true ,false ,false )
358
+ @test @inferred (ArrayInterface. contiguous_axis_indicator (B)) == (true ,false ,false )
359
+ @test @inferred (ArrayInterface. contiguous_axis_indicator (- 1 : 10 )) == (true ,)
353
360
@test @inferred (ArrayInterface. contiguous_axis_indicator (PermutedDimsArray (A,(3 ,1 ,2 )))) == (false ,true ,false )
354
361
@test @inferred (ArrayInterface. contiguous_axis_indicator (@view (PermutedDimsArray (A,(3 ,1 ,2 ))[2 ,1 : 2 ,:]))) == (true ,false )
355
362
@test @inferred (ArrayInterface. contiguous_axis_indicator (@view (PermutedDimsArray (A,(3 ,1 ,2 ))[2 ,1 : 2 ,:])' )) == (false ,true )
@@ -362,6 +369,8 @@ using OffsetArrays
362
369
363
370
@test @inferred (contiguous_batch_size (@SArray (zeros (2 ,2 ,2 )))) === ArrayInterface. StaticInt (0 )
364
371
@test @inferred (contiguous_batch_size (A)) === ArrayInterface. StaticInt (0 )
372
+ @test @inferred (contiguous_batch_size (B)) === ArrayInterface. StaticInt (0 )
373
+ @test @inferred (contiguous_batch_size (- 1 : 18 )) === ArrayInterface. StaticInt (0 )
365
374
@test @inferred (contiguous_batch_size (PermutedDimsArray (A,(3 ,1 ,2 )))) === ArrayInterface. StaticInt (0 )
366
375
@test @inferred (contiguous_batch_size (@view (PermutedDimsArray (A,(3 ,1 ,2 ))[2 ,1 : 2 ,:]))) === ArrayInterface. StaticInt (0 )
367
376
@test @inferred (contiguous_batch_size (@view (PermutedDimsArray (A,(3 ,1 ,2 ))[2 ,1 : 2 ,:])' )) === ArrayInterface. StaticInt (0 )
@@ -372,6 +381,8 @@ using OffsetArrays
372
381
373
382
@test @inferred (stride_rank (@SArray (zeros (2 ,2 ,2 )))) == (1 , 2 , 3 )
374
383
@test @inferred (stride_rank (A)) == (1 ,2 ,3 )
384
+ @test @inferred (stride_rank (B)) == (1 ,2 ,3 )
385
+ @test @inferred (stride_rank (- 4 : 4 )) == (1 ,)
375
386
@test @inferred (stride_rank (view (A,:,:,1 ))) === (static (1 ), static (2 ))
376
387
@test @inferred (stride_rank (view (A,:,:,1 ))) === ((ArrayInterface. StaticInt (1 ),ArrayInterface. StaticInt (2 )))
377
388
@test @inferred (stride_rank (PermutedDimsArray (A,(3 ,1 ,2 )))) == (3 , 1 , 2 )
@@ -400,6 +411,8 @@ using OffsetArrays
400
411
401
412
@test @inferred (ArrayInterface. is_column_major (@SArray (zeros (2 ,2 ,2 )))) === True ()
402
413
@test @inferred (ArrayInterface. is_column_major (A)) === True ()
414
+ @test @inferred (ArrayInterface. is_column_major (B)) === True ()
415
+ @test @inferred (ArrayInterface. is_column_major (- 4 : 7 )) === False ()
403
416
@test @inferred (ArrayInterface. is_column_major (PermutedDimsArray (A,(3 ,1 ,2 )))) === False ()
404
417
@test @inferred (ArrayInterface. is_column_major (@view (PermutedDimsArray (A,(3 ,1 ,2 ))[2 ,1 : 2 ,:]))) === True ()
405
418
@test @inferred (ArrayInterface. is_column_major (@view (PermutedDimsArray (A,(3 ,1 ,2 ))[2 ,1 : 2 ,:])' )) === False ()
@@ -408,11 +421,12 @@ using OffsetArrays
408
421
@test @inferred (ArrayInterface. is_column_major (@view (PermutedDimsArray (A,(3 ,1 ,2 ))[2 : 3 ,2 ,:])' )) === True ()
409
422
@test @inferred (ArrayInterface. is_column_major (@view (PermutedDimsArray (A,(3 ,1 ,2 ))[:,1 : 2 ,1 ])' )) === True ()
410
423
@test @inferred (ArrayInterface. is_column_major (@view (PermutedDimsArray (A,(3 ,1 ,2 ))[:,2 ,1 ])' )) === False ()
411
- @test @inferred (ArrayInterface. is_column_major (1 : 10 )) === False ()
412
424
@test @inferred (ArrayInterface. is_column_major (2.3 )) === False ()
413
425
414
426
@test @inferred (dense_dims (@SArray (zeros (2 ,2 ,2 )))) == (true ,true ,true )
415
427
@test @inferred (dense_dims (A)) == (true ,true ,true )
428
+ @test @inferred (dense_dims (B)) == (true ,true ,true )
429
+ @test @inferred (dense_dims (- 3 : 9 )) == (true ,)
416
430
@test @inferred (dense_dims (PermutedDimsArray (A,(3 ,1 ,2 )))) == (true ,true ,true )
417
431
@test @inferred (dense_dims (@view (PermutedDimsArray (A,(3 ,1 ,2 ))[2 ,1 : 2 ,:]))) == (true ,false )
418
432
@test @inferred (dense_dims (@view (PermutedDimsArray (A,(3 ,1 ,2 ))[2 ,1 : 2 ,:])' )) == (false ,true )
@@ -434,9 +448,9 @@ using OffsetArrays
434
448
@test @inferred (dense_dims (view (DummyZeros (3 ,4 ), :, 1 ))) === nothing
435
449
@test @inferred (dense_dims (view (DummyZeros (3 ,4 ), :, 1 )' )) === nothing
436
450
437
- B = Array {Int8} (undef, 2 ,2 ,2 ,2 );
438
- doubleperm = PermutedDimsArray (PermutedDimsArray (B ,(4 ,2 ,3 ,1 )), (4 ,2 ,1 ,3 ));
439
- @test collect (strides (B ))[collect (stride_rank (doubleperm))] == collect (strides (doubleperm))
451
+ C = Array {Int8} (undef, 2 ,2 ,2 ,2 );
452
+ doubleperm = PermutedDimsArray (PermutedDimsArray (C ,(4 ,2 ,3 ,1 )), (4 ,2 ,1 ,3 ));
453
+ @test collect (strides (C ))[collect (stride_rank (doubleperm))] == collect (strides (doubleperm))
440
454
441
455
@test @inferred (ArrayInterface. indices (OffsetArray (view (PermutedDimsArray (A, (3 ,1 ,2 )), 1 , :, 2 : 4 )' , 3 , - 173 ),1 )) === Base. Slice (ArrayInterface. OptionallyStaticUnitRange (4 ,6 ))
442
456
@test @inferred (ArrayInterface. indices (OffsetArray (view (PermutedDimsArray (A, (3 ,1 ,2 )), 1 , :, 2 : 4 )' , 3 , - 173 ),2 )) === Base. Slice (ArrayInterface. OptionallyStaticUnitRange (- 172 ,- 170 ))
0 commit comments