@@ -532,6 +532,48 @@ func.func @test_slice(%arg0 : tensor<?xi32>) -> () {
532532
533533// -----
534534
535+ // CHECK-LABEL: @test_slice_size_minus_one
536+ func.func @test_slice_size_minus_one (%arg0 : tensor <?x8 x8 x8 xi32 >) -> () {
537+ // CHECK: tosa.slice %arg0 {size = array<i64: -1, -1, -1, -1>, start = array<i64: 0, 1, -1, 8>} : (tensor<?x8x8x8xi32>) -> tensor<?x7x?x?xi32>
538+ // this checks following
539+ // dim 0: size=-1, input dim=? => inferred output dim is ?
540+ // dim 1: size=-1 => inferred output dim is input_dim - start
541+ // dim 2: size=-1, start=-1 => inferred output dim is ?
542+ // dim 3: size=-1, start=8 => inferred output dim is ? because start is out of bound
543+ %2 = tosa.slice %arg0 { start = array<i64 : 0 , 1 , -1 , 8 >, size = array<i64 : -1 , -1 , -1 , -1 > } : (tensor <?x8 x8 x8 xi32 >) -> tensor <?x?x?x?xi32 >
544+ return
545+ }
546+
547+ // -----
548+
549+ // CHECK-LABEL: @test_slice_size_out_of_bound
550+ func.func @test_slice_size_out_of_bound (%arg0 : tensor <8 x8 x8 x?xi32 >) -> () {
551+ // CHECK: tosa.slice %arg0 {size = array<i64: 0, -2, 9, 4>, start = array<i64: 0, 0, 0, 0>} : (tensor<8x8x8x?xi32>) -> tensor<?x?x?x4xi32>
552+ // this checks following
553+ // dim 0: size=0 => inferred output dim is ?
554+ // dim 1: size=-2 => inferred output dim is ?
555+ // dim 3: start+size out of bound because size too big: inferred output dim is ?
556+ // dim 4: size=4, input dim=? => inferred output dim is 4
557+ %2 = tosa.slice %arg0 { start = array<i64 : 0 , 0 , 0 , 0 >, size = array<i64 : 0 , -2 , 9 , 4 > } : (tensor <8 x8 x8 x?xi32 >) -> tensor <?x?x?x?xi32 >
558+ return
559+ }
560+
561+ // -----
562+
563+ // CHECK-LABEL: @test_slice_start_out_of_bound
564+ func.func @test_slice_start_out_of_bound (%arg0 : tensor <8 x8 x8 x?xi32 >) -> () {
565+ // CHECK: tosa.slice %arg0 {size = array<i64: 1, 1, 3, 4>, start = array<i64: -1, 8, 6, 8000000>} : (tensor<8x8x8x?xi32>) -> tensor<?x?x?x4xi32>
566+ // this checks following
567+ // dim 0: start=-1 => inferred output dim is ?
568+ // dim 1: start=8 => inferred output dim is ?
569+ // dim 2: start+size out of bound: inferred output dim is ?
570+ // dim 3: start=8000000, size=4, input dim=? => inferred output dim is 4
571+ %2 = tosa.slice %arg0 { start = array<i64 : -1 , 8 , 6 , 8000000 >, size = array<i64 : 1 , 1 , 3 , 4 > } : (tensor <8 x8 x8 x?xi32 >) -> tensor <?x?x?x?xi32 >
572+ return
573+ }
574+
575+ // -----
576+
535577// CHECK-LABEL: @test_slice_dynamic
536578func.func @test_slice_dynamic (%arg0 : tensor <10 x?x2 xf32 >) -> () {
537579 // CHECK: tosa.slice %arg0 {size = array<i64: 7, -1, 1>, start = array<i64: 1, 0, 0>} : (tensor<10x?x2xf32>) -> tensor<7x?x1xf32>
0 commit comments