Skip to content

Commit

Permalink
[Triton Tool] Enable the triton-tensor-layout tool for 3rd party Trit…
Browse files Browse the repository at this point in the history
…on GPU Dialect (#5444)

Remove the protection of only the `ttg` dialect being allowed in
triton-tensor-layout tool safely.

Change the helper function to check whether the layout attribute
implements the `toLinearLayout` interface.

This PR does not include new test because the in-tree LIT test covers
the changes for in-tree layout attribute of Triton GPU dialect.
  • Loading branch information
chengjunlu authored Dec 17, 2024
1 parent 24b8d43 commit 1f8966b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions bin/triton-tensor-layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,11 @@ 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.
if (dialectName == "ttg") {
// DistributedEncodingTrait and SharedEncodingAttr implements the
// toLinearLayout interface.
mlir::Attribute layout = tensorType.getEncoding();
if (isa<mlir::triton::gpu::DistributedEncodingTrait,
mlir::triton::gpu::SharedEncodingAttr>(layout)) {
os << triton::gpu::getLayoutStr(tensorType, UseHWPointOfView);
return success();
}
Expand Down

0 comments on commit 1f8966b

Please sign in to comment.