Skip to content

Commit

Permalink
[mlir][Linalg] Uniformize linalg.generic with named ops.
Browse files Browse the repository at this point in the history
This revision allows representing a reduction at the level of linalg on tensors for generic ops by uniformizing with the named ops approach.
  • Loading branch information
Nicolas Vasilache committed Sep 22, 2020
1 parent 0304c6d commit ed22913
Show file tree
Hide file tree
Showing 36 changed files with 1,307 additions and 1,170 deletions.
29 changes: 9 additions & 20 deletions mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class ParallelOp;
namespace edsc {
inline void defaultRegionBuilder(ValueRange args) {}

/// Build a `linalg.generic` op with the specified `inputs`, `outputs` and
/// `region`.
/// Build a `linalg.generic` op with the specified `inputs`, `outputBuffers`,
/// `initTensors`, `resultTensorsTypes` and `region`.
///
/// `otherValues` and `otherAttributes` may be passed and will be appended as
/// operands and attributes respectively.
Expand All @@ -41,14 +41,15 @@ inline void defaultRegionBuilder(ValueRange args) {}
///
/// 1. `inputs` may contain StructuredIndexed that capture either buffer or
/// tensor values.
/// 2. `outputs` may contain StructuredIndexed that capture either buffer values
/// or tensor types. If both buffer values and tensor types are present, then
/// all buffer values must appear before any tensor type. Without this
/// restriction output tensor results would need to be reordered, which would
/// result in surprising behavior when combined with region definition.
/// 2. `outputsBuffers` may contain StructuredIndexed that capture buffer
/// values.
/// 3. `initTensors` contain tensor values, without indexing maps.
/// 4. `resultTensorTypes` may contain StructuredIndexed that capture return
/// tensor types.
Operation *makeGenericLinalgOp(
ArrayRef<IteratorType> iteratorTypes, ArrayRef<StructuredIndexed> inputs,
ArrayRef<StructuredIndexed> outputs,
ArrayRef<StructuredIndexed> outputBuffers, ArrayRef<Value> initTensors,
ArrayRef<StructuredIndexed> resultTensorTypes,
function_ref<void(ValueRange)> regionBuilder = defaultRegionBuilder,
ArrayRef<Value> otherValues = {}, ArrayRef<Attribute> otherAttributes = {});

Expand Down Expand Up @@ -134,18 +135,6 @@ Operation *
linalg_generic_matmul(Value vA, Value vB, Value vC,
MatmulRegionBuilder regionBuilder = macRegionBuilder);

/// Build a linalg.generic, under the current ScopedContext, at the current
/// insert point, that computes:
/// ```
/// (m, n, k) = (par, par, seq)
/// |
/// | C(m, n) = sum_k(A(m, k) * B(k, n))
/// ```
/// and returns the tensor `C`.
Operation *
linalg_generic_matmul(Value vA, Value vB, RankedTensorType tC,
MatmulRegionBuilder regionBuilder = mulRegionBuilder);

/// Build a linalg.generic, under the current ScopedContext, at the current
/// insert point, that computes:
/// ```
Expand Down
Loading

0 comments on commit ed22913

Please sign in to comment.