Skip to content

Commit 5cd8ce5

Browse files
committed
add a test
Signed-off-by: hanhanW <hanhan0912@gmail.com>
1 parent 08eeaed commit 5cd8ce5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

compiler/src/iree/compiler/DispatchCreation/test/hoist_encoding_ops.mlir

+21
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,24 @@ util.func public @hoist_both_src_and_encoding() -> tensor<640x320xf32> {
226226
// CHECK: %[[CST:.+]] = arith.constant
227227
// CHECK: %[[SET_ENCODING:.+]] = iree_encoding.set_encoding %[[CST]]
228228
// CHECK: flow.dispatch.region
229+
230+
// -----
231+
232+
// It tests that the constant-like source is already outside the region, and the
233+
// hoisting does not happen to it. Otherwise, it crashes.
234+
235+
#encoding = #iree_encoding.testing_encoding<>
236+
util.func private @get_tensor(tensor<640x320xf32, #encoding>) -> tensor<640x320xf32>
237+
util.func public @hoist_encoding_only() -> tensor<640x320xf32> {
238+
%cst = arith.constant dense<1.0> : tensor<640x320xf32>
239+
%0 = flow.dispatch.region -> (tensor<640x320xf32>) {
240+
%1 = iree_encoding.set_encoding %cst : tensor<640x320xf32> -> tensor<640x320xf32, #encoding>
241+
%2 = util.call @get_tensor(%1) : (tensor<640x320xf32, #encoding>) -> tensor<640x320xf32>
242+
flow.return %2 : tensor<640x320xf32>
243+
}
244+
util.return %0 : tensor<640x320xf32>
245+
}
246+
// CHECK-LABEL: util.func public @hoist_encoding_only(
247+
// CHECK: %[[CST:.+]] = arith.constant
248+
// CHECK: %[[SET_ENCODING:.+]] = iree_encoding.set_encoding %[[CST]]
249+
// CHECK: flow.dispatch.region

0 commit comments

Comments
 (0)