-
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
TTNN->EmitC new op conversion infrastructure #2331
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.
Clang-Tidy
found issue(s) with the introduced code (1/1)
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.
Great change! Thanks!
- TODO: add gtest to confirm expectations
- TODO: add tests for std::array - TODO: add tests for std::variant
bd880d8
to
0829d58
Compare
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.
Can you update the docs as well please? These are the relevant emitc sections:
@svuckovicTT For the docs I planned to do it in the separate PR, just to test it a little bit further to verify that this won't require some major change. |
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.
Docs in next iteration.
### Ticket #2343 ### Problem description Part of the effort to onboard all TTNN ops to conversion infrastructure introduced in #2331 ### What's changed Transitioned ops with existing conversion to conversion with the new converter. Few changes in the Emitter class, mainly in the way how operands are treated, to accommodate more complex cases like `Variadic` of tensors that maps to `std::vector<ttnn::Tensor>`.
### Ticket #2343 ### Problem description Part of the effort to onboard all TTNN ops to conversion infrastructure introduced in #2331 ### What's changed Transitioned ops with existing conversion to conversion with the new converter. Few changes in the Emitter class, mainly in the way how operands are treated, to accommodate more complex cases like `Variadic` of tensors that maps to `std::vector<ttnn::Tensor>`.
### Ticket #2311 ### Problem description Existing way of TTNN->EmitC conversion exhibits a few limitations: 1. requires too much consideration on the OP to OP basis (requires user to explicitly make differentiation between operands and attributes) 2. didn't take into consideration many-to-many relationship of MLIR and C++ types (i.e. {`ArrayAttr`, `DenseI32ArrayAttr`} <-> {`ttnn::SmallVector<int32_t>`, `std::vector<uint32_t>`}) ### What's changed Introduction of the new `EmitCTTNNEmitter` class that should address these limitations in the following way: 1. Most conversions should follow this pattern ```cpp ttnn_to_emitc::EmitCTTNNEmitter<TTNNOp> emitter(srcOp, adaptor, rewrite); llvm::SmallVector<mlir::Attribute> args { emitter.emit(srcOp.getArg0()), emitter.emit(srcOp.getArg1()), ..., emitter.emit(srcOp.getArgN()) }; emitter.replaceOp(*this, args); return success(); ``` 2. For many-to-many relationship between MLIR and C++ types we 'hint' emit member function with the target C++ type ```cpp emitter.emit<ttnn::SmallVector<int32_t>>(srcOp.getSomeDenseArrayAttr()) ``` Of course, this is still a utility and it's not baked directly into MLIR's conversion pattern rewriter, so we can still do it the old way for the ops whose structure deviates too much from the general op structure. ### Checklist - [x] New/Existing tests provide coverage for changes - At this point `EmitCTTNNEmitter` and related class should still be considered WIP, next goal is to transfer all of the existing ops to this type of conversion and leverage existing tests to iron out some missing details
### Ticket #2343 ### Problem description Part of the effort to onboard all TTNN ops to conversion infrastructure introduced in #2331 ### What's changed Transitioned ops with existing conversion to conversion with the new converter. Few changes in the Emitter class, mainly in the way how operands are treated, to accommodate more complex cases like `Variadic` of tensors that maps to `std::vector<ttnn::Tensor>`.
Ticket
#2311
Problem description
Existing way of TTNN->EmitC conversion exhibits a few limitations:
ArrayAttr
,DenseI32ArrayAttr
} <-> {ttnn::SmallVector<int32_t>
,std::vector<uint32_t>
})What's changed
Introduction of the new
EmitCTTNNEmitter
class that should address these limitations in the following way:emitter.emit<ttnn::SmallVector<int32_t>>(srcOp.getSomeDenseArrayAttr())
Of course, this is still a utility and it's not baked directly into MLIR's conversion pattern rewriter, so we can still do it the old way for the ops whose structure deviates too much from the general op structure.
Checklist
EmitCTTNNEmitter
and related class should still be considered WIP, next goal is to transfer all of the existing ops to this type of conversion and leverage existing tests to iron out some missing details