As the title says, triton-to-linalg convert tt.func use walk rather than conversion pattern.
|
// Convert tt.func and tt.return into func's counterparts |
|
moduleOp.walk([&](triton::FuncOp func) { |
|
OpBuilder builder(func); |
|
|
|
auto name = func.getName(); |
|
auto type = func.getFunctionType(); |
|
|
|
SmallVector<DictionaryAttr> argAttrs, resAttrs; |
|
func.getAllArgAttrs(argAttrs); |
|
func.getAllResultAttrs(resAttrs); |
|
|
|
auto funcFunc = builder.create<func::FuncOp>(func.getLoc(), name, type); |
|
funcFunc.setAllArgAttrs(argAttrs); |
|
funcFunc.setAllResultAttrs(resAttrs); |
|
|
|
auto &funcFuncBody = funcFunc.getBody(); |
|
auto &funcBody = func.getBody(); |
|
|
|
IRMapping map; |
|
funcBody.cloneInto(&funcFuncBody, map); |
|
|
|
for (Block &block : funcFuncBody.getBlocks()) { |
|
auto term = block.getTerminator(); |
|
builder.setInsertionPoint(term); |
|
builder.create<func::ReturnOp>(func.getLoc(), term->getOperands()); |
|
term->erase(); |
|
} |
|
func.erase(); |
|
}); |
As the title says, triton-to-linalg convert
tt.funcuse walk rather than conversion pattern.triton-shared/lib/Conversion/TritonToLinalg/TritonToLinalgPass.cpp
Lines 187 to 215 in 2b728ad