scf.for used to only support 1:1 type conversion, this patch add support for 1:N type conversion.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp | ||
---|---|---|
87 | Do we really need to set the attribute here? It breaks a CHECK test with a random attribute attached. |
Thanks for adding this functionality so quickly, Peiming!
Alex, for context, we will need this to complete https://reviews.llvm.org/D136286
(where we found that 1:N does not work for for loops yet)
mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp | ||
---|---|---|
35 | Can we swap the if (inputs.size() == 1) here or the if (inputs.size() != 1) above such that the if-true is always e.g. the 1:N and the fall through is the 1:1, that feels a bit more symmetric while reading these two methods | |
100 | an unresolved |
This clearly needs a test.
mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp | ||
---|---|---|
19 | Please document the methods. | |
21 | Nit: no need to prefix casts with llvm::, they are reexported. | |
41–48 | Nit: don't specify the number of stack elements in SmallVector unless you have a strong reason to pick one. Legacy code may have a number, but you don't need to replicate it. | |
51–89 | This entire comment is obsoleted by new code, there is no cloning anymore. | |
87 | Transformations are not required to propagate discardable attributes, but it's a sort of a good tone if they do. Also nit: it shouldn't be necessary to explicitly static_cast, all concrete op classes overload operator-> to provide access to Operation *. | |
90 | Thou shalt not modify IR in patterns without using the rewriter. The rewriter may be keeping track of the blocks created in the constructor and will have a dangling pointer unless it knows the block has been erased. | |
101 | It is preferable for this to go through getTypeConverter().materializeSourceConversion instead so it composes with whatever kind of casts the caller wants to use. |
address comments
mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp | ||
---|---|---|
41–48 | Good to know! |
Please document the methods.