Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/lib/IR/BuiltinAttributes.cpp | ||
---|---|---|
919 | Why is it allocating one when it's empty? I would expect this to call Base::get with an empty ArrayRef. |
mlir/lib/IR/BuiltinAttributes.cpp | ||
---|---|---|
919 | This is to avoid an assertion error in VectorType::get. |
mlir/lib/IR/BuiltinAttributes.cpp | ||
---|---|---|
919 | It's not really a valid workaround though, because it's not creating what the user intended (meaning any number of expected invariants are broken, e.g. most of the ElementsAttr are not going to work as expected). Given that VectorType can't support zero elements, we should switch this to use TensorType, just not support empty lists (which is kind of weird), or let VectorType have zero elements. |
mlir/lib/IR/BuiltinAttributes.cpp | ||
---|---|---|
919 | As far as I understand Nicolas, the intent is to let VectorType have zero elements. @nicolasvasilache did I understand that right? And if yes, would you be willing to take a look what would be needed to avoid the assert? |
mlir/lib/IR/BuiltinAttributes.cpp | ||
---|---|---|
919 | But a similar workaround was already used in the patch where VectorType support for empty shapes was added: https://reviews.llvm.org/D114387 You're confusing MLIR vector and LLVM vectors: MLIR vector support 0-D and should work with empty in general, as I mentioned separately they already do. However LLVM does not know about this and we must convert to llvm.vector<1xT>since we use the same MLIR VectorType representation for MLIR and LLVM the type conversion when lowering to LLVM is vector<T> (for MLIR) -> vector<1xT> (for LLVM). I am still unclear what problem you are hitting, can you please send a standalone .mlir to repro? |
mlir/lib/IR/BuiltinAttributes.cpp | ||
---|---|---|
919 | ok so from offline discussion it seems you are trying to build vector<0xT>; this is indeed illegal, you want to build vector<T> for such cases with an empty shape. |
Thanks Nicolas for pointing out the real problem: we should not use VectorType::get(0, elementType) for 0-d vector. I have rewritten this part in BuiltinAttributes.cpp to already pass an ArrayRef to the getShapedType methods.
mlir/test/IR/attribute.mlir | ||
---|---|---|
525 | Can we drop the empty space from the syntax? |
Thanks for the review, and for pointing out a better way than the workaround I had :)
Why is it allocating one when it's empty? I would expect this to call Base::get with an empty ArrayRef.