[PATCH] D72555: [mlir][Linalg] Update the semantics, verifier and test for Linalg with tensors.

Nicolas Vasilache via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 10 23:29:55 PST 2020


nicolasvasilache created this revision.
Herald added subscribers: llvm-commits, lucyrfox, mgester, arpith-jacob, antiagainst, shauheen, burmako, jpienaar, rriddle, mehdi_amini, bmahjour.
Herald added a project: LLVM.
nicolasvasilache edited the summary of this revision.
nicolasvasilache added reviewers: ftynse, jpienaar, mravishankar, asaadaldien, pifon2a, herhut, stellaraccident, sanjoy.
nicolasvasilache updated this revision to Diff 237485.
nicolasvasilache added a comment.

clang-format.


This diff fixes issues with the semantics of linalg.generic on tensors that appeared when converting directly from HLO to linalg.generic.
The changes are self-contained within MLIR and can be captured and tested independently of XLA.

The linalg.generic and indexed_generic are updated to:

   To allow progressive lowering from the value world (a.k.a tensor values) to 
  the buffer world (a.k.a memref values), a `linalg.generic` op accepts
  mixing input and output ranked tensor values with input and output memrefs.
  
  ```mlir
    %1 = linalg.generic #trait_attribute %A, %B, %C {other-attributes} :
      tensor<?x?xf32>,
      memref<?x?xf32, stride_specification>,
      tensor<?x?xf32>
      -> (tensor<?x?xf32>)




  In this case, the number of outputs (args_out) must match the sum of (1) the
  number of output buffer operands and (2) the number of tensor return values.
  The semantics is that the `linalg.indexed_generic` op produces (i.e.
  allocates and fills) its return values.
  
  Tensor values must be legalized by a buffer allocation pass before most
  transformations can be applied. Such legalization moves tensor return values
  into output buffer operands and updates the region argument accordingly.
  
  Transformations that create control-flow around linalg.indexed_generic
  operations are not expected to mix with tensors because SSA values do not
  escape naturally. Still, transformations and rewrites that take advantage of
  tensor SSA values are expected to be useful and will be added in the near
  future.

  


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72555

Files:
  mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
  mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h
  mlir/include/mlir/Dialect/Linalg/Utils/Utils.h
  mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp
  mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
  mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp
  mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp
  mlir/lib/Dialect/Linalg/Transforms/LinalgTransforms.cpp
  mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
  mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
  mlir/test/Dialect/Linalg/invalid.mlir
  mlir/test/Dialect/Linalg/roundtrip.mlir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72555.237485.patch
Type: text/x-patch
Size: 54906 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200111/ffde66e8/attachment.bin>


More information about the llvm-commits mailing list