@@ -686,6 +686,48 @@ func.func @test_cond_if_incorrect_type_simple(%arg0: tensor<f32>, %arg1: tensor<
686
686
return %0 : tensor <f32 >
687
687
}
688
688
689
+ // -----
690
+ func.func @test_while_loop_wrong_terminator (%arg0: tensor <i32 >, %arg1: tensor <i32 >) -> tensor <i32 > {
691
+ %0 = tosa.while_loop (%arg2 = %arg0 ) : (tensor <i32 >) -> tensor <i32 > {
692
+ // expected-error@+2 {{'func.return' op expects parent op 'func.func'}}
693
+ %1 = tosa.greater_equal %arg1 , %arg2 : (tensor <i32 >, tensor <i32 >) -> tensor <i1 >
694
+ " func.return" (%arg2 ) : (tensor <i32 >) -> ()
695
+ } do {
696
+ ^bb0 (%arg2: tensor <i32 >):
697
+ %1 = " tosa.const" () <{values = dense <1 > : tensor <i32 >}> : () -> tensor <i32 >
698
+ %2 = tosa.add %arg2 , %1 : (tensor <i32 >, tensor <i32 >) -> tensor <i32 >
699
+ tosa.yield %2 : tensor <i32 >
700
+ }
701
+ return %0 : tensor <i32 >
702
+ }
703
+
704
+ // -----
705
+ func.func @test_while_loop_missing_cond_terminator (%arg0: tensor <i32 >, %arg1: tensor <i32 >) -> tensor <i32 > {
706
+ %0 = tosa.while_loop (%arg2 = %arg0 ) : (tensor <i32 >) -> tensor <i32 > {
707
+ // expected-error@+1 {{block with no terminator}}
708
+ %1 = tosa.greater_equal %arg1 , %arg2 : (tensor <i32 >, tensor <i32 >) -> tensor <i1 >
709
+ } do {
710
+ ^bb0 (%arg2: tensor <i32 >):
711
+ %1 = " tosa.const" () <{values = dense <1 > : tensor <i32 >}> : () -> tensor <i32 >
712
+ %2 = tosa.add %arg2 , %1 : (tensor <i32 >, tensor <i32 >) -> tensor <i32 >
713
+ tosa.yield %2 : tensor <i32 >
714
+ }
715
+ return %0 : tensor <i32 >
716
+ }
717
+
718
+ // -----
719
+ func.func @test_while_loop_missing_body_terminator (%arg0: tensor <i32 >, %arg1: tensor <i32 >) -> tensor <i32 > {
720
+ %0 = tosa.while_loop (%arg2 = %arg0 ) : (tensor <i32 >) -> tensor <i32 > {
721
+ %1 = tosa.greater_equal %arg1 , %arg2 : (tensor <i32 >, tensor <i32 >) -> tensor <i1 >
722
+ tosa.yield %1 : tensor <i1 >
723
+ } do {
724
+ ^bb0 (%arg2: tensor <i32 >):
725
+ // expected-error@+1 {{block with no terminator}}
726
+ %1 = " tosa.const" () <{values = dense <1 > : tensor <i32 >}> : () -> tensor <i32 >
727
+ }
728
+ return %0 : tensor <i32 >
729
+ }
730
+
689
731
// -----
690
732
691
733
func.func @test_while_loop_input_list_mismatch_body_block_in (%arg0: tensor <10 xi32 >, %arg1: tensor <i32 >) {
0 commit comments