Skip to content

Commit

Permalink
added tt::LayoutAttr to the backend interface
Browse files Browse the repository at this point in the history
  • Loading branch information
mbezuljTT committed Nov 1, 2024
1 parent 301383a commit 3404e19
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions include/ttmlir/Dialect/TTNN/IR/TTNNOpsBackendInterfaces.td
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def TTNNOpBackendInterface : OpInterface<"TTNNOpBackend"> {
}],
/*retTy=*/"size_t",
/*methodName=*/"getOpPerfCycles",
/*args=*/(ins), // TBD
/*args=*/(ins "const tt::LayoutAttr&":$output_layout), // Subject to change
/*methodBody=*/"",
/*defaultImplementation=*/"return std::numeric_limits<size_t>::max();"
>,
Expand All @@ -30,7 +30,7 @@ def TTNNOpBackendInterface : OpInterface<"TTNNOpBackend"> {
}],
/*retTy=*/"size_t",
/*methodName=*/"getOpL1Usage",
/*args=*/(ins), // TBD
/*args=*/(ins "const tt::LayoutAttr&":$output_layout), // Subject to change
/*methodBody=*/"",
/*defaultImplementation=*/"return 0;"
>,
Expand All @@ -40,7 +40,7 @@ def TTNNOpBackendInterface : OpInterface<"TTNNOpBackend"> {
}],
/*retTy=*/"bool",
/*methodName=*/"isOpLegal",
/*args=*/(ins), // TBD
/*args=*/(ins "const tt::LayoutAttr&":$output_layout), // Subject to change
/*methodBody=*/"",
/*defaultImplementation=*/"return true;"
>,
Expand Down
6 changes: 3 additions & 3 deletions lib/Dialect/TTNN/Analysis/LegalGridAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ bool mock_is_output_tensor_legal_for_op(Operation *op, tt::LayoutAttr layout) {

// if (TTNNOpBackend backend = dyn_cast<TTNNOpBackend>(op)) {
// llvm::outs() << op->getName() << "=" << layout << "\n";
// llvm::outs() << "\t[Perf] = " << backend.getOpPerfCycles() << "\n";
// llvm::outs() << "\t[L1] = " << backend.getOpL1Usage() << "\n";
// llvm::outs() << "\t[Legal] = " << backend.isOpLegal() << "\n";
// llvm::outs() << "\t[Perf] = " << backend.getOpPerfCycles(layout) << "\n";
// llvm::outs() << "\t[L1] = " << backend.getOpL1Usage(layout) << "\n";
// llvm::outs() << "\t[Legal] = " << backend.isOpLegal(layout) << "\n";
// }

return true;
Expand Down
6 changes: 3 additions & 3 deletions lib/Dialect/TTNN/IR/TTNNOpsBackendInterfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ namespace mlir::tt::ttnn {
//===----------------------------------------------------------------------===//

// // Relu backend interface
size_t ReluOp::getOpPerfCycles() {
size_t ReluOp::getOpPerfCycles(const tt::LayoutAttr &output_layout) {
// Implement a custom estimate for relu op cycles.
return 5;
}

size_t ReluOp::getOpL1Usage() {
size_t ReluOp::getOpL1Usage(const tt::LayoutAttr &output_layout) {
// Implement a custom estimate for relu op L1 usage.
return 10;
}

bool ReluOp::isOpLegal() {
bool ReluOp::isOpLegal(const tt::LayoutAttr &output_layout) {
// Implement a custom check for relu op legality.
return true;
}
Expand Down

0 comments on commit 3404e19

Please sign in to comment.