11// RUN: onnf-opt --shape-inference %s -split-input-file | FileCheck %s 
22
3+ //===----------------------------------------------------------------------===// 
34/// Test the default behavior of transpose when no information for the 
4- /// permutation of the axes is provided. 
5+ /// permutation of the axes is provided and when a permutation is provided. 
6+ //===----------------------------------------------------------------------===// 
7+ 
58func  @test_default_transpose (%arg0  : tensor <5 x5 x1 x32 xf32 >) -> tensor <*xf32 > {
69  %0  = " onnx.Transpose"  (%arg0 ) : (tensor <5 x5 x1 x32 xf32 >) -> tensor <*xf32 >
710  " std.return"  (%0 ) : (tensor <*xf32 >) -> ()
@@ -12,11 +15,137 @@ func @test_default_transpose(%arg0 : tensor<5x5x1x32xf32>) -> tensor<*xf32> {
1215// CHECK: return [[RES]] : tensor<32x1x5x5xf32> 
1316
1417/// Test shape inference for transposition when perm attribute is specified. 
18+ 
1519func  @test_transpose (%arg0  : tensor <5 x5 x1 x32 xf32 >) -> tensor <*xf32 > {
1620  %0  = " onnx.Transpose"  (%arg0 ) {perm  = [2 , 0 , 3 , 1 ]} : (tensor <5 x5 x1 x32 xf32 >) -> tensor <*xf32 >
1721  " std.return"  (%0 ) : (tensor <*xf32 >) -> ()
1822}
1923
2024// CHECK-LABEL: test_transpose 
2125// CHECK: [[RES_ATTR:%.+]] = "onnx.Transpose"(%arg0) {perm = [2, 0, 3, 1]} : (tensor<5x5x1x32xf32>) -> tensor<1x5x32x5xf32> 
22- // CHECK: return [[RES_ATTR]] : tensor<1x5x32x5xf32> 
26+ // CHECK: return [[RES_ATTR]] : tensor<1x5x32x5xf32> 
27+ 
28+ //===----------------------------------------------------------------------===// 
29+ /// Test shape inference for ConvNoBias operation and all its attributes. 
30+ //===----------------------------------------------------------------------===// 
31+ 
32+ /// Default and required attributes. 
33+ 
34+ func  @test_conv_no_bias_1 (%arg0  : tensor <1 x2 x32 x64 xf32 >, %arg1  : tensor <5 x2 x6 x7 xf32 >) -> tensor <*xf32 > {
35+   %0  = " onnx.ConvNoBias"  (%arg0 , %arg1 ) {auto_pad  = " NOTSET"  , group  = 1  : i32 } : (tensor <1 x2 x32 x64 xf32 >, tensor <5 x2 x6 x7 xf32 >) -> tensor <*xf32 >
36+   " std.return"  (%0 ) : (tensor <*xf32 >) -> ()
37+ }
38+ 
39+ // CHECK-LABEL: test_conv_no_bias_1 
40+ // CHECK: [[RES_ATTR:%.+]] = "onnx.ConvNoBias"(%arg0, %arg1) {auto_pad = "NOTSET", group = 1 : i32} : (tensor<1x2x32x64xf32>, tensor<5x2x6x7xf32>) -> tensor<1x5x27x58xf32> 
41+ // CHECK: return [[RES_ATTR]] : tensor<1x5x27x58xf32> 
42+ 
43+ /// kernel_shape attribute. 
44+ 
45+ func  @test_conv_no_bias_2 (%arg0  : tensor <1 x2 x32 x64 xf32 >, %arg1  : tensor <5 x2 x6 x7 xf32 >) -> tensor <*xf32 > {
46+   %0  = " onnx.ConvNoBias"  (%arg0 , %arg1 ) {auto_pad  = " NOTSET"  , group  = 1  : i32 , kernel_shape  = [8 , 9 ]} : (tensor <1 x2 x32 x64 xf32 >, tensor <5 x2 x6 x7 xf32 >) -> tensor <*xf32 >
47+   " std.return"  (%0 ) : (tensor <*xf32 >) -> ()
48+ }
49+ 
50+ // CHECK-LABEL: test_conv_no_bias_2 
51+ // CHECK: [[RES_ATTR:%.+]] = "onnx.ConvNoBias"(%arg0, %arg1) {auto_pad = "NOTSET", group = 1 : i32, kernel_shape = [8, 9]} : (tensor<1x2x32x64xf32>, tensor<5x2x6x7xf32>) -> tensor<1x5x25x56xf32> 
52+ // CHECK: return [[RES_ATTR]] : tensor<1x5x25x56xf32> 
53+ 
54+ /// pads attribute. 
55+ /// Use pads to make output size equal to input size by adding K - 1 to the result. 
56+ 
57+ func  @test_conv_no_bias_3 (%arg0  : tensor <1 x2 x32 x64 xf32 >, %arg1  : tensor <5 x2 x6 x10 xf32 >) -> tensor <*xf32 > {
58+   %0  = " onnx.ConvNoBias"  (%arg0 , %arg1 ) {auto_pad  = " NOTSET"  , group  = 1  : i32 , pads  = [2 , 4 , 3 , 5 ]} : (tensor <1 x2 x32 x64 xf32 >, tensor <5 x2 x6 x10 xf32 >) -> tensor <*xf32 >
59+   " std.return"  (%0 ) : (tensor <*xf32 >) -> ()
60+ }
61+ 
62+ // CHECK-LABEL: test_conv_no_bias_3 
63+ // CHECK: [[RES_ATTR:%.+]] = "onnx.ConvNoBias"(%arg0, %arg1) {auto_pad = "NOTSET", group = 1 : i32, pads = [2, 4, 3, 5]} : (tensor<1x2x32x64xf32>, tensor<5x2x6x10xf32>) -> tensor<1x5x32x64xf32> 
64+ // CHECK: return [[RES_ATTR]] : tensor<1x5x32x64xf32> 
65+ 
66+ /// auto_pad set to SAME_UPPER and SAME_LOWER. 
67+ 
68+ func  @test_conv_no_bias_4 (%arg0  : tensor <1 x2 x32 x64 xf32 >, %arg1  : tensor <5 x2 x6 x10 xf32 >) -> tensor <*xf32 > {
69+   %0  = " onnx.ConvNoBias"  (%arg0 , %arg1 ) {auto_pad  = " SAME_UPPER"  , group  = 1  : i32 } : (tensor <1 x2 x32 x64 xf32 >, tensor <5 x2 x6 x10 xf32 >) -> tensor <*xf32 >
70+   " std.return"  (%0 ) : (tensor <*xf32 >) -> ()
71+ }
72+ 
73+ // CHECK-LABEL: test_conv_no_bias_4 
74+ // CHECK: [[RES_ATTR:%.+]] = "onnx.ConvNoBias"(%arg0, %arg1) {auto_pad = "SAME_UPPER", group = 1 : i32} : (tensor<1x2x32x64xf32>, tensor<5x2x6x10xf32>) -> tensor<1x5x32x64xf32> 
75+ // CHECK: return [[RES_ATTR]] : tensor<1x5x32x64xf32> 
76+ 
77+ func  @test_conv_no_bias_5 (%arg0  : tensor <1 x2 x32 x64 xf32 >, %arg1  : tensor <5 x2 x6 x10 xf32 >) -> tensor <*xf32 > {
78+   %0  = " onnx.ConvNoBias"  (%arg0 , %arg1 ) {auto_pad  = " SAME_LOWER"  , group  = 1  : i32 } : (tensor <1 x2 x32 x64 xf32 >, tensor <5 x2 x6 x10 xf32 >) -> tensor <*xf32 >
79+   " std.return"  (%0 ) : (tensor <*xf32 >) -> ()
80+ }
81+ 
82+ // CHECK-LABEL: test_conv_no_bias_5 
83+ // CHECK: [[RES_ATTR:%.+]] = "onnx.ConvNoBias"(%arg0, %arg1) {auto_pad = "SAME_LOWER", group = 1 : i32} : (tensor<1x2x32x64xf32>, tensor<5x2x6x10xf32>) -> tensor<1x5x32x64xf32> 
84+ // CHECK: return [[RES_ATTR]] : tensor<1x5x32x64xf32> 
85+ 
86+ /// auto_pad set to VALID. 
87+ 
88+ func  @test_conv_no_bias_6 (%arg0  : tensor <1 x2 x32 x64 xf32 >, %arg1  : tensor <5 x2 x6 x10 xf32 >) -> tensor <*xf32 > {
89+   %0  = " onnx.ConvNoBias"  (%arg0 , %arg1 ) {auto_pad  = " VALID"  , group  = 1  : i32 } : (tensor <1 x2 x32 x64 xf32 >, tensor <5 x2 x6 x10 xf32 >) -> tensor <*xf32 >
90+   " std.return"  (%0 ) : (tensor <*xf32 >) -> ()
91+ }
92+ 
93+ // CHECK-LABEL: test_conv_no_bias_6 
94+ // CHECK: [[RES_ATTR:%.+]] = "onnx.ConvNoBias"(%arg0, %arg1) {auto_pad = "VALID", group = 1 : i32} : (tensor<1x2x32x64xf32>, tensor<5x2x6x10xf32>) -> tensor<1x5x27x55xf32> 
95+ // CHECK: return [[RES_ATTR]] : tensor<1x5x27x55xf32> 
96+ 
97+ /// With strides attribute. 
98+ 
99+ func  @test_conv_no_bias_7 (%arg0  : tensor <1 x2 x32 x64 xf32 >, %arg1  : tensor <5 x2 x6 x7 xf32 >) -> tensor <*xf32 > {
100+   %0  = " onnx.ConvNoBias"  (%arg0 , %arg1 ) {auto_pad  = " NOTSET"  , group  = 1  : i32 , strides  = [2 , 3 ]} : (tensor <1 x2 x32 x64 xf32 >, tensor <5 x2 x6 x7 xf32 >) -> tensor <*xf32 >
101+   " std.return"  (%0 ) : (tensor <*xf32 >) -> ()
102+ }
103+ 
104+ // CHECK-LABEL: test_conv_no_bias_7 
105+ // CHECK: [[RES_ATTR:%.+]] = "onnx.ConvNoBias"(%arg0, %arg1) {auto_pad = "NOTSET", group = 1 : i32, strides = [2, 3]} : (tensor<1x2x32x64xf32>, tensor<5x2x6x7xf32>) -> tensor<1x5x14x20xf32> 
106+ // CHECK: return [[RES_ATTR]] : tensor<1x5x14x20xf32> 
107+ 
108+ /// auto_pad set to SAME_UPPER with strides attribute. 
109+ /// The auto_pad will pas as if stride is equal to 1. 
110+ 
111+ func  @test_conv_no_bias_8 (%arg0  : tensor <1 x2 x32 x64 xf32 >, %arg1  : tensor <5 x2 x6 x7 xf32 >) -> tensor <*xf32 > {
112+   %0  = " onnx.ConvNoBias"  (%arg0 , %arg1 ) {auto_pad  = " SAME_UPPER"  , group  = 1  : i32 , strides  = [2 , 3 ]} : (tensor <1 x2 x32 x64 xf32 >, tensor <5 x2 x6 x7 xf32 >) -> tensor <*xf32 >
113+   " std.return"  (%0 ) : (tensor <*xf32 >) -> ()
114+ }
115+ 
116+ // CHECK-LABEL: test_conv_no_bias_8 
117+ // CHECK: [[RES_ATTR:%.+]] = "onnx.ConvNoBias"(%arg0, %arg1) {auto_pad = "SAME_UPPER", group = 1 : i32, strides = [2, 3]} : (tensor<1x2x32x64xf32>, tensor<5x2x6x7xf32>) -> tensor<1x5x16x22xf32> 
118+ // CHECK: return [[RES_ATTR]] : tensor<1x5x16x22xf32> 
119+ 
120+ /// dilations attribute. 
121+ 
122+ func  @test_conv_no_bias_9 (%arg0  : tensor <1 x2 x32 x64 xf32 >, %arg1  : tensor <5 x2 x6 x7 xf32 >) -> tensor <*xf32 > {
123+   %0  = " onnx.ConvNoBias"  (%arg0 , %arg1 ) {auto_pad  = " NOTSET"  , group  = 1  : i32 , dilations  = [2 , 3 ]} : (tensor <1 x2 x32 x64 xf32 >, tensor <5 x2 x6 x7 xf32 >) -> tensor <*xf32 >
124+   " std.return"  (%0 ) : (tensor <*xf32 >) -> ()
125+ }
126+ 
127+ // CHECK-LABEL: test_conv_no_bias_9 
128+ // CHECK: [[RES_ATTR:%.+]] = "onnx.ConvNoBias"(%arg0, %arg1) {auto_pad = "NOTSET", dilations = [2, 3], group = 1 : i32} : (tensor<1x2x32x64xf32>, tensor<5x2x6x7xf32>) -> tensor<1x5x20x42xf32> 
129+ // CHECK: return [[RES_ATTR]] : tensor<1x5x20x42xf32> 
130+ 
131+ /// dilations attribute with stride. 
132+ 
133+ func  @test_conv_no_bias_10 (%arg0  : tensor <1 x2 x32 x64 xf32 >, %arg1  : tensor <5 x2 x6 x7 xf32 >) -> tensor <*xf32 > {
134+   %0  = " onnx.ConvNoBias"  (%arg0 , %arg1 ) {auto_pad  = " NOTSET"  , group  = 1  : i32 , dilations  = [2 , 3 ], strides  = [2 , 2 ]} : (tensor <1 x2 x32 x64 xf32 >, tensor <5 x2 x6 x7 xf32 >) -> tensor <*xf32 >
135+   " std.return"  (%0 ) : (tensor <*xf32 >) -> ()
136+ }
137+ 
138+ // CHECK-LABEL: test_conv_no_bias_10 
139+ // CHECK: [[RES_ATTR:%.+]] = "onnx.ConvNoBias"(%arg0, %arg1) {auto_pad = "NOTSET", dilations = [2, 3], group = 1 : i32, strides = [2, 2]} : (tensor<1x2x32x64xf32>, tensor<5x2x6x7xf32>) -> tensor<1x5x10x21xf32> 
140+ // CHECK: return [[RES_ATTR]] : tensor<1x5x10x21xf32> 
141+ 
142+ /// dilations attribute with auto_pad set to SAME_UPPER. 
143+ 
144+ func  @test_conv_no_bias_11 (%arg0  : tensor <1 x2 x32 x64 xf32 >, %arg1  : tensor <5 x2 x6 x7 xf32 >) -> tensor <*xf32 > {
145+   %0  = " onnx.ConvNoBias"  (%arg0 , %arg1 ) {auto_pad  = " SAME_UPPER"  , group  = 1  : i32 , dilations  = [2 , 3 ]} : (tensor <1 x2 x32 x64 xf32 >, tensor <5 x2 x6 x7 xf32 >) -> tensor <*xf32 >
146+   " std.return"  (%0 ) : (tensor <*xf32 >) -> ()
147+ }
148+ 
149+ // CHECK-LABEL: test_conv_no_bias_11 
150+ // CHECK: [[RES_ATTR:%.+]] = "onnx.ConvNoBias"(%arg0, %arg1) {auto_pad = "SAME_UPPER", dilations = [2, 3], group = 1 : i32} : (tensor<1x2x32x64xf32>, tensor<5x2x6x7xf32>) -> tensor<1x5x32x64xf32> 
151+ // CHECK: return [[RES_ATTR]] : tensor<1x5x32x64xf32> 
0 commit comments