- Fix ODS framework to suppress build methods that infer result types and are ambiguous with collective variants. This applies to operations with a single variadic inputs whose result types can be inferred.
- Extended OpBuildGenTest to test these kinds of ops.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Seems like this will prevent the collision in the short term, but this solution doesn't seem like it will scale as builders get more complex. I'm not opposed to a special case here, but I'd feel more comfortable if there was a more general structure in place to prevent this from scaling to lots of special cases.
I agree. A more general solution might be to generate all "collective" variants first, and then have a way for the build methods that will be ambiguous with any of them automatically filtered out, so that we don't have to guard their generation, just their emission. That might need the OpMethodSignature to have more structure than the current string members. I will file a bug for this assuming folks agree.
Why not have opClass.newMethod flag this? If adding a new method to the class with the same signature, flag it (return nullptr or some such, depending on where the collision occurs it is either fine or an error). Start with the build methods users requested first and then add autogenerated ones as long as they don't conflict. Then we don't have to do gymnastics here. I'd say even the non-collective ones are the more user friendly ones. Although in cases of conflict it provides the same signature so perhaps it doesn't matter which one gets generated.
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp | ||
---|---|---|
235 | s/of/if/ |
That scheme would work as well. Although note ambiguity can come in 2 forms: (a) 2 different methods with exactly same signature (in which case both should be equivalent and generating any one of them is ok) and (b) 2 methods, one having a prefix of arguments as the other and the rest of the arguments in the other all have default values. In such a case, we want to preserve the second one (with more arguments). So ordering the generation of these methods will be important as well if we go with eager pruning. Otherwise, we just record all of them, and do pruning of the ambiguous ones at emission time.
all have default values.
Oh yeah, that gets nasty in checking too. Almost makes me think of fluent style builders ;-)
LG to avoid current issues and we can refactor to avoid it in a more structured way post.
Thanks. Filed https://bugs.llvm.org/show_bug.cgi?id=47095 to tract the more general mechanism for doing this.
s/of/if/