@@ -293,21 +293,34 @@ def bundle_xegpu_fused_attention_schedule(
293293 # `linalg.fill`s (rather than `tensor.extract_slice` of an outside fill), so
294294 # the dependant-reduction fusion's zero-init legality check now succeeds.
295295 tile_and_fuse_reduction_dim (func , anytype , parameters )
296- transform .print_ (target = func , name = "after inner tiling and fusion" )
297-
298- if stop_at_stage == "inner-tiled" :
299- raise PipelineInterrupt ()
300-
301296 # Drop the batch unit extent (tile size 1) from the linalg ops in the loop
302297 # nest before vectorizing. Tiling the batch dim by 1 left every op with a
303298 # leading 1x... shape; folding it here (via rank-reducing slices) means
304299 # vectorization emits 128x64 / 128 vectors directly instead of 1x128x64
305300 # vectors wrapped in shape_casts, and bufferization allocates unit-dim-free
306301 # memrefs (e.g. memref<128xf16> instead of memref<1x128xf16>).
302+ # The fold_unit_extent_dims patterns only rewrite linalg.generic ops, so
303+ # first generalize the remaining named/category ops in the loop nest (the K
304+ # transpose, the scale linalg.mul and the div/mul linalg.elementwise ops)
305+ # into generics. Without this the unit dim survives on exactly those ops.
306+ func = apply_registered_pass (
307+ func ,
308+ "linalg-morph-ops" ,
309+ options = {"category-to-generic" : True },
310+ )
311+ transform .apply_cse (func )
312+ canonicalize (func )
313+ transform .print_ (target = func , name = "after generalizing" )
314+
307315 with ir .InsertionPoint (transform .apply_patterns (func ).patterns ):
308316 structured .apply_patterns_linalg_fold_unit_extent_dims_via_slices ()
317+ structured .apply_patterns_linalg_fold_unit_extent_dims_via_reshapes ()
309318 transform .apply_cse (func )
310319 canonicalize (func )
320+ transform .print_ (target = func , name = "after inner tiling and fusion" )
321+
322+ if stop_at_stage == "inner-tiled" :
323+ raise PipelineInterrupt ()
311324
312325 # Vectorize the fused loop nest: rewrite the remaining linalg ops (the tiled
313326 # matmuls, reductions and elementwise ops inside the scf.for) into vector
@@ -404,7 +417,7 @@ def bundle_xegpu_fused_attention_schedule(
404417 gpu_func = match (gpu_mod , ops = {"gpu.func" })
405418 allocas = match (gpu_func , ops = {"memref.alloca" })
406419 transform_ext .update_address_space (allocas , address_space = 3 )
407- gpu_func = apply_registered_pass (gpu_func , "convert-vector-to-xegpu" )
420+ # gpu_func = apply_registered_pass(gpu_func, "convert-vector-to-xegpu")
408421 transform .apply_cse (gpu_func )
409422 gpu_func = apply_registered_pass (gpu_func , "loop-invariant-code-motion" )
410423
0 commit comments