This revision adds EDSC support for VectorOps to enable the creation of a vector_matmul declaratively. The vector_matmul is a simple configuration
 of the vector.contract op that follows the StructuredOps abstraction.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
| mlir/include/mlir/IR/AffineMap.h | ||
|---|---|---|
| 72 | 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. | |
| mlir/lib/Dialect/VectorOps/EDSC/Builders.cpp | ||
| 31 | 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 *. 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()});
} | |
| mlir/include/mlir/IR/AffineMap.h | ||
|---|---|---|
| 66 | You wrote "Returns the AffineMap" but it returns a vector of AffineMap? | |
| mlir/lib/Dialect/VectorOps/EDSC/Builders.cpp | ||
| 31 | What about materializing directly as an Array of StringAttr here instead of doing it in the builder? | |
| mlir/lib/IR/AffineMap.cpp | ||
| 147 | Using templates could avoid the temporary exprsVector, but I'm not sure it really matters... | |
| mlir/lib/Dialect/VectorOps/EDSC/Builders.cpp | ||
|---|---|---|
| 31 | That falls into the category of multiple attrs and having builders for multiple combinations of attrs vs underlying values. Then orthogonally, the materialization is really a "proper API with ranges" issues on which I gave up in this revision. | |
| mlir/lib/IR/AffineMap.cpp | ||
| 147 | Good enough, thanks! | |
| mlir/lib/Dialect/VectorOps/EDSC/Builders.cpp | ||
|---|---|---|
| 31 | I'm not sure what you mean: your builder API is encouraging a more costly model: you materialize two SmallVector instead of one. | |
You wrote "Returns the AffineMap" but it returns a vector of AffineMap?