@@ -155,3 +155,44 @@ func.func @test_resize_nearest_3d(%arg0: !torch.vtensor<[?,?,?,?,?],f32>, %arg1:
155
155
%7 = torch.aten.__interpolate.size_list_scale_list %arg0 , %6 , %none_0 , %str , %false , %none_0 , %false : !torch.vtensor <[?,?,?,?,?],f32 >, !torch.list <int >, !torch.none , !torch.str , !torch.bool , !torch.none , !torch.bool -> !torch.vtensor <[?,?,?,?,?],f32 >
156
156
return %7 : !torch.vtensor <[?,?,?,?,?],f32 >
157
157
}
158
+
159
+ // CHECK-LABEL: func.func @test_resize_nearest_half_pixel
160
+ func.func @test_resize_nearest_half_pixel_round_prefer_floor (%arg0: !torch.vtensor <[?,?,?],f32 >, %arg1: !torch.vtensor <[3 ],si64 >) -> !torch.vtensor <[?,?,?],f32 > {
161
+ // CHECK: %[[GENERIC:.*]] = linalg.generic
162
+ // CHECK: %[[x11:.*]] = linalg.index 0 : index
163
+ // CHECK: %[[x12:.*]] = linalg.index 1 : index
164
+ // CHECK: %[[x13:.*]] = linalg.index 2 : index
165
+ // CHECK: %[[x15:.*]] = arith.sitofp %[[c2_i64:.*]] : i64 to f32
166
+ // CHECK: %[[x19:.*]] = arith.sitofp %[[x6:.*]] : i64 to f32
167
+ // CHECK: %[[x21:.*]] = arith.divf %[[x19]], %[[x15]] : f32
168
+ // CHECK: %[[x23:.*]] = arith.index_cast %[[x13]] : index to i64
169
+ // CHECK: %[[x24:.*]] = arith.sitofp %[[x23]] : i64 to f32
170
+ // CHECK: %[[cst:.*]] = arith.constant 5.000000e-01 : f32
171
+ // CHECK: %[[add:.*]] = arith.addf %[[x24]], %[[cst]] : f32
172
+ // CHECK: %[[x25:.*]] = arith.divf %[[add]], %[[x21]] : f32
173
+ // CHECK: %[[sub:.*]] = arith.subf %[[x25]], %[[cst]] : f32
174
+ // CHECK: %[[cst3:.*]] = arith.constant 5.000000e-01 : f32
175
+ // CHECK: %[[floor:.*]] = math.floor %[[sub]] : f32
176
+ // CHECK: %[[ceil:.*]] = math.ceil %[[sub]] : f32
177
+ // CHECK: %[[sub2:.*]] = arith.subf %[[sub]], %[[floor]] : f32
178
+ // CHECK: %[[cmpf:.*]] = arith.cmpf ule, %[[sub2]], %[[cst3]] : f32
179
+ // CHECK: %[[select:.*]] = arith.select %[[cmpf]], %[[floor]], %[[ceil]] : f32
180
+ // CHECK: %[[x31:.*]] = arith.fptosi %[[select]] : f32 to i64
181
+ // CHECK: %[[x32:.*]] = arith.index_cast %[[x31]] : i64 to index
182
+ // CHECK: %[[extracted:.*]] = tensor.extract %[[x0:.*]][%[[x11]], %[[x12]], %[[x32]]] : tensor<?x?x?xf32>
183
+ // CHECK: linalg.yield %[[extracted]] : f32
184
+ %none = torch.constant.none
185
+ %none_0 = torch.constant.none
186
+ %int0 = torch.constant.int 0
187
+ %false = torch.constant.bool false
188
+ %true = torch.constant.bool true
189
+ %str = torch.constant.str " nearest_half_pixel,round_prefer_floor"
190
+ %int2 = torch.constant.int 2
191
+ %0 = torch.aten.select.int %arg1 , %int0 , %int2 : !torch.vtensor <[3 ],si64 >, !torch.int , !torch.int -> !torch.vtensor <[1 ],si64 >
192
+ %1 = torch.aten.item %0 : !torch.vtensor <[1 ],si64 > -> !torch.int
193
+ %4 = torch.prim.ListConstruct %1 : (!torch.int ) -> !torch.list <int >
194
+ %5 = torch.aten.__interpolate.size_list_scale_list %arg0 , %4 , %none_0 , %str , %false , %none_0 , %false : !torch.vtensor <[?,?,?],f32 >, !torch.list <int >, !torch.none , !torch.str , !torch.bool , !torch.none , !torch.bool -> !torch.vtensor <[?,?,?],f32 >
195
+ return %5 : !torch.vtensor <[?,?,?],f32 >
196
+ }
197
+
198
+ // -----
0 commit comments