-
Notifications
You must be signed in to change notification settings - Fork 16
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
remove CB operands from ttir.generic #2376
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Style nit regarding headers
#include <mlir/Interfaces/ControlFlowInterfaces.h> | ||
#include <mlir/Interfaces/DestinationStyleOpInterface.h> | ||
#include <mlir/Interfaces/InferTypeOpInterface.h> | ||
#include <mlir/Interfaces/SideEffectInterfaces.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the chevrons here goes against our style guide (inherited from llvm).
See https://docs.tenstorrent.com/tt-mlir/coding-guidelines.html#includes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've always used <> for all includes that are external to the project's source tree and thus need an include path provided to the compiler. Also have done this in several prev PRs...
Changed in the last commit.
// clang-format on | ||
template <typename Op> | ||
mlir::MutableOperandRange getDpsOutputs(Op *op) { | ||
return impl::getDpsOutputs<Op>::evaluate(op); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the usual type deduction technique
include/ttmlir/Utils.h
Outdated
#include <mlir/CAPI/IR.h> | ||
#include <mlir/Dialect/Tensor/IR/Tensor.h> | ||
#include <mlir/IR/AffineMap.h> | ||
#include <mlir/IR/BuiltinAttributes.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in the latest commit
} | ||
}; | ||
} // namespace | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1300 lines removed, you must have fixed at least 10 bugs in one shot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the best c++ code is code that doesn't exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
#ifndef TTMLIR_DIALECT_TTIR_IR_UTILS_H | ||
#define TTMLIR_DIALECT_TTIR_IR_UTILS_H | ||
|
||
#include <mlir/IR/ValueRange.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: <>
here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed here as well
|
||
template <typename Op> | ||
inline constexpr bool has_variadic_outputs< | ||
Op, std::void_t<decltype(std::declval<Op>().getOutputsMutable())>> = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I find convention from STL with _v
and _t
handy when working with templates, though this is localized so it's okay either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree and I started with _v
but then it seemed to me that llvm sources don't use such suffixes, so I changed. I've checked again and maybe their usage is mixed. I've gone back to _v
which is my personal preference as well.
static mlir::MutableOperandRange evaluate(Op *op) { | ||
return op->getOutputsMutable(); | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's your opinion on this vs if constexpr
? I find the latter more handy for cases like this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if constexpr
would work here as well, as well a c++20 concept (when we can use c++20).
I think some intermediate version I had needed template specialization to instantiate single/variadic branches separately. But that's not needed in the final version so I've changed to if constexpr
as more compact.
### Ticket Closes #1969 ### Problem description We are moving lowering of operands to CB slots to a lower section of the d2m pipeline and hence decided to remove CB operand-related arguments from ttir.generic op. ### What's changed There are two main changes, the first is a generic tablegen cleanup action and is somewhat independent of the second: 1. a new `getDpsOutputs()` helper method in `ttmlir/Dialect/TTIR/IR/Utils.h` will auto-detect whether a concrete OP has single or variadic outputs; using it in `extraClassDeclaration` of selected base tablegen `class`es allows multiple such trivial/repeated declarations to be removed from a number of TTIROps `def`s. 2. ttir.generic has lost CB operands/mapping attributes; the `enqueue program` rewriter in `TTIRToTTMetal.cpp` pass that depends on that logic has been removed for now ### Checklist - [x] multiple existing tests had their operand_cb_mapping attributes removed and `operandSegmentSizes` adjusted accordingly
### Ticket Closes #1969 ### Problem description We are moving lowering of operands to CB slots to a lower section of the d2m pipeline and hence decided to remove CB operand-related arguments from ttir.generic op. ### What's changed There are two main changes, the first is a generic tablegen cleanup action and is somewhat independent of the second: 1. a new `getDpsOutputs()` helper method in `ttmlir/Dialect/TTIR/IR/Utils.h` will auto-detect whether a concrete OP has single or variadic outputs; using it in `extraClassDeclaration` of selected base tablegen `class`es allows multiple such trivial/repeated declarations to be removed from a number of TTIROps `def`s. 2. ttir.generic has lost CB operands/mapping attributes; the `enqueue program` rewriter in `TTIRToTTMetal.cpp` pass that depends on that logic has been removed for now ### Checklist - [x] multiple existing tests had their operand_cb_mapping attributes removed and `operandSegmentSizes` adjusted accordingly
Ticket
Closes #1969
Problem description
We are moving lowering of operands to CB slots to a lower section of the d2m pipeline and hence decided to remove CB operand-related arguments from ttir.generic op.
What's changed
There are two main changes, the first is a generic tablegen cleanup action and is somewhat independent of the second:
getDpsOutputs()
helper method inttmlir/Dialect/TTIR/IR/Utils.h
will auto-detect whether a concrete OP has single or variadic outputs; using it inextraClassDeclaration
of selected base tablegenclass
es allows multiple such trivial/repeated declarations to be removed from a number of TTIROpsdef
s.enqueue program
rewriter inTTIRToTTMetal.cpp
pass that depends on that logic has been removed for nowChecklist
operandSegmentSizes
adjusted accordingly