Skip to content
  1. Dec 02, 2020
    • Christian Sigg's avatar
      Add `Operation* OpState::operator->()` to provide more convenient access to members of Operation. · c4a04059
      Christian Sigg authored
      Given that OpState already implicit converts to Operator*, this seems reasonable.
      
      The alternative would be to add more functions to OpState which forward to Operation.
      
      Reviewed By: rriddle, ftynse
      
      Differential Revision: https://reviews.llvm.org/D92266
      c4a04059
    • Alex Zinenko's avatar
      [OpenMPIRBuilder] forward arguments as pointers to outlined function · 240dd924
      Alex Zinenko authored
      OpenMPIRBuilder::createParallel outlines the body region of the parallel
      construct into a new function that accepts any value previously defined outside
      the region as a function argument. This function is called back by OpenMP
      runtime function __kmpc_fork_call, which expects trailing arguments to be
      pointers. If the region uses a value that is not of a pointer type, e.g. a
      struct, the produced code would be invalid. In such cases, make createParallel
      emit IR that stores the value on stack and pass the pointer to the outlined
      function instead. The outlined function then loads the value back and uses as
      normal.
      
      Reviewed By: jdoerfert, llitchev
      
      Differential Revision: https://reviews.llvm.org/D92189
      240dd924
    • River Riddle's avatar
      [mlir][PDL] Use .getOperation() when construction SuccessorRange to avoid... · 8affe881
      River Riddle authored
      [mlir][PDL] Use .getOperation() when construction SuccessorRange to avoid ambiguous constructor in GCC5
      8affe881
    • River Riddle's avatar
    • 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
  2. Dec 01, 2020
    • Eugene Zhulenev's avatar
      [mlir] AsyncRuntime: disable threading until test flakiness is fixed · 9edcedf7
      Eugene Zhulenev authored
      ExecutionEngine/LLJIT do not run globals destructors in loaded dynamic libraries when destroyed, and threads managed by ThreadPool can race with program termination, and it leads to segfaults.
      
      TODO: Re-enable threading after fixing a problem with destructors, or removing static globals from dynamic library.
      
      Differential Revision: https://reviews.llvm.org/D92368
      9edcedf7
    • Sean Silva's avatar
      [mlir] Small cleanups to func-bufferize/finalizing-bufferize · 774f1d3f
      Sean Silva authored
      - Address TODO in scf-bufferize: the argument materialization issue is
        now fixed and the code is now in Transforms/Bufferize.cpp
      - Tighten up finalizing-bufferize to avoid creating invalid IR when
        operand types potentially change
      - Tidy up the testing of func-bufferize, and move appropriate tests
        to a new finalizing-bufferize.mlir
      - The new stricter checking in finalizing-bufferize revealed that we
        needed a DimOp conversion pattern (found when integrating into npcomp).
        Previously, the converion infrastructure was blindly changing the
        operand type during finalization, which happened to work due to
        DimOp's tensor/memref polymorphism, but is generally not encouraged
        (the new pattern is the way to tell the conversion infrastructure that
        it is legal to change that type).
      774f1d3f
  3. Nov 30, 2020
    • Nicolas Vasilache's avatar
      [mlir][LLVMIR] Add support for InlineAsmOp · 047400ed
      Nicolas Vasilache authored
      The InlineAsmOp mirrors the underlying LLVM semantics with a notable
      exception: the embedded `asm_string` is not allowed to define or reference
      any symbol or any global variable: only the operands of the op may be read,
      written, or referenced.
      Attempting to define or reference any symbol or any global behavior is
      considered undefined behavior at this time.
      
      The asm dialect syntax is currently specified with an integer (0 [default] for the "att dialect", 1 for the intel dialect) to circumvent the ODS limitation on string enums.
      
      Translation to LLVM is provided and raises the fact that the asm constraints string must be well-formed with respect to in/out operands. No check is performed on the asm_string.
      
      An InlineAsm instruction in LLVM is a special call operation to a function that is constructed on the fly.
      It does not fit the current model of MLIR calls with symbols.
      As a consequence, the current implementation constructs the function type in ModuleTranslation.cpp.
      This should be refactored in the future.
      
      The mlir-cpu-runner is augmented with the global initialization of the X86 asm parser to allow proper execution in JIT mode. Previously, only the X86 asm printer was initialized.
      
      Differential revision: https://reviews.llvm.org/D92166
      047400ed
    • Stella Laurenzo's avatar
      [mlir][CAPI] Convert the rest of the API int -> bool. · 62195b75
      Stella Laurenzo authored
      * Follows on https://reviews.llvm.org/D92193
      * I had a mid-air collision with some additional occurrences and then noticed that there were a lot more. Think I got them all.
      
      Differential Revision: https://reviews.llvm.org/D92292
      62195b75
    • Stella Laurenzo's avatar
      [mlir][Python] Add an Operation.result property. · ba0fe76b
      Stella Laurenzo authored
      * If ODS redefines this, it is fine, but I have found this accessor to be universally useful in the old npcomp bindings and I'm closing gaps that will let me switch.
      
      Differential Revision: https://reviews.llvm.org/D92287
      ba0fe76b
    • Stella Laurenzo's avatar
      [mlir][Python] Python API cleanups and additions found during code audit. · bd2083c2
      Stella Laurenzo authored
      * Add capsule get/create for Attribute and Type, which already had capsule interop defined.
      * Add capsule interop and get/create for Location.
      * Add Location __eq__.
      * Use get() and implicit cast to go from PyAttribute, PyType, PyLocation to MlirAttribute, MlirType, MlirLocation (bundled with this change because I didn't want to continue the pattern one more time).
      
      Differential Revision: https://reviews.llvm.org/D92283
      bd2083c2
    • George's avatar
      Use bool in place of int for boolean things in the C API · 8b6bea9b
      George authored
      `bool` is pretty well supported by now in C, and using it in place of `int` is not only more semantically accurate, but also improves automatic bindings for languages like Swift.
      
      There is more discussion here: https://llvm.discourse.group/t/adding-mlirbool-to-c-bindings/2280/5
      
      Reviewed By: ftynse, mehdi_amini
      
      Differential Revision: https://reviews.llvm.org/D92193
      8b6bea9b
  4. 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
    • George's avatar
      Use `const` for array pointers in `StandardTypes.h` · 7f521318
      George authored
      This mirrors the underlying C++ api.
      
      Reviewed By: mehdi_amini
      
      Differential Revision: https://reviews.llvm.org/D92252
      7f521318
    • 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
  5. Nov 28, 2020
  6. Nov 27, 2020
  7. Nov 26, 2020
  8. Nov 25, 2020
  9. Nov 24, 2020
    • Aart Bik's avatar
      [mlir][sparse] generalize invariant expression handling in sparse compiler · b228e2bd
      Aart Bik authored
      Generalizes invariant handling to anything defined outside the Linalg op
      (parameters and SSA computations). Fixes bug that was using parameter number
      as tensor number.
      
      Reviewed By: penpornk
      
      Differential Revision: https://reviews.llvm.org/D91985
      b228e2bd
    • Alex Zinenko's avatar
      [mlir] Add conversion from SCF parallel loops to OpenMP · 119545f4
      Alex Zinenko authored
      Introduce a conversion pass from SCF parallel loops to OpenMP dialect
      constructs - parallel region and workshare loop. Loops with reductions are not
      supported because the OpenMP dialect cannot model them yet.
      
      The conversion currently targets only one level of parallelism, i.e. only
      one top-level `omp.parallel` operation is produced even if there are nested
      `scf.parallel` operations that could be mapped to `omp.wsloop`. Nested
      parallelism support is left for future work.
      
      Reviewed By: kiranchandramohan
      
      Differential Revision: https://reviews.llvm.org/D91982
      119545f4
    • Nicolas Vasilache's avatar
      [mlir] NFC - Refactor and expose a helper printOffsetSizesAndStrides helper function. · c2470810
      Nicolas Vasilache authored
      Print part of an op of the form:
      ```
        <optional-offset-prefix>`[` offset-list `]`
        <optional-size-prefix>`[` size-list `]`
        <optional-stride-prefix>[` stride-list `]`
      ```
      
      Also address some leftover nits.
      
      Differential revision: https://reviews.llvm.org/D92031
      c2470810
    • Nicolas Vasilache's avatar
      [mlir] NFC - Refactor and expose a parsing helper for OffsetSizeAndStrideInterface · b6c71c13
      Nicolas Vasilache authored
      Parse trailing part of an op of the form:
      ```
        <optional-offset-prefix>`[` offset-list `]`
        <optional-size-prefix>`[` size-list `]`
        <optional-stride-prefix>[` stride-list `]`
      ```
      Each entry in the offset, size and stride list either resolves to an integer
      constant or an operand of index type.
      Constants are added to the `result` as named integer array attributes with
      name `OffsetSizeAndStrideOpInterface::getStaticOffsetsAttrName()` (resp.
      `getStaticSizesAttrName()`, `getStaticStridesAttrName()`).
      
      Append the number of offset, size and stride operands to `segmentSizes`
      before adding it to `result` as the named attribute:
      `OpTrait::AttrSizedOperandSegments<void>::getOperandSegmentSizeAttr()`.
      Offset, size and stride operands resolution occurs after `preResolutionFn`
      to give a chance to leading operands to resolve first, after parsing the
      types.
      ```
      ParseResult parseOffsetsSizesAndStrides(
          OpAsmParser &parser, OperationState &result, ArrayRef<int> segmentSizes,
          llvm::function_ref<ParseResult(OpAsmParser &, OperationState &)>
              preResolutionFn = nullptr,
          llvm::function_ref<ParseResult(OpAsmParser &)> parseOptionalOffsetPrefix =
              nullptr,
          llvm::function_ref<ParseResult(OpAsmParser &)> parseOptionalSizePrefix =
              nullptr,
          llvm::function_ref<ParseResult(OpAsmParser &)> parseOptionalStridePrefix =
              nullptr);
      ```
      
      Differential revision: https://reviews.llvm.org/D92030
      b6c71c13
    • zhanghb97's avatar
      [mlir][Python] Sync Python bindings with C API MlirStringRef modification. · 5f0c1e38
      zhanghb97 authored
      MLIR C API use the `MlirStringRef` instead of `const char *` for the string type now. This patch sync the Python bindings with the C API modification.
      
      Differential Revision: https://reviews.llvm.org/D92007
      5f0c1e38
    • Tei Jeong's avatar
      Fix CalibratedQuantizedType's print function to match parser · 76006326
      Tei Jeong authored
      Reviewed By: liufengdb
      
      Differential Revision: https://reviews.llvm.org/D92034
      76006326
    • Stella Laurenzo's avatar
      [mlir] Add Tosa dialect const folder for tosa.const. · db9713cd
      Stella Laurenzo authored
      * Was missed in the initial submission and is required for a ConstantLike op.
      * Also adds a materializeConstant hook to preserve it.
      * Tightens up the argument constraint on tosa.const to match what is actually legal.
      
      Differential Revision: https://reviews.llvm.org/D92040
      db9713cd
    • Nicolas Vasilache's avatar
      [mlir] NFC - Expose an OffsetSizeAndStrideOpInterface · a8de412f
      Nicolas Vasilache authored
      This revision will make it easier to create new ops base on the strided memref abstraction outside of the std dialect.
      
      OffsetSizeAndStrideOpInterface is an interface for ops that allow specifying mixed dynamic and static offsets, sizes and strides variadic operands.
          Ops that implement this interface need to expose the following methods:
            1. `getArrayAttrRanks` to specify the length of static integer
                attributes.
            2. `offsets`, `sizes` and `strides` variadic operands.
            3. `static_offsets`, resp. `static_sizes` and `static_strides` integer
                array attributes.
      
          The invariants of this interface are:
            1. `static_offsets`, `static_sizes` and `static_strides` have length
                exactly `getArrayAttrRanks()`[0] (resp. [1], [2]).
            2. `offsets`, `sizes` and `strides` have each length at most
               `getArrayAttrRanks()`[0] (resp. [1], [2]).
            3. if an entry of `static_offsets` (resp. `static_sizes`,
               `static_strides`) is equal to a special sentinel value, namely
               `ShapedType::kDynamicStrideOrOffset` (resp. `ShapedType::kDynamicSize`,
               `ShapedType::kDynamicStrideOrOffset`), then the corresponding entry is
               a dynamic offset (resp. size, stride).
            4. a variadic `offset` (resp. `sizes`, `strides`) operand  must be present
               for each dynamic offset (resp. size, stride).
      
          This interface is useful to factor out common behavior and provide support
          for carrying or injecting static behavior through the use of the static
          attributes.
      
      Differential Revision: https://reviews.llvm.org/D92011
      a8de412f
    • Eugene Zhulenev's avatar
      [mlir] AsyncRuntime: fix concurrency bugs + fix exports in methods definitions · 3d95d1b4
      Eugene Zhulenev authored
      1. Move ThreadPool ownership to the runtime, and wait for the async tasks completion in the destructor.
      2. Remove MLIR_ASYNCRUNTIME_EXPORT from method definitions because they are unnecessary in .cpp files, as only function declarations need to be exported, not their definitions.
      3. Fix concurrency bugs in group emplace and potential use-after-free in token emplace.
      
      Tested internally 10k runs in `async.mlir` and `async-group.mlir`.
      
      Fixed: https://bugs.llvm.org/show_bug.cgi?id=48267
      
      Reviewed By: mehdi_amini
      
      Differential Revision: https://reviews.llvm.org/D91988
      3d95d1b4
    • Alexander Belyaev's avatar
    • Alex Zinenko's avatar
      [mlir] move lib/Bindings/Python/Attributes.td to include/mlir/Bindings/Python · ee6255d2
      Alex Zinenko authored
      This file is intended to be included by other files, including
      out-of-tree dialects, and makes more sense in `include` than in `lib`.
      
      Depends On D91652
      
      Reviewed By: mehdi_amini
      
      Differential Revision: https://reviews.llvm.org/D91961
      ee6255d2
    • Alex Zinenko's avatar
      [mlir] Make attributes mutable in Python bindings · 029e199d
      Alex Zinenko authored
      Attributes represent additional data about an operation and are intended to be
      modifiable during the lifetime of the operation. In the dialect-specific Python
      bindings, attributes are exposed as properties on the operation class. Allow
      for assigning values to these properties. Also support creating new and
      deleting existing attributes through the generic "attributes" property of an
      operation. Any validity checking must be performed by the op verifier after the
      mutation, similarly to C++. Operations are not invalidated in the process: no
      dangling pointers can be created as all attributes are owned by the context and
      will remain live even if they are not used in any operation.
      
      Introduce a Python Test dialect by analogy with the Test dialect and to avoid
      polluting the latter with Python-specific constructs. Use this dialect to
      implement a test for the attribute access and mutation API.
      
      Reviewed By: stellaraccident, mehdi_amini
      
      Differential Revision: https://reviews.llvm.org/D91652
      029e199d
Loading