[PATCH] D75146: [mlir][Linalg] NFC - Refactor LinalgStructuredOps towards "named" Linalg ops
River Riddle via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 25 15:35:46 PST 2020
rriddle added inline comments.
================
Comment at: mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp:914
-static SmallVector<AffineExpr, 4> concat(ArrayRef<AffineExpr> a,
- ArrayRef<AffineExpr> b) {
+SmallVector<AffineExpr, 4> mlir::linalg::concat(ArrayRef<AffineExpr> a,
+ ArrayRef<AffineExpr> b) {
----------------
nicolasvasilache wrote:
> rriddle wrote:
> > Was there a problem with using llvm::concat?
> This
> ```
> SmallVector<AffineExpr, 4> mlir::linalg::concat(ArrayRef<AffineExpr> a,
> ArrayRef<AffineExpr> b) {
> auto rangeA = llvm::make_range(a.begin(), a.end());
> auto rangeB = llvm::make_range(b.begin(), b.end());
> auto concatRanges = llvm::concat<AffineExpr>(rangeA, rangeB);
> return llvm::to_vector<4>(concatRanges);
> }
> ```
>
> fails with
> ```
> ERROR: third_party/llvm/llvm-project/llvm/include/llvm/ADT/STLExtras.h:855:12 cannot initialize return object of type 'mlir::AffineExpr *' with an rvalue of type 'const mlir::AffineExpr *'
> return &*Begin;
> ^~~~~~~
> third_party/llvm/llvm-project/llvm/include/llvm/ADT/STLExtras.h:865:27 in instantiation of function template specialization 'llvm::concat_iterator<mlir::AffineExpr, const mlir::AffineExpr *, const mlir::AffineExpr *>::getHelper<1>' requested here
> &concat_iterator::getHelper<Ns>...};
> ^
> third_party/llvm/llvm-project/llvm/include/llvm/ADT/STLExtras.h:892:12 in instantiation of function template specialization 'llvm::concat_iterator<mlir::AffineExpr, const mlir::AffineExpr *, const mlir::AffineExpr *>::get<0, 1>' requested here
> return get(std::index_sequence_for<IterTs...>());
> ^
> third_party/crosstool/v18/stable/toolchain/include/c++/v1/memory:3162:75 in instantiation of member function 'llvm::concat_iterator<mlir::AffineExpr, const mlir::AffineExpr *, const mlir::AffineExpr *>::operator*' requested here
> ::new (static_cast<void*>(_VSTD::addressof(*__r))) value_type(*__f);
> ^
> third_party/llvm/llvm-project/llvm/include/llvm/ADT/SmallVector.h:279:10 in instantiation of function template specialization 'std::__u::uninitialized_copy<llvm::concat_iterator<mlir::AffineExpr, const mlir::AffineExpr *, const mlir::AffineExpr *>, mlir::AffineExpr *>' requested here
> std::uninitialized_copy(I, E, Dest);
> ^
> third_party/llvm/llvm-project/llvm/include/llvm/ADT/SmallVector.h:392:11 in instantiation of function template specialization 'llvm::SmallVectorTemplateBase<mlir::AffineExpr, true>::uninitialized_copy<llvm::concat_iterator<mlir::AffineExpr, const mlir::AffineExpr *, const mlir::AffineExpr *>, mlir::AffineExpr *>' requested here
> this->uninitialized_copy(in_start, in_end, this->end());
> ^
> third_party/llvm/llvm-project/llvm/include/llvm/ADT/SmallVector.h:856:11 in instantiation of function template specialization 'llvm::SmallVectorImpl<mlir::AffineExpr>::append<llvm::concat_iterator<mlir::AffineExpr, const mlir::AffineExpr *, const mlir::AffineExpr *>, void>' requested here
> this->append(S, E);
> ^
> third_party/llvm/llvm-project/llvm/include/llvm/ADT/SmallVector.h:918:10 in instantiation of function template specialization 'llvm::SmallVector<mlir::AffineExpr, 4>::SmallVector<llvm::concat_iterator<mlir::AffineExpr, const mlir::AffineExpr *, const mlir::AffineExpr *>, void>' requested here
> return {std::begin(Range), std::end(Range)};
> ^
> third_party/llvm/llvm-project/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp:919:16 in instantiation of function template specialization 'llvm::to_vector<4, llvm::detail::concat_range<mlir::AffineExpr, llvm::iterator_range<const mlir::AffineExpr *> &, llvm::iterator_range<const mlir::AffineExpr *> &> &>' requested here
> return llvm::to_vector<4>(concatRanges);
> ```
>
> What am I missing?
I think you would need to do `llvm::concat<const AffineExpr>(...)`, given that ArrayRef holds values of `const T`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D75146/new/
https://reviews.llvm.org/D75146
More information about the llvm-commits
mailing list