Skip to content
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

Reduce diff with upstream code #2940

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions bin/triton-tensor-layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,17 @@ static cl::opt<std::string> TensorStr(
//===--------------------------------------------------------------------===//

LogicalResult layoutPrint(RankedTensorType tensorType, raw_ostream &os) {
StringRef dialectName = tensorType.getEncoding().getDialect().getNamespace();

// Dispatch to the corresponding dialect helper function to print the layout.
os << triton::gpu::getLayoutStr(tensorType, UseHWPointOfView);
return success();
if (dialectName == "ttg") {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is the same as upstream, however it may not work for us. @chengjunlu ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this code wouldn't work for us.
We need to PR the changes to upstream to enable this tool work for third party dialect.

os << triton::gpu::getLayoutStr(tensorType, UseHWPointOfView);
return success();
}

llvm::errs() << "Unsupported tensor layout attribute: "
<< tensorType.getEncoding() << "\n";
return failure();
}

LogicalResult printLayoutFromFile(MLIRContext *context, StringRef filename,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ void decomposeSplatOpToSharedLayoutConversion(ModuleOp module) {
int threadsPerWarp = triton::gpu::TritonGPUDialect::getThreadsPerWarp(module);
module.walk([&](triton::SplatOp splatOp) -> void {
auto dstType = cast<RankedTensorType>(splatOp.getType());
auto shared = dyn_cast_or_null<triton::gpu::SharedEncodingAttr>(
dstType.getEncoding());
auto shared =
dyn_cast<triton::gpu::SharedEncodingAttr>(dstType.getEncoding());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would make benchmark fail for the advanced path ? @quintinwang5 did you try to upstream this change ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Submitted something like this. They told me in ttgir every tensor must have a layout. So I think this is also unreasonable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove this pass for advance path. Right? Because there is no convert layout operation used in advance path.

if (shared) {
OpBuilder builder(splatOp);
SmallVector<unsigned, 4> sizePerThread(dstType.getRank(), 1);
Expand Down