-
Notifications
You must be signed in to change notification settings - Fork 0
Adapt conv tile. #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Adapt conv tile. #13
Changes from all commits
b5d8c6b
ee511d8
226d598
baa914a
10fbd7a
1de0414
5a489fa
a2cd45f
f6d6302
c5e26aa
70cdb85
5d835ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,15 +35,17 @@ include "mlir/Interfaces/ViewLikeInterface.td" | |
| //===----------------------------------------------------------------------===// | ||
|
|
||
| def PTODpsType : | ||
| AnyTypeOf<[AnyRankedTensor, PartitionTensorViewType, TileBufType]>; | ||
| AnyTypeOf<[AnyRankedTensor, PartitionTensorViewType, TileBufType, | ||
| ConvTileType]>; | ||
|
|
||
| def PTOPipeEntryType : | ||
| AnyTypeOf<[AnyRankedTensor, TensorViewType, TileBufType], | ||
| "TensorView, TileBuf, or Tensor">; | ||
| AnyTypeOf<[AnyRankedTensor, TensorViewType, TileBufType, ConvTileType], | ||
| "TensorView, TileBuf, ConvTile, or Tensor">; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PTOPipeEntryType仅涉及到TPush Tpop等mix kernel op, 这些op应该不支持convtile吧,确认是否需要,不需要的话这个不能添加ConvTile |
||
|
|
||
| def PTOCommType : | ||
| AnyTypeOf<[AnyRankedTensor, TensorViewType, PartitionTensorViewType, | ||
| TileBufType], "TensorView, PartitionTensorView, TileBuf, or Tensor">; | ||
| TileBufType, ConvTileType], | ||
| "TensorView, PartitionTensorView, TileBuf, ConvTile, or Tensor">; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 同上 |
||
|
|
||
| def PtrOrMemRef : | ||
| AnyTypeOf<[PtrType, AnyMemRef], "Ptr or MemRef">; | ||
|
|
@@ -331,7 +333,10 @@ def AllocTileOp : PTO_Op<"alloc_tile", [AttrSizedOperandSegments]> { | |
| Optional<Index>:$valid_col | ||
| ); | ||
|
|
||
| let results = (outs TileBufType:$result); | ||
| // ConvTile values reuse the same allocation surface but carry a different | ||
| // type/metadata payload. The lowering selects the emitted C++ type from the | ||
| // result type. | ||
| let results = (outs AnyTypeOf<[TileBufType, ConvTileType], "TileBuf or ConvTile">:$result); | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. alloc_tile 结果现在可能是 ConvTile,但基线里至少有多处对 alloc/tile 结果无条件 castpto::TileBufType,本 PR 只适配了 EmitC alloc pattern 和
只要 ConvTile 流经任一路径就是 cast<> 断言崩溃。PR 声称"仅 EmitC",但类型系统并不阻止 ConvTile 进入这些 pass。建议:要么在这些 pass 入口对 ConvTile 做 |
||
| let assemblyFormat = [{ | ||
| (`addr` `=` $addr^)? | ||
|
|
@@ -1360,6 +1365,12 @@ def TMovOp : PTO_TOp<"tmov", [ | |
| return as.getAddressSpace(); | ||
| return std::nullopt; | ||
| } | ||
| if (auto ct = llvm::dyn_cast<::mlir::pto::ConvTileType>(ty)) { | ||
| if (auto as = llvm::dyn_cast_or_null<::mlir::pto::AddressSpaceAttr>( | ||
| ct.getMemorySpace())) | ||
| return as.getAddressSpace(); | ||
| return std::nullopt; | ||
| } | ||
| return std::nullopt; | ||
| }; | ||
|
|
||
|
|
@@ -1882,6 +1893,67 @@ def SetQuantVectorOp : PTO_Op<"set_quant_vector", [ | |
| }]; | ||
| } | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // ConvTile / IMG2COL config ops | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| def SetFmatrixOp : PTO_Op<"set_fmatrix", [MemoryEffects<[MemWrite]>]> { | ||
| let summary = "Set FMATRIX registers from a ConvTile config"; | ||
| let arguments = (ins | ||
| ConvTileType:$src, | ||
| DefaultValuedAttr<PTO_FmatrixModeAttr, "::mlir::pto::FmatrixMode::FMATRIX_A_MANUAL">:$fmatrixMode | ||
| ); | ||
| let results = (outs); | ||
| let hasVerifier = 1; | ||
| let assemblyFormat = [{ | ||
| $src attr-dict `:` qualified(type($src)) | ||
| }]; | ||
| } | ||
|
|
||
| def SetImg2colRptOp : PTO_Op<"set_img2col_rpt", [MemoryEffects<[MemWrite]>]> { | ||
| let summary = "Set IMG2COL repeat control from a ConvTile config"; | ||
| let arguments = (ins | ||
| ConvTileType:$src, | ||
| DefaultValuedAttr<PTO_FmatrixModeAttr, "::mlir::pto::FmatrixMode::FMATRIX_A_MANUAL">:$fmatrixMode | ||
| ); | ||
| let results = (outs); | ||
| let hasVerifier = 1; | ||
| let assemblyFormat = [{ | ||
| $src attr-dict `:` qualified(type($src)) | ||
| }]; | ||
| } | ||
|
|
||
| def SetImg2colPaddingOp : PTO_Op<"set_img2col_padding", [MemoryEffects<[MemWrite]>]> { | ||
| let summary = "Set IMG2COL padding control from a ConvTile config"; | ||
| let arguments = (ins | ||
| ConvTileType:$src, | ||
| DefaultValuedAttr<PTO_FmatrixModeAttr, "::mlir::pto::FmatrixMode::FMATRIX_A_MANUAL">:$fmatrixMode | ||
| ); | ||
| let results = (outs); | ||
| let hasVerifier = 1; | ||
| let assemblyFormat = [{ | ||
| $src attr-dict `:` qualified(type($src)) | ||
| }]; | ||
| } | ||
|
|
||
| def TImg2colOp : PTO_Op<"timg2col", [ | ||
| DeclareOpInterfaceMethods<MemoryEffectsOpInterface> | ||
| ]> { | ||
| let summary = "Image-to-column transform from ConvTile to TileBuf"; | ||
| let arguments = (ins | ||
| TileBufType:$dst, | ||
| ConvTileType:$src, | ||
| DefaultValuedOptionalAttr<I32Attr, "0">:$posM, | ||
| DefaultValuedOptionalAttr<I32Attr, "0">:$posK, | ||
| DefaultValuedAttr<PTO_FmatrixModeAttr, "::mlir::pto::FmatrixMode::FMATRIX_A_MANUAL">:$fmatrixMode | ||
| ); | ||
| let results = (outs); | ||
| let hasVerifier = 1; | ||
| let assemblyFormat = [{ | ||
| $dst `,` $src attr-dict `:` qualified(type($dst)) `,` qualified(type($src)) | ||
| }]; | ||
| } | ||
|
|
||
| def ReserveBufferOp : PTO_Op<"reserve_buffer"> { | ||
| let summary = "Reserve a local consumer slot buffer"; | ||
|
|
||
|
|
@@ -6239,7 +6311,6 @@ def TDeInterleaveOp: PTO_TOp<"tdeinterleave", [ | |
| ::mlir::Value getDst1() { return getDsts()[1]; } | ||
| }]; | ||
| } | ||
|
|
||
| def TRowProdOp: PTO_TOp<"trowprod", [ | ||
| PTO_DpsInitOpInterface, | ||
| OpPipeInterface, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PTODpsType涉及到很多不支持convtile的op, 加在这里相当于很多op的输入输出都支持convtile,有需要的话单独定义个type, 不要动这个类型