Skip to content
  1. May 27, 2021
  2. May 21, 2021
  3. May 19, 2021
    • Thomas Köppe's avatar
      Add a helper function to convert LogicalResult to int for return from main · 58369fce
      Thomas Köppe authored
      At present, a lot of code contains main function bodies like "return failed(mlir::MlirOptMain(...);". This is unfortunate for two reasons: a) it uses ADL, which is maybe not what the free "failed" function was designed for; and b) it is a bit awkward to read, requring the reader to both understand the boolean nature of the value and the semantics of main's return value. (And it's also not portable, since 1 is not a portable success value.)
      
      The replacement code, `return mlir::AsMainReturnCode(mlir::MlirOptMain(...))` is a bit more self-explanatory.
      
      The change applies the new function to a few internal uses of MlirOptMain, too.
      
      Reviewed By: mehdi_amini
      
      Differential Revision: https://reviews.llvm.org/D102641
      58369fce
  4. May 05, 2021
  5. Apr 22, 2021
  6. Apr 06, 2021
  7. Apr 01, 2021
  8. Mar 19, 2021
    • Christian Sigg's avatar
      [mlir] Remove mlir-rocm-runner · a825fb2c
      Christian Sigg authored
      This change combines for ROCm what was done for CUDA in D97463, D98203, D98360, and D98396.
      
      I did not try to compile SerializeToHsaco.cpp or test mlir/test/Integration/GPU/ROCM because I don't have an AMD card. I fixed the things that had obvious bit-rot though.
      
      Reviewed By: whchung
      
      Differential Revision: https://reviews.llvm.org/D98447
      a825fb2c
  9. Mar 11, 2021
    • Alex Zinenko's avatar
      [mlir] Introduce data layout modeling subsystem · 3ba14fa0
      Alex Zinenko authored
      Data layout information allows to answer questions about the size and alignment
      properties of a type. It enables, among others, the generation of various
      linear memory addressing schemes for containers of abstract types and deeper
      reasoning about vectors. This introduces the subsystem for modeling data
      layouts in MLIR.
      
      The data layout subsystem is designed to scale to MLIR's open type and
      operation system. At the top level, it consists of attribute interfaces that
      can be implemented by concrete data layout specifications; type interfaces that
      should be implemented by types subject to data layout; operation interfaces
      that must be implemented by operations that can serve as data layout scopes
      (e.g., modules); and dialect interfaces for data layout properties unrelated to
      specific types. Built-in types are handled specially to decrease the overall
      query cost.
      
      A concrete default implementation of these interfaces is provided in the new
      Target dialect. Defaults for built-in types that match the current behavior are
      also provided.
      
      Reviewed By: rriddle
      
      Differential Revision: https://reviews.llvm.org/D97067
      3ba14fa0
    • Christian Sigg's avatar
      [mlir] Change test-gpu-to-cubin to derive from SerializeToBlobPass · bafe418d
      Christian Sigg authored
      Clean-up after D98279, remove one call to createConvertGPUKernelToBlobPass().
      
      Depends On D98203
      
      Reviewed By: mehdi_amini
      
      Differential Revision: https://reviews.llvm.org/D98360
      bafe418d
  10. Mar 05, 2021
    • Diego Caballero's avatar
      [mlir] Add 'Skip' result to Operation visitor · 2de6dbda
      Diego Caballero authored
      This patch is a follow-up on D97217. It adds a new 'Skip' result to the Operation visitor
      so that a callback can stop the ongoing visit of an operation/block/region and
      continue visiting the next one without fully interrupting the walk. Skipping is
      needed to be able to erase an operation/block in pre-order and do not continue
      visiting the internals of that operation/block.
      
      Related to the skipping mechanism, the patch also introduces the following changes:
       * Added new TestIRVisitors pass with basic testing for the IR visitors.
       * Fixed missing early increment ranges in visitor implementation.
       * Updated documentation of walk methods to include erasure information and walk
         order information.
      
      Reviewed By: rriddle
      
      Differential Revision: https://reviews.llvm.org/D97820
      2de6dbda
  11. Feb 19, 2021
    • Eugene Zhulenev's avatar
      [mlir] Add math polynomial approximation pass · f99ccf65
      Eugene Zhulenev authored
      This gives ~30x speedup compared to expanding Tanh into exp operations:
      
      ```
      name                  old cpu/op  new cpu/op  delta
      BM_mlir_Tanh_f32/10    253ns ± 3%    55ns ± 7%  -78.35%  (p=0.000 n=44+41)
      BM_mlir_Tanh_f32/100  2.21µs ± 4%  0.14µs ± 8%  -93.85%  (p=0.000 n=48+49)
      BM_mlir_Tanh_f32/1k   22.6µs ± 4%   0.7µs ± 5%  -96.68%  (p=0.000 n=32+42)
      BM_mlir_Tanh_f32/10k   225µs ± 5%     7µs ± 6%  -96.88%  (p=0.000 n=49+55)
      
      name                  old time/op             new time/op             delta
      BM_mlir_Tanh_f32/10    259ns ± 1%               56ns ± 2%  -78.31%        (p=0.000 n=41+39)
      BM_mlir_Tanh_f32/100  2.27µs ± 1%             0.14µs ± 5%  -93.89%        (p=0.000 n=46+49)
      BM_mlir_Tanh_f32/1k   22.9µs ± 1%              0.8µs ± 4%  -96.67%        (p=0.000 n=30+42)
      BM_mlir_Tanh_f32/10k   230µs ± 0%                7µs ± 3%  -96.88%        (p=0.000 n=37+55)
      ```
      
      This approximations is based on Eigen::generic_fast_tanh function
      
      Reviewed By: mehdi_amini
      
      Differential Revision: https://reviews.llvm.org/D96739
      f99ccf65
  12. Feb 09, 2021
    • River Riddle's avatar
      [mlir] Add initial support for an alias analysis framework in MLIR · b9c876bd
      River Riddle authored
      This revision adds a new `AliasAnalysis` class that represents the main alias analysis interface in MLIR. The purpose of this class is not to hold the aliasing logic itself, but to provide an interface into various different alias analysis implementations. As it evolves this should allow for users to plug in specialized alias analysis implementations for their own needs, and have them immediately usable by other analyses and transformations.
      
      This revision also adds an initial simple generic alias, LocalAliasAnalysis, that provides support for performing stateless local alias queries between values. This class is similar in scope to LLVM's BasicAA.
      
      Differential Revision: https://reviews.llvm.org/D92343
      b9c876bd
  13. Jan 28, 2021
  14. Dec 23, 2020
  15. Dec 02, 2020
    • River Riddle's avatar
      [mlir][PDL] Add support for PDL bytecode and expose PDL support to OwningRewritePatternList · abfd1a8b
      River Riddle authored
      PDL patterns are now supported via a new `PDLPatternModule` class. This class contains a ModuleOp with the pdl::PatternOp operations representing the patterns, as well as a collection of registered C++ functions for native constraints/creations/rewrites/etc. that may be invoked via the pdl patterns. Instances of this class are added to an OwningRewritePatternList in the same fashion as C++ RewritePatterns, i.e. via the `insert` method.
      
      The PDL bytecode is an in-memory representation of the PDL interpreter dialect that can be efficiently interpreted/executed. The representation of the bytecode boils down to a code array(for opcodes/memory locations/etc) and a memory buffer(for storing attributes/operations/values/any other data necessary). The bytecode operations are effectively a 1-1 mapping to the PDLInterp dialect operations, with a few exceptions in cases where the in-memory representation of the bytecode can be more efficient than the MLIR representation. For example, a generic `AreEqual` bytecode op can be used to represent AreEqualOp, CheckAttributeOp, and CheckTypeOp.
      
      The execution of the bytecode is split into two phases: matching and rewriting. When matching, all of the matched patterns are collected to avoid the overhead of re-running parts of the matcher. These matched patterns are then considered alongside the native C++ patterns, which rewrite immediately in-place via `RewritePattern::matchAndRewrite`,  for the given root operation. When a PDL pattern is matched and has the highest benefit, it is passed back to the bytecode to execute its rewriter.
      
      Differential Revision: https://reviews.llvm.org/D89107
      abfd1a8b
  16. Nov 29, 2020
    • Jacques Pienaar's avatar
      [mlir] Add a shape function library op · e534cee2
      Jacques Pienaar authored
      Op with mapping from ops to corresponding shape functions for those op
      in the library and mechanism to associate shape functions to functions.
      The mapping of operand to shape function is kept separate from the shape
      functions themselves as the operation is associated to the shape
      function and not vice versa, and one could have a common library of
      shape functions that can be used in different contexts.
      
      Use fully qualified names and require a name for shape fn lib ops for
      now and an explicit print/parse (based around the generated one & GPU
      module op ones).
      
      This commit reverts d9da4c3e. Fixes
      missing headers (don't know how that was working locally).
      
      Differential Revision: https://reviews.llvm.org/D91672
      e534cee2
    • Mehdi Amini's avatar
      Revert "[mlir] Add a shape function library op" · d9da4c3e
      Mehdi Amini authored
      This reverts commit 6dd9596b.
      
      Build is broken.
      d9da4c3e
    • Jacques Pienaar's avatar
      [mlir] Add a shape function library op · 6dd9596b
      Jacques Pienaar authored
      Op with mapping from ops to corresponding shape functions for those op
      in the library and mechanism to associate shape functions to functions.
      The mapping of operand to shape function is kept separate from the shape
      functions themselves as the operation is associated to the shape
      function and not vice versa, and one could have a common library of
      shape functions that can be used in different contexts.
      
      Use fully qualified names and require a name for shape fn lib ops for
      now and an explicit print/parse (based around the generated one & GPU
      module op ones).
      
      Differential Revision: https://reviews.llvm.org/D91672
      6dd9596b
  17. Nov 23, 2020
    • MaheshRavishankar's avatar
      [mlir][Linalg] Fuse sequence of Linalg operation (on buffers) · e65a5e5b
      MaheshRavishankar authored
      Enhance the tile+fuse logic to allow fusing a sequence of operations.
      
      Make sure the value used to obtain tile shape is a
      SubViewOp/SubTensorOp. Current logic used to get the bounds of loop
      depends on the use of `getOrCreateRange` method on `SubViewOp` and
      `SubTensorOp`. Make sure that the value/dim used to compute the range
      is from such ops.  This fix is a reasonable WAR, but a btter fix would
      be to make `getOrCreateRange` method be a method of `ViewInterface`.
      
      Differential Revision: https://reviews.llvm.org/D90991
      e65a5e5b
  18. Nov 20, 2020
  19. Nov 17, 2020
    • Aart Bik's avatar
      [mlir] [sparse] start of sparse tensor compiler support · eced4a8e
      Aart Bik authored
      As discussed in https://llvm.discourse.group/t/mlir-support-for-sparse-tensors/2020
      this CL is the start of sparse tensor compiler support in MLIR. Starting with a
      "dense" kernel expressed in the Linalg dialect together with per-dimension
      sparsity annotations on the tensors, the compiler automatically lowers the
      kernel to sparse code using the methods described in Fredrik Kjolstad's thesis.
      
      Many details are still TBD. For example, the sparse "bufferization" is purely
      done locally since we don't have a global solution for propagating sparsity
      yet. Furthermore, code to input and output the sparse tensors is missing.
      Nevertheless, with some hand modifications, the generated MLIR can be
      easily converted into runnable code already.
      
      Reviewed By: nicolasvasilache, ftynse
      
      Differential Revision: https://reviews.llvm.org/D90994
      eced4a8e
  20. Nov 16, 2020
    • Sean Silva's avatar
      [mlir] Add DecomposeCallGraphTypes pass. · 7c62c631
      Sean Silva authored
      This replaces the old type decomposition logic that was previously mixed
      into bufferization, and makes it easily accessible.
      
      This also deletes TestFinalizingBufferize, because after we remove the type
      decomposition, it doesn't do anything that is not already provided by
      func-bufferize.
      
      Differential Revision: https://reviews.llvm.org/D90899
      7c62c631
  21. Nov 11, 2020
  22. Nov 09, 2020
  23. Nov 08, 2020
  24. Nov 05, 2020
  25. Nov 02, 2020
    • Sean Silva's avatar
      [mlir][Bufferize] Rename TestBufferPlacement to TestFinalizingBufferize · 773ad135
      Sean Silva authored
      BufferPlacement is no longer part of bufferization. However, this test
      is an important test of "finalizing" bufferize passes.
      A "finalizing" bufferize conversion is one that performs a "full"
      conversion and expects all tensors to be gone from the program. This in
      particular involves rewriting funcs (including block arguments of the
      contained region), calls, and returns. The unique property of finalizing
      bufferization passes is that they cannot be done via a local
      transformation with suitable materializations to ensure composability
      (as other bufferization passes do). For example, if a call is
      rewritten, the callee needs to be rewritten otherwise the IR will end up
      invalid. Thus, finalizing bufferization passes require an atomic change
      to the entire program (e.g. the whole module).
      
      This new designation makes it clear also that it shouldn't be testing
      bufferization of linalg ops, so the tests have been updated to not use
      linalg.generic ops. (linalg.copy is still used as the "copy" op for
      copying into out-params)
      
      Differential Revision: https://reviews.llvm.org/D89979
      773ad135
  26. Oct 30, 2020
    • ergawy's avatar
      [MLIR][SPIRV] Start module combiner. · 90a8260c
      ergawy authored
      This commit adds a new library that merges/combines a number of spv
      modules into a combined one. The library has a single entry point:
      combine(...).
      
      To combine a number of MLIR spv modules, we move all the module-level ops
      from all the input modules into one big combined module. To that end, the
      combination process can proceed in 2 phases:
      
        (1) resolving conflicts between pairs of ops from different modules
        (2) deduplicate equivalent ops/sub-ops in the merged module. (TODO)
      
      This patch implements only the first phase.
      
      Reviewed By: antiagainst
      
      Differential Revision: https://reviews.llvm.org/D90477
      90a8260c
    • Geoffrey Martin-Noble's avatar
      Revert "[MLIR][SPIRV] Start module combiner." · 1142eaed
      Geoffrey Martin-Noble authored
      This reverts commit 27324f28.
      
      Shared libs build is broken linking lib/libMLIRSPIRVModuleCombiner.so:
      
      ```
      ModuleCombiner.cpp:
        undefined reference to `mlir::spirv::ModuleOp::addressing_model()
      ```
      
      https://buildkite.com/mlir/mlir-core/builds/8988#e3d966b9-ea43-492e-a192-b28e71e9a15b
      1142eaed
    • ergawy's avatar
      [MLIR][SPIRV] Start module combiner. · 27324f28
      ergawy authored
      This commit adds a new library that merges/combines a number of spv
      modules into a combined one. The library has a single entry point:
      combine(...).
      
      To combine a number of MLIR spv modules, we move all the module-level ops
      from all the input modules into one big combined module. To that end, the
      combination process can proceed in 2 phases:
      
        (1) resolving conflicts between pairs of ops from different modules
        (2) deduplicate equivalent ops/sub-ops in the merged module. (TODO)
      
      This patch implements only the first phase.
      
      Reviewed By: antiagainst
      
      Differential Revision: https://reviews.llvm.org/D90477
      27324f28
    • Mehdi Amini's avatar
      Revert "[MLIR][SPIRV] Start module combiner" · b3430ed0
      Mehdi Amini authored
      This reverts commit 316593ce.
      Build is broken with:
      
      TestModuleCombiner.cpp:(.text._ZN12_GLOBAL__N_122TestModuleCombinerPass14runOnOperationEv+0x195): undefined reference to `mlir::spirv::combine(llvm::MutableArrayRef<mlir::spirv::ModuleOp>, mlir::OpBuilder&, llvm::function_ref<void (mlir::spirv::ModuleOp, llvm::StringRef, llvm::StringRef)>)'
      b3430ed0
    • ergawy's avatar
      [MLIR][SPIRV] Start module combiner · 316593ce
      ergawy authored
      This commit adds a new library that merges/combines a number of spv
      modules into a combined one. The library has a single entry point:
      combine(...).
      
      To combine a number of MLIR spv modules, we move all the module-level ops
      from all the input modules into one big combined module. To that end, the
      combination process can proceed in 2 phases:
      
        (1) resolving conflicts between pairs of ops from different modules
        (2) deduplicate equivalent ops/sub-ops in the merged module. (TODO)
      
      This patch implements only the first phase.
      
      Reviewed By: antiagainst
      
      Differential Revision: https://reviews.llvm.org/D90022
      316593ce
  27. Oct 29, 2020
    • Nicolas Vasilache's avatar
      [mlir][Linalg] Make Linalg fusion a test pass · 9b17bf2e
      Nicolas Vasilache authored
      Linalg "tile-and-fuse" is currently exposed as a Linalg pass "-linalg-fusion" but only the mechanics of the transformation are currently relevant.
      Instead turn it into a "-test-linalg-greedy-fusion" pass which performs canonicalizations to enable more fusions to compose.
      This allows dropping the OperationFolder which is not meant to be used with the pattern rewrite infrastructure.
      
      Differential Revision: https://reviews.llvm.org/D90394
      9b17bf2e
  28. Oct 28, 2020
  29. Oct 24, 2020
  30. Oct 23, 2020
Loading