Skip to content
  1. Feb 08, 2021
  2. Feb 06, 2021
    • Tung D. Le's avatar
      [MLIR] [affine-loop-fusion] Fix a bug about non-result ops in affine-loop-fusion · 05c6c648
      Tung D. Le authored
      This patch fixes the following bug when calling --affine-loop-fusion
      
      Input program:
       ```mlir
      func @should_not_fuse_since_top_level_non_affine_non_result_users(
          %in0 : memref<32xf32>, %in1 : memref<32xf32>) {
        %c0 = constant 0 : index
        %cst_0 = constant 0.000000e+00 : f32
      
        affine.for %d = 0 to 32 {
          %lhs = affine.load %in0[%d] : memref<32xf32>
          %rhs = affine.load %in1[%d] : memref<32xf32>
          %add = addf %lhs, %rhs : f32
          affine.store %add, %in0[%d] : memref<32xf32>
        }
        store %cst_0, %in0[%c0] : memref<32xf32>
        affine.for %d = 0 to 32 {
          %lhs = affine.load %in0[%d] : memref<32xf32>
          %rhs = affine.load %in1[%d] : memref<32xf32>
          %add = addf %lhs, %rhs: f32
          affine.store %add, %in0[%d] : memref<32xf32>
        }
        return
      }
      ```
      
      call --affine-loop-fusion, we got an incorrect output:
      
      ```mlir
      func @should_not_fuse_since_top_level_non_affine_non_result_users(%arg0: memref<32xf32>, %arg1: memref<32xf32>) {
        %c0 = constant 0 : index
        %cst = constant 0.000000e+00 : f32
        store %cst, %arg0[%c0] : memref<32xf32>
        affine.for %arg2 = 0 to 32 {
          %0 = affine.load %arg0[%arg2] : memref<32xf32>
          %1 = affine.load %arg1[%arg2] : memref<32xf32>
          %2 = addf %0, %1 : f32
          affine.store %2, %arg0[%arg2] : memref<32xf32>
          %3 = affine.load %arg0[%arg2] : memref<32xf32>
          %4 = affine.load %arg1[%arg2] : memref<32xf32>
          %5 = addf %3, %4 : f32
          affine.store %5, %arg0[%arg2] : memref<32xf32>
        }
        return
      }
      ```
      
      This happened because when analyzing the source and destination nodes,
      affine loop fusion ignored non-result ops sandwitched between them. In
      other words, the MemRefDependencyGraph in the affine loop fusion ignored
      these non-result ops.
      
      This patch solves the issue by adding these non-result ops to the
      MemRefDependencyGraph.
      
      Reviewed By: bondhugula
      
      Differential Revision: https://reviews.llvm.org/D95668
      05c6c648
    • Mehdi Amini's avatar
      Rework ExecutionEngine::invoke() to make it more friendly to use from C++ · d6efb6fc
      Mehdi Amini authored
      This new invoke will pack a list of argument before calling the
      `invokePacked` method. It accepts returned value as output argument
      wrapped in `ExecutionEngine::Result<T>`, and delegate the packing of
      arguments to a trait to allow for customization for some types.
      
      Reviewed By: ftynse
      
      Differential Revision: https://reviews.llvm.org/D95961
      d6efb6fc
    • Mehdi Amini's avatar
  3. Feb 05, 2021
  4. Feb 04, 2021
    • Sean Silva's avatar
      [mlir] Small touchups to LangRef attribute section · 042db54b
      Sean Silva authored
      - attribute-dict production is redundant with dictionary-attribute
      - definitions of attribute aliases were part of the same production as
        uses of attribute aliases
      - `std.dim` now accepts the dimension number as an operand, so the
        example is out of date. Use the predicate of std.cmpi as a better
        example.
      
      Differential Revision: https://reviews.llvm.org/D96076
      042db54b
    • Lei Zhang's avatar
      Revert "[mlir][ODS] Use StringLiteral instead of StringRef when applicable" · 63dc2645
      Lei Zhang authored
      This reverts commit 953086dd because
      it breaks GCC 5 build:
      
        error: could not convert '(const char*)""' from 'const char*' to 'llvm::StringLiteral'
           static ::llvm::StringLiteral getDialectNamespace() { return ""; }
      63dc2645
    • Diego Caballero's avatar
      [mlir] Silence GCC warnings · f9f6b4f3
      Diego Caballero authored
      Reviewed By: mehdi_amini, rriddle
      
      Differential Revision: https://reviews.llvm.org/D95906
      f9f6b4f3
    • Mehdi Amini's avatar
    • Vladislav Vinogradov's avatar
      [mlir][ODS] Use StringLiteral instead of StringRef when applicable · 953086dd
      Vladislav Vinogradov authored
      Use `StringLiteral` for function return type if it is known to return
      constant string literals only.
      
      This will make it visible to API users, that such values can be safely
      stored, since they refers to constant data, which will never be deallocated.
      
      `StringRef` is general is not safe to store for a long term,
      since it might refer to temporal data allocated in heap.
      
      Reviewed By: mehdi_amini, bkramer
      
      Differential Revision: https://reviews.llvm.org/D95945
      953086dd
    • Vladislav Vinogradov's avatar
      [mlir][ODS] Add explicit namespace to `ViewLikeInterface` definition · cafdf468
      Vladislav Vinogradov authored
      To allow it usage for Operation classes defined outside of `mlir` namespace.
      
      Reviewed By: mehdi_amini
      
      Differential Revision: https://reviews.llvm.org/D95952
      cafdf468
    • Vladislav Vinogradov's avatar
      [mlir][ODS] Small fixes for ODS classes · 07fc8528
      Vladislav Vinogradov authored
      * Introduce separate `RankedTensorOf` class. Use it as base class for `AnyRankedTensor`.
      * Add C++ class specification (`::mlir::MemRefType`) to `MemRefRankOf` and `StaticShapeMemRefOf`.
      
      Reviewed By: ftynse
      
      Differential Revision: https://reviews.llvm.org/D95936
      07fc8528
    • Nicolas Vasilache's avatar
      [mlir][Linalg] Introduce a ContractionOpInterface · e4a503a2
      Nicolas Vasilache authored
      This revision takes advantage of recent extensions to vectorization to refactor contraction detection into a bona fide Linalg interface.
      The mlit-linalg-ods-gen parser is extended to support adding such interfaces.
      The detection that was originally enabling vectorization is refactored to serve as both a test on a generic LinalgOp as well as to verify ops that declare to conform to that interface.
      
      This is plugged through Linalg transforms and strategies but it quickly becomes evident that the complexity and rigidity of the C++ class based templating does not pay for itself.
      Therefore, this revision changes the API for vectorization patterns to get rid of templates as much as possible.
      Variadic templates are relegated to the internals of LinalgTransformationFilter as much as possible and away from the user-facing APIs.
      
      It is expected other patterns / transformations will follow the same path and drop as much C++ templating as possible from the class definition.
      
      Differential revision: https://reviews.llvm.org/D95973
      e4a503a2
    • Alexander Belyaev's avatar
      09c18a66
    • Nicolas Vasilache's avatar
      [mlir][Linalg] Drop SliceOp · f4ac9f03
      Nicolas Vasilache authored
      This op is subsumed by rank-reducing SubViewOp and has become useless.
      
      Differential revision: https://reviews.llvm.org/D95317
      f4ac9f03
    • Alex Zinenko's avatar
      [mlir] make vector to llvm conversion truly partial · ba87f991
      Alex Zinenko authored
      Historically, the Vector to LLVM dialect conversion subsumed the Standard to
      LLVM dialect conversion patterns. This was necessary because the conversion
      infrastructure did not have sufficient support for reconciling type
      conversions. This support is now available. Only keep the patterns related to
      the Vector dialect in the Vector to LLVM conversion and require type casts
      operations to be inserted if necessary. These casts will be removed by
      following conversions if possible. Update integration tests to also run the
      Standard to LLVM conversion.
      
      There is a significant amount of test churn, which is due to (a) unnecessarily
      strict tests in VectorToLLVM and (b) many patterns actually targeting Standard
      dialect ops instead of LLVM dialect ops leading to tests actually exercising a
      Vector->Standard->LLVM conversion. This churn is a good illustration of the
      reason to make the conversion partial: now the tests only check the code in the
      Vector to LLVM conversion and will not be randomly broken by changes in
      Standard to LLVM conversion.
      
      Arguably, it may be possible to extract Vector to Standard patterns into a
      separate pass, but given the ongoing splitting of the Standard dialect, such
      pass will be short-lived and will require further refactoring.
      
      Depends On D95626
      
      Reviewed By: nicolasvasilache, aartbik
      
      Differential Revision: https://reviews.llvm.org/D95685
      ba87f991
    • Alex Zinenko's avatar
      [mlir] Apply source materialization in case of transitive conversion · 5b91060d
      Alex Zinenko authored
      In dialect conversion infrastructure, source materialization applies as part of
      the finalization procedure to results of the newly produced operations that
      replace previously existing values with values having a different type.
      However, such operations may be created to replace operations created in other
      patterns. At this point, it is possible that the results of the _original_
      operation are still in use and have mismatching types, but the results of the
      _intermediate_ operation that performed the type change are not in use leading
      to the absence of source materialization. For example,
      
        %0 = dialect.produce : !dialect.A
        dialect.use %0 : !dialect.A
      
      can be replaced with
      
        %0 = dialect.other : !dialect.A
        %1 = dialect.produce : !dialect.A  // replaced, scheduled for removal
        dialect.use %1 : !dialect.A
      
      and then with
      
        %0 = dialect.final : !dialect.B
        %1 = dialect.other : !dialect.A    // replaced, scheduled for removal
        %2 = dialect.produce : !dialect.A  // replaced, scheduled for removal
        dialect.use %2 : !dialect.A
      
      in the same rewriting, but only the %1->%0 replacement is currently considered.
      
      Change the logic in dialect conversion to look up all values that were replaced
      by the given value and performing source materialization if any of those values
      is still in use with mismatching types. This is performed by computing the
      inverse value replacement mapping. This arguably expensive manipulation is
      performed only if there were some type-changing replacements. An alternative
      could be to consider all replaced operations and not only those that resulted
      in type changes, but it would harm pattern-level composability: the pattern
      that performed the non-type-changing replacement would have to be made aware of
      the type converter in order to call the materialization hook.
      
      Reviewed By: rriddle
      
      Differential Revision: https://reviews.llvm.org/D95626
      5b91060d
    • Nicolas Vasilache's avatar
      [mlir][Linalg] Generalize the definition of a Linalg contraction. · f245b7ad
      Nicolas Vasilache authored
      This revision defines a Linalg contraction in general terms:
      
        1. Has 2 input and 1 output shapes.
        2. Has at least one reduction dimension.
        3. Has only projected permutation indexing maps.
        4. its body computes `u5(u1(c) + u2(u3(a) * u4(b)))` on some field
          (AddOpType, MulOpType), where u1, u2, u3, u4 and u5 represent scalar unary
          operations that may change the type (e.g. for mixed-precision).
      
      As a consequence, when vectorization of such an op occurs, the only special
      behavior is that the (unique) MulOpType is vectorized into a
      `vector.contract`. All other ops are handled in a generic fashion.
      
       In the future, we may wish to allow more input arguments and elementwise and
       constant operations that do not involve the reduction dimension(s).
      
      A test is added to demonstrate the proper vectorization of matmul_i8_i8_i32.
      
      Differential revision: https://reviews.llvm.org/D95939
      f245b7ad
    • Nicolas Vasilache's avatar
      [mlir][Linalg] NFC - Extract a standalone LinalgInterfaces · 1029c82c
      Nicolas Vasilache authored
      This separation improves the layering and paves the way for more interfaces coming up in the future.
      
      Differential revision: https://reviews.llvm.org/D95941
      1029c82c
    • Isuru Fernando's avatar
      [MLIR] Fix building unittests in in-tree build · c95c0db2
      Isuru Fernando authored
      Reviewed By: mehdi_amini
      
      Differential Revision: https://reviews.llvm.org/D95978
      c95c0db2
    • Mehdi Amini's avatar
      Make the folder more robust against op fold() methods that generate a type mismatch · a1d5bdf8
      Mehdi Amini authored
      We could extend this with an interface to allow dialect to perform a type
      conversion, but that would make the folder creating operation which isn't
      the case at the moment, and isn't necessarily always desirable.
      
      Reviewed By: rriddle
      
      Differential Revision: https://reviews.llvm.org/D95991
      a1d5bdf8
  5. Feb 03, 2021
Loading