Skip to content

[question] Why there is not a conversion pattern for tt.func #350

@CoTinker

Description

@CoTinker

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();
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions