[PATCH] D74284: [mlir][VectorOps][EDSC] Add EDSC for VectorOps
Nicolas Vasilache via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 8 11:05:03 PST 2020
nicolasvasilache marked 2 inline comments as done.
nicolasvasilache added inline comments.
================
Comment at: mlir/include/mlir/IR/AffineMap.h:72
+ static SmallVector<AffineMap, 4>
+ inferFromExprList(ArrayRef<SmallVector<AffineExpr, 4>> exprsList);
+
----------------
I am really not happy about this duplication but I tried a bunch of different things and could not get it down to one single form.
@rriddle @mehdi_amini suggestions most welcome!
================
Comment at: mlir/lib/Dialect/VectorOps/EDSC/Builders.cpp:30
+ IndexingExprs{A.getExprs(), B.getExprs(), C.getExprs()},
+ ArrayRef<StringRef>{functional::map(toString, iteratorTypes)});
+}
----------------
One may think it is not great to materialize here but after spending too much time, I got to the following and still got compilation errors with issues converting to `const StringRef *`.
At this point I find it counterproductive and prefer the current form.
```
using IteratorTypeList = ArrayRef<IteratorType>;
class iterator_value_iterator final
: llvm::mapped_iterator<IteratorTypeList::iterator,
StringRef (*)(IteratorType)> {
public:
explicit iterator_value_iterator(IteratorTypeList::iterator it)
: llvm::mapped_iterator<IteratorTypeList::iterator,
StringRef (*)(IteratorType)>(
it, [](IteratorType iter) { return toString(iter); }) {}
StringRef operator*() const { return toString(*this->I); }
};
llvm::iterator_range<iterator_value_iterator>
makeRange(ArrayRef<IteratorType> iteratorTypes) {
return llvm::make_range(iterator_value_iterator(iteratorTypes.begin()),
iterator_value_iterator(iteratorTypes.end()));
}
Value mlir::edsc::ops::vector_contraction(
StructuredIndexed A, StructuredIndexed B, StructuredIndexed C,
ArrayRef<IteratorType> iteratorTypes) {
using IndexingExprs = ArrayRef<ArrayRef<AffineExpr>>;
auto range = makeRange(iteratorTypes);
return vector_contract(
A.getValue(), B.getValue(), C.getValue(),
IndexingExprs{A.getExprs(), B.getExprs(), C.getExprs()},
ArrayRef<StringRef>{range.begin(), range.end()});
}
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74284/new/
https://reviews.llvm.org/D74284
More information about the llvm-commits
mailing list