tt-mlir: [Bounty $500] Implement specific op includes generation
Implement proper creation of emitc::IncludeOps, taking into account differences between unary and binary op kernel includes, which of them exist in general, which are specific to unary vs binary (if any) and which are specific to the concrete op.
For example, exp call needs compute_kernel_api/eltwise_unary/exp.h included.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 16 (16 by maintainers)
No TTIR is a different dialect that doesn’t need these kernel includes.
Hey @wusatosi this all sounds great!! Thank you for the detailed writeup.
TBH I’m not sure we need this level of testing, I think just our usual testing of the ops will transitively cover this because compilation will fail otherwise! 😃
I think it’s probably OK to try and put together a PR and just ensure that existing CI passes. It’s understood that it’ll be an ongoing effort to manage these header lists esp as metal evolves and refactors things.
I was gonna work on fixing this as part of my PR until I saw the comment in the code that link to this issue lol.
@wusatosi In case you haven’t found out yet, for unary SFPU ops we should include sfpu_split_includes.h and emit the macro that corresponds to the op(s) at hand just before the inclusion.
Hey just an update I am still working on this.
@wusatosi thanks for picking this one up! I think the task has a few parts to it:
lib/Target/TTKernel/TTKernelToCpp.cppthere’s a helper class calledScopedModuleHelper, you’ll see today we just unconditionally emit a bunch of includes there depending on theThreadType.include/ttmlir/Target/TTKernel/TTKernelIncludesMap.h, that mapsop.getCallee() -> [StringRef includes].ScopedModuleHelperwe loop over the whole region and collect all required headers into a set, sort it in alphanumeric order and then emit the includes via verbatim op.Example of the static map (unsure if DenseMap is best here, but for now let’s go with that):
include/ttmlir/Dialect/TTKernel/IR/TTKernelOps.tdand cross reference tt-metal repo’s kernel library headers to see where they’re defined.requiredHeadersMap.@vroubtsovTT / @xanderchin to review, if you have some ideas on how this should work.
is this P2 because it has dependencies on something else? Could this become a bounty?
I’ve marked it as P2, probably everything marked as P2 will be punted out of this milestone into the next.