@@ -1396,29 +1396,43 @@ def SplitOp : Op<Transform_Dialect, "structured.split",
1396
1396
DeclareOpInterfaceMethods<TransformOpInterface>,
1397
1397
ReportTrackingListenerFailuresOpTrait]> {
1398
1398
let description = [{
1399
- Indicates that the given `target` op should be split into two complementary
1399
+ Splits the given `target` op into two or more complementary
1400
1400
parts, which combined cover the entire iteration domain of the original op.
1401
1401
The split is performed along the iteration space dimension provided as
1402
- attribute. In case of dimension overflow, the transformation fails. The
1403
- split is performed at the dimension iterator value specified as either the
1404
- static split point attribute when it is known at transform IR construction
1405
- time or as the handle to an operation producing a single index-typed value
1406
- when it is computed by payload IR. In the latter case, the static split
1402
+ chunk size attribute specifying the size of the lower part; the remaining
1403
+ range in the iteration space is assigned as the upper part. In case of
1404
+ dimension overflow, the transformation fails. The split is performed at the
1405
+ dimension iterator value specified as either the static chunk size
1406
+ attribute when it is known at transform IR construction time or
1407
+ as the handle to an operation producing a single index-typed value
1408
+ when it is computed by payload IR. In the latter case, the chunk size
1407
1409
point must be set to `ShapedType::kDynamic` and the dynamic size handle
1408
1410
must point to as many value-producing operations as there are structured
1409
1411
operations pointed to by the target handle.
1410
1412
1411
- The operation consumes the target handle, but preserves the split point
1412
- handle if provided. It produces two new handles pointing to the two parts
1413
- of the structured op after splitting, in the same order as the target
1414
- operand, with the first handle corresponding to the part with lower
1415
- iteration space indices.
1413
+ The operation consumes the target handle, but preserves the chunk size
1414
+ handle if provided. Without the `multiway` attribute, it produces two
1415
+ new handles pointing to the two parts of the structured op after splitting,
1416
+ in the same order as the target operand, with the first handle
1417
+ corresponding to the part with lower iteration space indices.
1418
+
1419
+ Multiway split mode is enabled by specifying the `multiway` attribute.
1420
+ In this mode a single `target` op is split into multiple parts covering
1421
+ the iteration space of the specified dimension. `static_chunk_sizes` and
1422
+ `dynamic_chunk_sizes` in this case is a list of chunk sizes that the given
1423
+ dimension should be split into. With `multiway` it produces two handles;
1424
+ the first handle is a list of the multiple parts of the structured op
1425
+ after splitting, where the target dimensions for each linalg op in the
1426
+ list corresponds to the chunk sizes specfied in the input split list.
1427
+ If the chunk sizes do not cover the entire iteration space, the leftover
1428
+ chunk is the last payload in the first handle. The second handle is empty.
1416
1429
}];
1417
1430
1418
1431
let arguments = (ins TransformHandleTypeInterface:$target,
1419
1432
I64Attr:$dimension,
1420
- Optional<TransformAnyParamTypeOrAnyHandle>:$dynamic_split_point,
1421
- I64Attr:$static_split_point);
1433
+ Optional<TransformAnyParamTypeOrAnyHandle>:$dynamic_chunk_sizes,
1434
+ I64Attr:$static_chunk_sizes,
1435
+ UnitAttr:$multiway);
1422
1436
let results = (outs TransformHandleTypeInterface:$first,
1423
1437
TransformHandleTypeInterface:$second);
1424
1438
let hasCustomAssemblyFormat = 1;
@@ -1819,6 +1833,51 @@ def TileReductionUsingForallOp :
1819
1833
1820
1834
}
1821
1835
1836
+ //===----------------------------------------------------------------------===//
1837
+ // ContinuousTileSizesOp
1838
+ //===----------------------------------------------------------------------===//
1839
+
1840
+ def ContinuousTileSizesOp : Op<Transform_Dialect, "structured.continuous_tile_sizes",
1841
+ [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>,
1842
+ DeclareOpInterfaceMethods<TransformOpInterface>,
1843
+ ReportTrackingListenerFailuresOpTrait]> {
1844
+ let description = [{
1845
+ This transform emits the IR computing the list of (1) exponentially
1846
+ diminishing tile sizes that are powers of 2; and (2) the corresponding
1847
+ chunk-sizes the target op should be split into along the given dimension.
1848
+
1849
+ For example, for `target_size` 9, and `dimension` 0 for the following
1850
+ linalg op as target
1851
+
1852
+ ```
1853
+ %0 = linalg.matmul ins(%arg0, %arg1: tensor<25x34xf32>, tensor<34x25xf32>)
1854
+ outs(%arg2: tensor<25x25xf32>)
1855
+ ```
1856
+
1857
+ the first result `tile_sizes` will be a list of diminishing tile sizes
1858
+ 9, 4, 2, 1; and the second result will be a list of chunk sizes
1859
+ 18, 4, 2, 1 that the corresponding dimension should be split into.
1860
+
1861
+ After the target op has been split along the given dimension (for example
1862
+ using multiway split), each chunk can be tiled with the corresponding tile
1863
+ size in the `tile_sizes` list generated as a result of this op.
1864
+
1865
+ Specifying the output type as !transform.param<i64> will cause `tile_sizes`
1866
+ and `chunk_sizes` to be computed statically and not dynamically.
1867
+ }];
1868
+
1869
+ let arguments = (ins TransformHandleTypeInterface:$target,
1870
+ ConfinedAttr<I64Attr, [IntNonNegative]>:$dimension,
1871
+ ConfinedAttr<I64Attr, [IntNonNegative]>:$target_size);
1872
+ let results = (outs TransformAnyParamTypeOrAnyHandle:$tile_sizes,
1873
+ TransformAnyParamTypeOrAnyHandle:$chunk_sizes);
1874
+ let hasVerifier = 1;
1875
+ let assemblyFormat =
1876
+ "$target attr-dict `:` custom<ContinuousTileSizeTypes>("
1877
+ "type($target), type($tile_sizes), type($chunk_sizes))";
1878
+
1879
+ }
1880
+
1822
1881
//===----------------------------------------------------------------------===//
1823
1882
// TileUsingForOp
1824
1883
//===----------------------------------------------------------------------===//
0 commit comments