[llvm-branch-commits] [mlir] d0cb0d3 - [mlir] Add Complex dialect.

2021-01-15 Thread Alexander Belyaev via llvm-branch-commits

Author: Alexander Belyaev
Date: 2021-01-15T19:58:10+01:00
New Revision: d0cb0d30a431578ecedb98c57780154789f3c594

URL: 
https://github.com/llvm/llvm-project/commit/d0cb0d30a431578ecedb98c57780154789f3c594
DIFF: 
https://github.com/llvm/llvm-project/commit/d0cb0d30a431578ecedb98c57780154789f3c594.diff

LOG: [mlir] Add Complex dialect.

Differential Revision: https://reviews.llvm.org/D94764

Added: 
mlir/include/mlir/Conversion/ComplexToLLVM/ComplexToLLVM.h
mlir/include/mlir/Dialect/Complex/CMakeLists.txt
mlir/include/mlir/Dialect/Complex/IR/CMakeLists.txt
mlir/include/mlir/Dialect/Complex/IR/Complex.h
mlir/include/mlir/Dialect/Complex/IR/ComplexBase.td
mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td
mlir/lib/Conversion/ComplexToLLVM/CMakeLists.txt
mlir/lib/Conversion/ComplexToLLVM/ComplexToLLVM.cpp
mlir/lib/Dialect/Complex/CMakeLists.txt
mlir/lib/Dialect/Complex/IR/CMakeLists.txt
mlir/lib/Dialect/Complex/IR/ComplexDialect.cpp
mlir/lib/Dialect/Complex/IR/ComplexOps.cpp
mlir/test/Conversion/ComplexToLLVM/convert-to-llvm.mlir
mlir/test/Dialect/Complex/ops.mlir

Modified: 
mlir/include/mlir/Conversion/Passes.h
mlir/include/mlir/Conversion/Passes.td
mlir/include/mlir/Dialect/CMakeLists.txt
mlir/include/mlir/InitAllDialects.h
mlir/lib/Conversion/CMakeLists.txt
mlir/lib/Conversion/PassDetail.h
mlir/lib/Dialect/CMakeLists.txt
mlir/test/mlir-opt/commandline.mlir

Removed: 




diff  --git a/mlir/include/mlir/Conversion/ComplexToLLVM/ComplexToLLVM.h 
b/mlir/include/mlir/Conversion/ComplexToLLVM/ComplexToLLVM.h
new file mode 100644
index ..3dab2a136b28
--- /dev/null
+++ b/mlir/include/mlir/Conversion/ComplexToLLVM/ComplexToLLVM.h
@@ -0,0 +1,29 @@
+//===- ComplexToLLVM.h - Utils to convert from the complex dialect 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#ifndef MLIR_CONVERSION_COMPLEXTOLLVM_COMPLEXTOLLVM_H_
+#define MLIR_CONVERSION_COMPLEXTOLLVM_COMPLEXTOLLVM_H_
+
+#include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h"
+#include "mlir/Transforms/DialectConversion.h"
+
+namespace mlir {
+class MLIRContext;
+class ModuleOp;
+template 
+class OperationPass;
+
+/// Populate the given list with patterns that convert from Complex to LLVM.
+void populateComplexToLLVMConversionPatterns(
+LLVMTypeConverter &converter, OwningRewritePatternList &patterns);
+
+/// Create a pass to convert Complex operations to the LLVMIR dialect.
+std::unique_ptr> createConvertComplexToLLVMPass();
+
+} // namespace mlir
+
+#endif // MLIR_CONVERSION_COMPLEXTOLLVM_COMPLEXTOLLVM_H_

diff  --git a/mlir/include/mlir/Conversion/Passes.h 
b/mlir/include/mlir/Conversion/Passes.h
index 2e07a795b6c7..121dae6f46f8 100644
--- a/mlir/include/mlir/Conversion/Passes.h
+++ b/mlir/include/mlir/Conversion/Passes.h
@@ -11,6 +11,7 @@
 
 #include "mlir/Conversion/AffineToStandard/AffineToStandard.h"
 #include "mlir/Conversion/AsyncToLLVM/AsyncToLLVM.h"
+#include "mlir/Conversion/ComplexToLLVM/ComplexToLLVM.h"
 #include "mlir/Conversion/GPUCommon/GPUCommonPass.h"
 #include "mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h"
 #include "mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h"

diff  --git a/mlir/include/mlir/Conversion/Passes.td 
b/mlir/include/mlir/Conversion/Passes.td
index e8ca058adedd..aa228784e48a 100644
--- a/mlir/include/mlir/Conversion/Passes.td
+++ b/mlir/include/mlir/Conversion/Passes.td
@@ -88,6 +88,16 @@ def ConvertAsyncToLLVM : Pass<"convert-async-to-llvm", 
"ModuleOp"> {
   let dependentDialects = ["LLVM::LLVMDialect"];
 }
 
+//===--===//
+// ComplexToLLVM
+//===--===//
+
+def ConvertComplexToLLVM : Pass<"convert-complex-to-llvm", "ModuleOp"> {
+  let summary = "Convert Complex dialect to LLVM dialect";
+  let constructor = "mlir::createConvertComplexToLLVMPass()";
+  let dependentDialects = ["LLVM::LLVMDialect"];
+}
+
 
//===--===//
 // GPUCommon
 
//===--===//

diff  --git a/mlir/include/mlir/Dialect/CMakeLists.txt 
b/mlir/include/mlir/Dialect/CMakeLists.txt
index 51b423ee3b98..df0c751b6ba6 100644
--- a/mlir/include/mlir/Dialect/CMakeLists.txt
+++ b/mlir/include/mlir/Dialect/CMakeLists.txt
@@ -3,6 +3,7 @@ add_subdirectory(Async)
 add_subdirectory(ArmNeon)
 add_subdirectory(ArmSVE)
 add_subdirectory(AVX512)
+add_subdirectory(Complex)
 add_subdirectory(GPU)
 add_subdirectory(Linalg)
 add_subdirectory(LLVMIR)

diff  --git a/mlir/

[llvm-branch-commits] [mlir] 11f4c58 - [mlir] Add `complex.abs`, `complex.div` and `complex.mul` to ComplexOps.

2021-01-19 Thread Alexander Belyaev via llvm-branch-commits

Author: Alexander Belyaev
Date: 2021-01-19T12:09:59+01:00
New Revision: 11f4c58c153cedf6fe04cab49d4a4f02d00e3383

URL: 
https://github.com/llvm/llvm-project/commit/11f4c58c153cedf6fe04cab49d4a4f02d00e3383
DIFF: 
https://github.com/llvm/llvm-project/commit/11f4c58c153cedf6fe04cab49d4a4f02d00e3383.diff

LOG: [mlir] Add `complex.abs`, `complex.div` and `complex.mul` to ComplexOps.

Differential Revision: https://reviews.llvm.org/D94911

Added: 


Modified: 
mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td
mlir/lib/Conversion/ComplexToLLVM/ComplexToLLVM.cpp
mlir/test/Conversion/ComplexToLLVM/convert-to-llvm.mlir
mlir/test/Dialect/Complex/ops.mlir

Removed: 




diff  --git a/mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td 
b/mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td
index a4329df7c1aa..960f5f64eec3 100644
--- a/mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td
+++ b/mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td
@@ -43,11 +43,37 @@ def AddOp : ComplexArithmeticOp<"add"> {
 Example:
 
 ```mlir
-%a = add %b, %c : complex
+%a = complex.add %b, %c : complex
 ```
   }];
 }
 
+//===--===//
+// AbsOp
+//===--===//
+
+def AbsOp : Complex_Op<"abs",
+[NoSideEffect,
+ TypesMatchWith<"complex element type matches result type",
+"complex", "result",
+"$_self.cast().getElementType()">]> {
+  let summary = "computes absolute value of a complex number";
+  let description = [{
+The `abs` op takes a single complex number and computes its absolute value.
+
+Example:
+
+```mlir
+%a = complex.abs %b : complex
+```
+  }];
+
+  let arguments = (ins Complex:$complex);
+  let results = (outs AnyFloat:$result);
+
+  let assemblyFormat = "$complex attr-dict `:` type($complex)";
+}
+
 
//===--===//
 // CreateOp
 
//===--===//
@@ -70,7 +96,7 @@ def CreateOp : Complex_Op<"create",
 Example:
 
 ```mlir
-%a = create_complex %b, %c : complex
+%a = complex.create %b, %c : complex
 ```
   }];
 
@@ -80,6 +106,22 @@ def CreateOp : Complex_Op<"create",
   let assemblyFormat = "$real `,` $imaginary attr-dict `:` type($complex)";
 }
 
+//===--===//
+// DivOp
+//===--===//
+
+def DivOp : ComplexArithmeticOp<"div"> {
+  let summary = "complex division";
+  let description = [{
+The `div` operation takes two complex numbers and returns result of their
+division:
+
+```mlir
+%a = complex.div %b, %c : complex
+```
+  }];
+}
+
 
//===--===//
 // ImOp
 
//===--===//
@@ -96,7 +138,7 @@ def ImOp : Complex_Op<"im",
 Example:
 
 ```mlir
-%a = im %b : complex
+%a = complex.im %b : complex
 ```
   }];
 
@@ -106,6 +148,21 @@ def ImOp : Complex_Op<"im",
   let assemblyFormat = "$complex attr-dict `:` type($complex)";
 }
 
+//===--===//
+// MulOp
+//===--===//
+
+def MulOp : ComplexArithmeticOp<"mul"> {
+  let summary = "complex multiplication";
+  let description = [{
+The `mul` operation takes two complex numbers and returns their product:
+
+```mlir
+%a = complex.mul %b, %c : complex
+```
+  }];
+}
+
 
//===--===//
 // ReOp
 
//===--===//
@@ -122,7 +179,7 @@ def ReOp : Complex_Op<"re",
 Example:
 
 ```mlir
-%a = re %b : complex
+%a = complex.re %b : complex
 ```
   }];
 
@@ -145,7 +202,7 @@ def SubOp : ComplexArithmeticOp<"sub"> {
 Example:
 
 ```mlir
-%a = sub %b, %c : complex
+%a = complex.sub %b, %c : complex
 ```
   }];
 }

diff  --git a/mlir/lib/Conversion/ComplexToLLVM/ComplexToLLVM.cpp 
b/mlir/lib/Conversion/ComplexToLLVM/ComplexToLLVM.cpp
index 1096b08da1f1..270b9489625c 100644
--- a/mlir/lib/Conversion/ComplexToLLVM/ComplexToLLVM.cpp
+++ b/mlir/lib/Conversion/ComplexToLLVM/ComplexToLLVM.cpp
@@ -17,6 +17,29 @@ using namespace mlir::LLVM;
 
 namespace {
 
+struct AbsOpConversion : public ConvertOpToLLVMPattern {
+  using ConvertOpToLLVMPattern::ConvertOpToLLVMPattern;
+
+  LogicalResult
+  matchAndRewrite(complex::AbsOp op, ArrayRef operands,
+  ConversionPatternRewriter &rewriter) const override {
+complex::AbsO

[llvm-branch-commits] [mlir] b1e1bba - [mlir] Add ComplexDialect to SCF->GPU pass.

2021-01-20 Thread Alexander Belyaev via llvm-branch-commits

Author: Alexander Belyaev
Date: 2021-01-20T21:18:09+01:00
New Revision: b1e1bbae0e30c89251940efb0780eee6a1b79ecd

URL: 
https://github.com/llvm/llvm-project/commit/b1e1bbae0e30c89251940efb0780eee6a1b79ecd
DIFF: 
https://github.com/llvm/llvm-project/commit/b1e1bbae0e30c89251940efb0780eee6a1b79ecd.diff

LOG: [mlir] Add ComplexDialect to SCF->GPU pass.

Added: 


Modified: 
mlir/lib/Conversion/SCFToGPU/CMakeLists.txt
mlir/lib/Conversion/SCFToGPU/SCFToGPUPass.cpp

Removed: 




diff  --git a/mlir/lib/Conversion/SCFToGPU/CMakeLists.txt 
b/mlir/lib/Conversion/SCFToGPU/CMakeLists.txt
index 10fed819ca35..f3de289c28cc 100644
--- a/mlir/lib/Conversion/SCFToGPU/CMakeLists.txt
+++ b/mlir/lib/Conversion/SCFToGPU/CMakeLists.txt
@@ -11,6 +11,7 @@ add_mlir_conversion_library(MLIRSCFToGPU
   LINK_LIBS PUBLIC
   MLIRAffine
   MLIRAffineToStandard
+  MLIRComplex
   MLIRGPU
   MLIRIR
   MLIRLinalg

diff  --git a/mlir/lib/Conversion/SCFToGPU/SCFToGPUPass.cpp 
b/mlir/lib/Conversion/SCFToGPU/SCFToGPUPass.cpp
index 2941b400babe..66fbacf69d5b 100644
--- a/mlir/lib/Conversion/SCFToGPU/SCFToGPUPass.cpp
+++ b/mlir/lib/Conversion/SCFToGPU/SCFToGPUPass.cpp
@@ -10,6 +10,7 @@
 #include "../PassDetail.h"
 #include "mlir/Conversion/SCFToGPU/SCFToGPU.h"
 #include "mlir/Dialect/Affine/IR/AffineOps.h"
+#include "mlir/Dialect/Complex/IR/Complex.h"
 #include "mlir/Dialect/GPU/GPUDialect.h"
 #include "mlir/Dialect/SCF/SCF.h"
 #include "mlir/Dialect/StandardOps/IR/Ops.h"
@@ -49,10 +50,9 @@ struct ParallelLoopToGpuPass
 OwningRewritePatternList patterns;
 populateParallelLoopToGPUPatterns(patterns, &getContext());
 ConversionTarget target(getContext());
-target.addLegalDialect();
-target.addLegalDialect();
-target.addLegalDialect();
-target.addLegalDialect();
+target.addLegalDialect();
 configureParallelLoopToGPULegality(target);
 if (failed(applyPartialConversion(getOperation(), target,
   std::move(patterns



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] fc58bfd - [mlir] Remove complex ops from Standard dialect.

2021-01-21 Thread Alexander Belyaev via llvm-branch-commits

Author: Alexander Belyaev
Date: 2021-01-21T10:34:26+01:00
New Revision: fc58bfd02f8d27e610500db53b268157cce0637b

URL: 
https://github.com/llvm/llvm-project/commit/fc58bfd02f8d27e610500db53b268157cce0637b
DIFF: 
https://github.com/llvm/llvm-project/commit/fc58bfd02f8d27e610500db53b268157cce0637b.diff

LOG: [mlir] Remove complex ops from Standard dialect.

`complex` dialect should be used instead.
https://llvm.discourse.group/t/rfc-split-the-complex-dialect-from-std/2496/2

Differential Revision: https://reviews.llvm.org/D95077

Added: 


Modified: 
mlir/include/mlir/Dialect/StandardOps/EDSC/Intrinsics.h
mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
mlir/test/Conversion/StandardToLLVM/convert-to-llvmir.mlir
mlir/test/IR/core-ops.mlir
mlir/test/IR/invalid-ops.mlir

Removed: 




diff  --git a/mlir/include/mlir/Dialect/StandardOps/EDSC/Intrinsics.h 
b/mlir/include/mlir/Dialect/StandardOps/EDSC/Intrinsics.h
index a9eed0984c80..5d4668d7b5fc 100644
--- a/mlir/include/mlir/Dialect/StandardOps/EDSC/Intrinsics.h
+++ b/mlir/include/mlir/Dialect/StandardOps/EDSC/Intrinsics.h
@@ -20,7 +20,6 @@ using std_addf = ValueBuilder;
 using std_alloc = ValueBuilder;
 using std_alloca = ValueBuilder;
 using std_call = OperationBuilder;
-using std_create_complex = ValueBuilder;
 using std_constant = ValueBuilder;
 using std_constant_float = ValueBuilder;
 using std_constant_index = ValueBuilder;
@@ -31,12 +30,10 @@ using std_diviu = ValueBuilder;
 using std_dim = ValueBuilder;
 using std_fpext = ValueBuilder;
 using std_fptrunc = ValueBuilder;
-using std_im = ValueBuilder;
 using std_index_cast = ValueBuilder;
 using std_muli = ValueBuilder;
 using std_mulf = ValueBuilder;
 using std_memref_cast = ValueBuilder;
-using std_re = ValueBuilder;
 using std_ret = OperationBuilder;
 using std_rsqrt = ValueBuilder;
 using std_select = ValueBuilder;

diff  --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td 
b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
index f4caa7da1721..5987640a429d 100644
--- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
+++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
@@ -151,18 +151,6 @@ class FloatArithmeticOp 
traits = []> :
   [DeclareOpInterfaceMethods])>,
 Arguments<(ins FloatLike:$lhs, FloatLike:$rhs)>;
 
-// Base class for standard arithmetic operations on complex numbers with a
-// floating-point element type.
-// These operations take two operands and return one result, all of which must
-// be complex numbers of the same type.
-// The assembly format is as follows
-//
-// cf %0, %1 : complex
-//
-class ComplexFloatArithmeticOp traits = []> :
-ArithmeticOp,
-Arguments<(ins Complex:$lhs, Complex:$rhs)>;
-
 // Base class for memref allocating ops: alloca and alloc.
 //
 //   %0 = alloclike(%m)[%s] : memref<8x?xf32, (d0, d1)[s0] -> ((d0 + s0), d1)>
@@ -265,26 +253,6 @@ def AbsFOp : FloatUnaryOp<"absf"> {
   }];
 }
 
-//===--===//
-// AddCFOp
-//===--===//
-
-def AddCFOp : ComplexFloatArithmeticOp<"addcf"> {
-  let summary = "complex number addition";
-  let description = [{
-The `addcf` operation takes two complex number operands and returns their
-sum, a single complex number.
-All operands and result must be of the same type, a complex number with a
-floating-point element type.
-
-Example:
-
-```mlir
-%a = addcf %b, %c : complex
-```
-  }];
-}
-
 
//===--===//
 // AddFOp
 
//===--===//
@@ -1180,40 +1148,6 @@ def CmpIOp : Std_Op<"cmpi",
   let assemblyFormat = "$predicate `,` $lhs `,` $rhs attr-dict `:` type($lhs)";
 }
 
-//===--===//
-// CreateComplexOp
-//===--===//
-
-def CreateComplexOp : Std_Op<"create_complex",
-[NoSideEffect,
- AllTypesMatch<["real", "imaginary"]>,
- TypesMatchWith<"complex element type matches real operand type",
-"complex", "real",
-"$_self.cast().getElementType()">,
- TypesMatchWith<"complex element type matches imaginary operand type",
-"complex", "imaginary",
-"$_self.cast().getElementType()">]> {
-  let summary = "creates a complex number";
-  let description = [{
-The `create_complex` operation creates a complex number from two
-floating-point operands, the real and the imaginary part.
-
-Example:
-
-```mlir
-%a = create_complex %b, %c : complex
-```
-  }];
-
-  let arguments = (ins AnyFloat:$real, AnyFloat:$imagin

[llvm-branch-commits] [mlir] e47e313 - [mlir] Fix a typo MemRefType -> UnrankedMemRefType

2020-12-30 Thread Alexander Belyaev via llvm-branch-commits

Author: Alexander Belyaev
Date: 2020-12-30T14:35:25+01:00
New Revision: e47e313d647e00ab5fbb4a17f9b69f33c49aafc3

URL: 
https://github.com/llvm/llvm-project/commit/e47e313d647e00ab5fbb4a17f9b69f33c49aafc3
DIFF: 
https://github.com/llvm/llvm-project/commit/e47e313d647e00ab5fbb4a17f9b69f33c49aafc3.diff

LOG: [mlir] Fix a typo MemRefType -> UnrankedMemRefType

Added: 


Modified: 
mlir/include/mlir/IR/OpBase.td

Removed: 




diff  --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td
index c65cc22c90f0..dfea9fed70a5 100644
--- a/mlir/include/mlir/IR/OpBase.td
+++ b/mlir/include/mlir/IR/OpBase.td
@@ -656,7 +656,7 @@ class 4DTensorOf allowedTypes> : 
TensorRankOf;
 def AnyUnrankedMemRef :
 ShapedContainerType<[AnyType],
 IsUnrankedMemRefTypePred, "unranked.memref",
-"::mlir::MemRefType">;
+"::mlir::UnrankedMemRefType">;
 // Memref type.
 
 // Memrefs are blocks of data with fixed type and rank.



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] 89ae5b5 - [mlir] Add canonicalization pattern out_tensor->linalg->dim to out_tensor->dim.

2021-01-05 Thread Alexander Belyaev via llvm-branch-commits

Author: Alexander Belyaev
Date: 2021-01-05T15:15:21+01:00
New Revision: 89ae5b5b6a475addb7248ca7a948a944a15f0275

URL: 
https://github.com/llvm/llvm-project/commit/89ae5b5b6a475addb7248ca7a948a944a15f0275
DIFF: 
https://github.com/llvm/llvm-project/commit/89ae5b5b6a475addb7248ca7a948a944a15f0275.diff

LOG: [mlir] Add canonicalization pattern out_tensor->linalg->dim to 
out_tensor->dim.

Differential Revision: https://reviews.llvm.org/D94079

Added: 


Modified: 
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
mlir/test/Dialect/Linalg/canonicalize.mlir

Removed: 




diff  --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp 
b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
index bcbd6d9036121..529ba35a0b87d 100644
--- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
+++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
@@ -1958,14 +1958,33 @@ struct DeduplicateInputs : public RewritePattern {
 return success();
   }
 };
+
+/// Canonicalize a `linalgOp` -> `dim` pattern by replacing the `dim` arg
+/// with the corresponding output tensor argument of the linalg op.
+struct ReplaceDimOfLinalgResult : public OpRewritePattern {
+  using OpRewritePattern::OpRewritePattern;
+
+  LogicalResult matchAndRewrite(DimOp dimOp,
+PatternRewriter &rewriter) const override {
+Value dimOpArg = dimOp.memrefOrTensor();
+auto linalgOp = dimOpArg.getDefiningOp();
+if (!linalgOp)
+  return failure();
+
+auto results = linalgOp.getOperation()->getResults();
+int64_t id = std::distance(results.begin(), llvm::find(results, dimOpArg));
+auto outputTensors = linalgOp.getOutputTensors();
+rewriter.replaceOpWithNewOp(dimOp, outputTensors[id], 
dimOp.index());
+return success();
+  }
+};
 } // namespace
 
 #define CANONICALIZERS_AND_FOLDERS(XXX)
\
   void XXX::getCanonicalizationPatterns(OwningRewritePatternList &results, 
\
 MLIRContext *context) {
\
-results.insert();   
\
-results.insert();
\
-results.insert();   
\
+results.insert();  
\
+results.insert(context); 
\
   }
\

\
   LogicalResult XXX::fold(ArrayRef, 
\

diff  --git a/mlir/test/Dialect/Linalg/canonicalize.mlir 
b/mlir/test/Dialect/Linalg/canonicalize.mlir
index f015d5fd64fd9..faac64c0d91a9 100644
--- a/mlir/test/Dialect/Linalg/canonicalize.mlir
+++ b/mlir/test/Dialect/Linalg/canonicalize.mlir
@@ -389,3 +389,31 @@ func @init_tensor_dynamic_dim(%arg0 : index) -> (index) {
 //  CHECK: func @init_tensor_dynamic_dim
 // CHECK-SAME:   %[[ARG0:[a-zA-Z0-9_]+]]: index
 //  CHECK:   return %[[ARG0]]
+
+// -
+
+#map = affine_map<(d0) -> (d0)>
+
+func @init_tensor_dim_of_linalg_result(%arg_0 : tensor,
+%arg_1: tensor) -> (tensor, tensor) {
+  %0, %1 = linalg.generic {
+indexing_maps = [#map, #map, #map],
+iterator_types = ["parallel"]
+  } ins(%arg_0 : tensor)
+outs(%arg_0, %arg_1 : tensor, tensor) {
+  ^bb0(%in: f32, %out_0: f32, %out_1: f32):
+linalg.yield %in, %in : f32, f32
+  } -> tensor, tensor
+
+  %c0 = constant 0 : index
+  %num_elem_0 = dim %0, %c0 : tensor
+  %result_0 = linalg.init_tensor [%num_elem_0] : tensor
+
+  %num_elem_1 = dim %1, %c0 : tensor
+  %result_1 = linalg.init_tensor [%num_elem_1] : tensor
+  return %result_0, %result_1 : tensor, tensor
+}
+// CHECK-LABEL: func @init_tensor_dim_of_linalg_result(
+// CHECK-SAME: [[ARG_0:%.*]]: tensor, [[ARG_1:%.*]]: tensor)
+// CHECK: dim [[ARG_0]]
+// CHECK: dim [[ARG_1]]



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 9c4b222 - Revert "Revert "Revert "Revert "Revert "[analyzer] NFC: Move path diagnostic consumer implementations to libAnalysis."""""

2021-01-08 Thread Alexander Belyaev via llvm-branch-commits

Author: Alexander Belyaev
Date: 2021-01-08T14:17:18+01:00
New Revision: 9c4b2225b24de07a728715ce20238803370413ea

URL: 
https://github.com/llvm/llvm-project/commit/9c4b2225b24de07a728715ce20238803370413ea
DIFF: 
https://github.com/llvm/llvm-project/commit/9c4b2225b24de07a728715ce20238803370413ea.diff

LOG: Revert "Revert "Revert "Revert "Revert "[analyzer] NFC: Move path 
diagnostic consumer implementations to libAnalysis."

This reverts commit 6b0ee02747ed22d41e175d15f27025183341e6f8.

Circular dependency again.

Added: 
clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h
clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
clang/lib/StaticAnalyzer/Core/TextDiagnostics.cpp

Modified: 
clang/include/clang/CrossTU/CrossTranslationUnit.h
clang/include/clang/StaticAnalyzer/Core/Analyses.def
clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
clang/include/clang/module.modulemap
clang/lib/Analysis/CMakeLists.txt
clang/lib/CrossTU/CrossTranslationUnit.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/StaticAnalyzer/Core/CMakeLists.txt
clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Removed: 
clang/include/clang/Analysis/CrossTUAnalysisHelper.h
clang/include/clang/Analysis/PathDiagnosticConsumers.def
clang/include/clang/Analysis/PathDiagnosticConsumers.h
clang/lib/Analysis/HTMLPathDiagnosticConsumer.cpp
clang/lib/Analysis/PlistHTMLPathDiagnosticConsumer.cpp
clang/lib/Analysis/PlistPathDiagnosticConsumer.cpp
clang/lib/Analysis/SarifPathDiagnosticConsumer.cpp
clang/lib/Analysis/TextPathDiagnosticConsumer.cpp



diff  --git a/clang/include/clang/Analysis/CrossTUAnalysisHelper.h 
b/clang/include/clang/Analysis/CrossTUAnalysisHelper.h
deleted file mode 100644
index 500e78ddedcf..
--- a/clang/include/clang/Analysis/CrossTUAnalysisHelper.h
+++ /dev/null
@@ -1,41 +0,0 @@
-//===- CrossTUAnalysisHelper.h - Abstraction layer for CTU --*- C++ 
-*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-#ifndef LLVM_CLANG_ANALYSIS_CROSS_TU_HELPER_H
-#define LLVM_CLANG_ANALYSIS_CROSS_TU_HELPER_H
-
-#include "llvm/ADT/Optional.h"
-#include "clang/Basic/SourceManager.h"
-
-namespace clang {
-
-class ASTUnit;
-
-/// This class is an abstract interface acting as a bridge between
-/// an analysis that requires lookups across translation units (a user
-/// of that interface) and the facility that implements such lookups
-/// (an implementation of that interface). This is useful to break direct
-/// link-time dependencies between the (possibly shared) libraries in which
-/// the user and the implementation live.
-class CrossTUAnalysisHelper {
-public:
-  /// Determine the original source location in the original TU for an
-  /// imported source location.
-  /// \p ToLoc Source location in the imported-to AST.
-  /// \return Source location in the imported-from AST and the corresponding
-  /// ASTUnit object (the AST was loaded from a file using an internal ASTUnit
-  /// object that is returned here).
-  /// If any error happens (ToLoc is a non-imported source location) empty is
-  /// returned.
-  virtual llvm::Optional>
-  getImportedFromSourceLocationWithPreprocessor(SourceLocation ToLoc) const = 
0;
-
-  virtual ~CrossTUAnalysisHelper() {}
-};
-} // namespace clang
-
-#endif // LLVM_CLANG_ANALYSIS_CROSS_TU_HELPER_H

diff  --git a/clang/include/clang/Analysis/PathDiagnosticConsumers.def 
b/clang/include/clang/Analysis/PathDiagnosticConsumers.def
deleted file mode 100644
index 33d2072fcf31..
--- a/clang/include/clang/Analysis/PathDiagnosticConsumers.def
+++ /dev/null
@@ -1,50 +0,0 @@
-//===-- PathDiagnosticConsumers.def - Visualizing warnings --*- C++ 
-*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-//
-// This file defines the set of path diagnostic consumers - objects that
-// implement 
diff erent representations of static analysis results.
-//
-//===--===//
-
-#ifndef ANALYSIS_DIAGNOSTICS
-#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN)
-#endif
-
-ANALYSIS_DIAGNOSTICS(HTML, "html", "Output analysis results using HTML",
- createHTM

[llvm-branch-commits] [llvm] bcbdeaf - Revert "[SLP]Need shrink the load vector after reordering."

2021-01-08 Thread Alexander Belyaev via llvm-branch-commits

Author: Alexander Belyaev
Date: 2021-01-08T14:42:26+01:00
New Revision: bcbdeafa9cb3469a7bf367c17f32d913076a4d55

URL: 
https://github.com/llvm/llvm-project/commit/bcbdeafa9cb3469a7bf367c17f32d913076a4d55
DIFF: 
https://github.com/llvm/llvm-project/commit/bcbdeafa9cb3469a7bf367c17f32d913076a4d55.diff

LOG: Revert "[SLP]Need shrink the load vector after reordering."

This reverts commit 4284afdf9432f7d756f56b0ab21d69191adefa8d.

This changes computed values in fused_batchnorm_test_cpu.

Not equal to tolerance rtol=1e-06, atol=0.001
Mismatched value: a is different from b.
not close where = (array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1,
   1, 1]), array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1,
   1, 1]), array([0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 
1, 1, 1,
   1, 1]), array([0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 
1, 2, 3,
   4, 5]))
not close lhs = [-0.6636615  -0.9804948  -1.148275   -0.68193716 -0.8572368  
-0.65046215
 -0.6993756  -1.2244141  -1.0938729  -0.50369143 -0.51830524 -0.738452
 -0.7214286  -0.48115745 -0.9380924  -0.9341769  -0.5916775  -1.2896856
 -0.7264182  -0.9746917  -0.783249   -0.7659018  -0.86214024 -0.47784212]
not close rhs = [ 0.44102234  0.12418899 -0.04359123  0.42274666  0.24744703  
0.45422167
  0.40530816 -0.11973029  0.01081094  0.6009924   0.5863786   0.3662318
  0.38325527  0.62352633  0.1665914   0.1705069   0.5130063  -0.18500176
  0.37826565  0.12999213  0.3214348   0.3387820.24254355  0.62684166]
not close dif = [1.1046839 1.1046838 1.1046838 1.1046839 1.1046839 1.1046839 
1.1046838
 1.1046839 1.1046839 1.1046839 1.1046839 1.1046839 1.1046839 1.1046838
 1.1046839 1.1046839 1.1046839 1.1046839 1.1046839 1.1046839 1.1046839
 1.1046839 1.1046838 1.1046838]
not close tol = [0.00100044 0.00100012 0.0014 0.00100042 0.00100025 
0.00100045
 0.00100041 0.00100012 0.0011 0.0010006  0.00100059 0.00100037
 0.00100038 0.00100062 0.00100017 0.00100017 0.00100051 0.00100019
 0.00100038 0.00100013 0.00100032 0.00100034 0.00100024 0.00100063]

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/test/Transforms/SLPVectorizer/X86/shrink_after_reorder.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp 
b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index ef0dea0f11d3..f124dd8ef374 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -4260,13 +4260,18 @@ Value *BoUpSLP::vectorizeTree(ArrayRef VL) {
   if (E->isSame(VL)) {
 Value *V = vectorizeTree(E);
 if (VL.size() == E->Scalars.size() && !E->ReuseShuffleIndices.empty()) 
{
-  // Reshuffle to get only unique values.
-  SmallVector UniqueIdxs;
-  SmallSet UsedIdxs;
-  for (int Idx : E->ReuseShuffleIndices)
-if (UsedIdxs.insert(Idx).second)
-  UniqueIdxs.emplace_back(Idx);
-  V = Builder.CreateShuffleVector(V, UniqueIdxs, "shrink.shuffle");
+  // We need to get the vectorized value but without shuffle.
+  if (auto *SV = dyn_cast(V)) {
+V = SV->getOperand(0);
+  } else {
+// Reshuffle to get only unique values.
+SmallVector UniqueIdxs;
+SmallSet UsedIdxs;
+for (int Idx : E->ReuseShuffleIndices)
+  if (UsedIdxs.insert(Idx).second)
+UniqueIdxs.emplace_back(Idx);
+V = Builder.CreateShuffleVector(V, UniqueIdxs);
+  }
 }
 return V;
   }

diff  --git a/llvm/test/Transforms/SLPVectorizer/X86/shrink_after_reorder.ll 
b/llvm/test/Transforms/SLPVectorizer/X86/shrink_after_reorder.ll
index 533b48eec295..110e114b 100644
--- a/llvm/test/Transforms/SLPVectorizer/X86/shrink_after_reorder.ll
+++ b/llvm/test/Transforms/SLPVectorizer/X86/shrink_after_reorder.ll
@@ -10,8 +10,7 @@ define void @wombat(i32* %ptr, i32* %ptr1) {
 ; CHECK-NEXT:[[TMP1:%.*]] = load <2 x i32>, <2 x i32>* [[TMP0]], align 8
 ; CHECK-NEXT:[[SHUFFLE:%.*]] = shufflevector <2 x i32> [[TMP1]], <2 x i32> 
poison, <4 x i32> 
 ; CHECK-NEXT:[[TMP27:%.*]] = getelementptr inbounds i32, i32* 
[[PTR1:%.*]], i32 3
-; CHECK-NEXT:[[SHRINK_SHUFFLE:%.*]] = shufflevector <4 x i32> [[SHUFFLE]], 
<4 x i32> poison, <2 x i32> 
-; CHECK-NEXT:[[TMP2:%.*]] = add nsw <2 x i32> [[SHRINK_SHUFFLE]], 
+; CHECK-NEXT:[[TMP2:%.*]] = add nsw <2 x i32> [[TMP1]], 
 ; CHECK-NEXT:[[SHUFFLE1:%.*]] = shufflevector <2 x i32> [[TMP2]], <2 x 
i32> poison, <4 x i32> 
 ; CHECK-NEXT:[[TMP34:%.*]] = getelementptr inbounds i32, i32* [[PTR1]], 
i32 4
 ; CHECK-NEXT:[[TMP40:%.*]] = getelementptr inbounds i32, i32* [[PTR1]], 
i32 5



___
llvm-branch-commits mailing list
llvm-branch-commit

[llvm-branch-commits] [mlir] f8184d4 - [mlir] Lookup the latest value with a legal type when remapping values.

2020-12-16 Thread Alexander Belyaev via llvm-branch-commits

Author: Alexander Belyaev
Date: 2020-12-16T09:53:19+01:00
New Revision: f8184d4c44dff1fab1311f0c23ab50936647

URL: 
https://github.com/llvm/llvm-project/commit/f8184d4c44dff1fab1311f0c23ab50936647
DIFF: 
https://github.com/llvm/llvm-project/commit/f8184d4c44dff1fab1311f0c23ab50936647.diff

LOG: [mlir] Lookup the latest value with a legal type when remapping values.

The current condition implies that the target materialization will be
called even if the type is the new operand type is legal, but slightly
different. For example, if there is a bufferization pattern that changes
memref layout, then target materialization for an illegal type
(TensorType) would be called.

Differential Revision: https://reviews.llvm.org/D93126

Added: 


Modified: 
mlir/lib/Transforms/Utils/DialectConversion.cpp

Removed: 




diff  --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp 
b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index 0a1a6b712ff2..61371b2c08b6 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -105,10 +105,15 @@ namespace {
 /// functionality, i.e. we will traverse if the mapped value also has a 
mapping.
 struct ConversionValueMapping {
   /// Lookup a mapped value within the map. If a mapping for the provided value
-  /// does not exist then return the provided value. If `desiredType` is
-  /// non-null, returns the most recently mapped value with that type. If an
-  /// operand of that type does not exist, defaults to normal behavior.
-  Value lookupOrDefault(Value from, Type desiredType = nullptr) const;
+  /// does not exist then return the provided value.
+  Value lookupOrDefault(Value from) const;
+
+  /// Lookup the latest legal value within the map. If a mapping for the
+  /// provided value does not exist then return the provided value. If
+  /// `converter` is non-null, returns the most recently mapped value with the
+  /// legal type. If an operand of that type does not exist, defaults to normal
+  /// behavior.
+  Value lookupLatestLegal(Value from, TypeConverter *converter) const;
 
   /// Lookup a mapped value within the map, or return null if a mapping does 
not
   /// exist. If a mapping exists, this follows the same behavior of
@@ -127,22 +132,24 @@ struct ConversionValueMapping {
 };
 } // end anonymous namespace
 
-Value ConversionValueMapping::lookupOrDefault(Value from,
-  Type desiredType) const {
-  // If there was no desired type, simply find the leaf value.
-  if (!desiredType) {
-// If this value had a valid mapping, unmap that value as well in the case
-// that it was also replaced.
-while (auto mappedValue = mapping.lookupOrNull(from))
-  from = mappedValue;
-return from;
-  }
+Value ConversionValueMapping::lookupOrDefault(Value from) const {
+  // If this value had a valid mapping, unmap that value as well in the case
+  // that it was also replaced.
+  while (auto mappedValue = mapping.lookupOrNull(from))
+from = mappedValue;
+  return from;
+}
 
-  // Otherwise, try to find the deepest value that has the desired type.
-  Value desiredValue;
+Value ConversionValueMapping::lookupLatestLegal(
+Value from, TypeConverter *converter) const {
+  if (!converter)
+return lookupOrDefault(from);
+
+  // Otherwise, try to find the deepest value that has the legal type.
+  Value legalValue;
   do {
-if (from.getType() == desiredType)
-  desiredValue = from;
+if (converter->isLegal(from.getType()))
+  legalValue = from;
 
 Value mappedValue = mapping.lookupOrNull(from);
 if (!mappedValue)
@@ -151,7 +158,7 @@ Value ConversionValueMapping::lookupOrDefault(Value from,
   } while (true);
 
   // If the desired value was found use it, otherwise default to the leaf 
value.
-  return desiredValue ? desiredValue : from;
+  return legalValue ? legalValue : from;
 }
 
 Value ConversionValueMapping::lookupOrNull(Value from) const {
@@ -1039,22 +1046,41 @@ LogicalResult 
ConversionPatternRewriterImpl::remapValues(
 Value operand = it.value();
 Type origType = operand.getType();
 
-// If a converter was provided, get the desired legal types for this
-// operand.
-Type desiredType;
+Value newOperand = mapping.lookupLatestLegal(operand, converter);
+
+// Handle the case where the conversion was 1->1 and the new operand type
+// isn't legal.
+Type newOperandType = newOperand.getType();
 if (converter) {
-  // If there is no legal conversion, fail to match this pattern.
-  legalTypes.clear();
-  if (failed(converter->convertType(origType, legalTypes))) {
-return notifyMatchFailure(loc, [=](Diagnostic &diag) {
-  diag << "unable to convert type for operand #" << it.index()
-   << ", type was " << origType;
-});
+  if (!converter->isLegal(newOpe

[llvm-branch-commits] [mlir] 9ca67d7 - Revert "[mlir] Lookup the latest value with a legal type when remapping values."

2020-12-16 Thread Alexander Belyaev via llvm-branch-commits

Author: Alexander Belyaev
Date: 2020-12-16T23:09:04+01:00
New Revision: 9ca67d7f4467a5dab4287e7c431f9daf313ca38a

URL: 
https://github.com/llvm/llvm-project/commit/9ca67d7f4467a5dab4287e7c431f9daf313ca38a
DIFF: 
https://github.com/llvm/llvm-project/commit/9ca67d7f4467a5dab4287e7c431f9daf313ca38a.diff

LOG: Revert "[mlir] Lookup the latest value with a legal type when remapping 
values."

This reverts commit f8184d4c44dff1fab1311f0c23ab50936647.

Added: 


Modified: 
mlir/lib/Transforms/Utils/DialectConversion.cpp

Removed: 




diff  --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp 
b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index 61371b2c08b6..0a1a6b712ff2 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -105,15 +105,10 @@ namespace {
 /// functionality, i.e. we will traverse if the mapped value also has a 
mapping.
 struct ConversionValueMapping {
   /// Lookup a mapped value within the map. If a mapping for the provided value
-  /// does not exist then return the provided value.
-  Value lookupOrDefault(Value from) const;
-
-  /// Lookup the latest legal value within the map. If a mapping for the
-  /// provided value does not exist then return the provided value. If
-  /// `converter` is non-null, returns the most recently mapped value with the
-  /// legal type. If an operand of that type does not exist, defaults to normal
-  /// behavior.
-  Value lookupLatestLegal(Value from, TypeConverter *converter) const;
+  /// does not exist then return the provided value. If `desiredType` is
+  /// non-null, returns the most recently mapped value with that type. If an
+  /// operand of that type does not exist, defaults to normal behavior.
+  Value lookupOrDefault(Value from, Type desiredType = nullptr) const;
 
   /// Lookup a mapped value within the map, or return null if a mapping does 
not
   /// exist. If a mapping exists, this follows the same behavior of
@@ -132,24 +127,22 @@ struct ConversionValueMapping {
 };
 } // end anonymous namespace
 
-Value ConversionValueMapping::lookupOrDefault(Value from) const {
-  // If this value had a valid mapping, unmap that value as well in the case
-  // that it was also replaced.
-  while (auto mappedValue = mapping.lookupOrNull(from))
-from = mappedValue;
-  return from;
-}
-
-Value ConversionValueMapping::lookupLatestLegal(
-Value from, TypeConverter *converter) const {
-  if (!converter)
-return lookupOrDefault(from);
+Value ConversionValueMapping::lookupOrDefault(Value from,
+  Type desiredType) const {
+  // If there was no desired type, simply find the leaf value.
+  if (!desiredType) {
+// If this value had a valid mapping, unmap that value as well in the case
+// that it was also replaced.
+while (auto mappedValue = mapping.lookupOrNull(from))
+  from = mappedValue;
+return from;
+  }
 
-  // Otherwise, try to find the deepest value that has the legal type.
-  Value legalValue;
+  // Otherwise, try to find the deepest value that has the desired type.
+  Value desiredValue;
   do {
-if (converter->isLegal(from.getType()))
-  legalValue = from;
+if (from.getType() == desiredType)
+  desiredValue = from;
 
 Value mappedValue = mapping.lookupOrNull(from);
 if (!mappedValue)
@@ -158,7 +151,7 @@ Value ConversionValueMapping::lookupLatestLegal(
   } while (true);
 
   // If the desired value was found use it, otherwise default to the leaf 
value.
-  return legalValue ? legalValue : from;
+  return desiredValue ? desiredValue : from;
 }
 
 Value ConversionValueMapping::lookupOrNull(Value from) const {
@@ -1046,41 +1039,22 @@ LogicalResult 
ConversionPatternRewriterImpl::remapValues(
 Value operand = it.value();
 Type origType = operand.getType();
 
-Value newOperand = mapping.lookupLatestLegal(operand, converter);
-
-// Handle the case where the conversion was 1->1 and the new operand type
-// isn't legal.
-Type newOperandType = newOperand.getType();
+// If a converter was provided, get the desired legal types for this
+// operand.
+Type desiredType;
 if (converter) {
-  if (!converter->isLegal(newOperandType)) {
-legalTypes.clear();
-
-// If there is no legal conversion, fail to match this pattern.
-if (failed(converter->convertType(origType, legalTypes))) {
-  return notifyMatchFailure(loc, [=](Diagnostic &diag) {
-diag << "unable to convert type for operand #" << it.index()
- << ", type was " << origType;
-  });
-}
-// TODO: There currently isn't any mechanism to do 1->N type conversion
-// via the PatternRewriter replacement API, so for now we just ignore
-// it.
-if (legalTypes.size() != 1) {
-  remapped.push_back(newOperand);
- 

[llvm-branch-commits] [mlir] c6b2c17 - [mlir] Add a print function for memref<*xi64>.

2020-11-23 Thread Alexander Belyaev via llvm-branch-commits

Author: Alexander Belyaev
Date: 2020-11-23T16:17:41+01:00
New Revision: c6b2c17e9c28afec7ec6ea10d78d7705d2ec49ea

URL: 
https://github.com/llvm/llvm-project/commit/c6b2c17e9c28afec7ec6ea10d78d7705d2ec49ea
DIFF: 
https://github.com/llvm/llvm-project/commit/c6b2c17e9c28afec7ec6ea10d78d7705d2ec49ea.diff

LOG: [mlir] Add a print function for memref<*xi64>.

Differential Revision: https://reviews.llvm.org/D91070

Added: 


Modified: 
mlir/include/mlir/ExecutionEngine/RunnerUtils.h
mlir/lib/ExecutionEngine/RunnerUtils.cpp

Removed: 




diff  --git a/mlir/include/mlir/ExecutionEngine/RunnerUtils.h 
b/mlir/include/mlir/ExecutionEngine/RunnerUtils.h
index 02e5c153bdbd..4f3cc7753a48 100644
--- a/mlir/include/mlir/ExecutionEngine/RunnerUtils.h
+++ b/mlir/include/mlir/ExecutionEngine/RunnerUtils.h
@@ -225,6 +225,8 @@ _mlir_ciface_print_memref_f64(UnrankedMemRefType 
*M);
 
 extern "C" MLIR_RUNNERUTILS_EXPORT void print_memref_i32(int64_t rank,
  void *ptr);
+extern "C" MLIR_RUNNERUTILS_EXPORT void print_memref_i64(int64_t rank,
+ void *ptr);
 extern "C" MLIR_RUNNERUTILS_EXPORT void print_memref_f32(int64_t rank,
  void *ptr);
 extern "C" MLIR_RUNNERUTILS_EXPORT void print_memref_f64(int64_t rank,

diff  --git a/mlir/lib/ExecutionEngine/RunnerUtils.cpp 
b/mlir/lib/ExecutionEngine/RunnerUtils.cpp
index 6df88b2e11ac..19315d7d1e6d 100644
--- a/mlir/lib/ExecutionEngine/RunnerUtils.cpp
+++ b/mlir/lib/ExecutionEngine/RunnerUtils.cpp
@@ -32,6 +32,10 @@ extern "C" void 
_mlir_ciface_print_memref_i32(UnrankedMemRefType *M) {
   impl::printMemRef(*M);
 }
 
+extern "C" void _mlir_ciface_print_memref_i64(UnrankedMemRefType *M) {
+  impl::printMemRef(*M);
+}
+
 extern "C" void _mlir_ciface_print_memref_f32(UnrankedMemRefType *M) {
   impl::printMemRef(*M);
 }
@@ -45,6 +49,11 @@ extern "C" void print_memref_i32(int64_t rank, void *ptr) {
   _mlir_ciface_print_memref_i32(&descriptor);
 }
 
+extern "C" void print_memref_i64(int64_t rank, void *ptr) {
+  UnrankedMemRefType descriptor = {rank, ptr};
+  _mlir_ciface_print_memref_i64(&descriptor);
+}
+
 extern "C" void print_memref_f32(int64_t rank, void *ptr) {
   UnrankedMemRefType descriptor = {rank, ptr};
   _mlir_ciface_print_memref_f32(&descriptor);



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] 0386b6a - [MLIR] Lower shape.num_elements -> shape.reduce.

2020-06-07 Thread Alexander Belyaev via llvm-branch-commits

Author: Alexander Belyaev
Date: 2020-06-07T16:25:14+02:00
New Revision: 0386b6ac330bd591f1f04c24c5416cc24b0c2c0a

URL: 
https://github.com/llvm/llvm-project/commit/0386b6ac330bd591f1f04c24c5416cc24b0c2c0a
DIFF: 
https://github.com/llvm/llvm-project/commit/0386b6ac330bd591f1f04c24c5416cc24b0c2c0a.diff

LOG: [MLIR] Lower shape.num_elements -> shape.reduce.

Differential Revision: https://reviews.llvm.org/D81279

Added: 
mlir/include/mlir/Dialect/Shape/Transforms/CMakeLists.txt
mlir/include/mlir/Dialect/Shape/Transforms/Passes.h
mlir/include/mlir/Dialect/Shape/Transforms/Passes.td
mlir/lib/Dialect/Shape/Transforms/CMakeLists.txt
mlir/lib/Dialect/Shape/Transforms/PassDetail.h
mlir/lib/Dialect/Shape/Transforms/ShapeToShapeLowering.cpp
mlir/test/Dialect/Shape/shape-to-shape.mlir

Modified: 
mlir/docs/Passes.md
mlir/include/mlir/Dialect/Shape/CMakeLists.txt
mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
mlir/include/mlir/InitAllPasses.h
mlir/lib/Dialect/Shape/CMakeLists.txt
mlir/lib/Dialect/Shape/IR/Shape.cpp

Removed: 




diff  --git a/mlir/docs/Passes.md b/mlir/docs/Passes.md
index 0f48396b220e..451b76370c7e 100644
--- a/mlir/docs/Passes.md
+++ b/mlir/docs/Passes.md
@@ -36,6 +36,10 @@ This document describes the available MLIR passes and their 
contracts.
 
 [include "QuantPasses.md"]
 
+## `shape` Dialect Passes
+
+[include "ShapePasses.md"]
+
 ## `spv` Dialect Passes
 
 [include "SPIRVPasses.md"]

diff  --git a/mlir/include/mlir/Dialect/Shape/CMakeLists.txt 
b/mlir/include/mlir/Dialect/Shape/CMakeLists.txt
index f33061b2d87c..9f57627c321f 100644
--- a/mlir/include/mlir/Dialect/Shape/CMakeLists.txt
+++ b/mlir/include/mlir/Dialect/Shape/CMakeLists.txt
@@ -1 +1,2 @@
 add_subdirectory(IR)
+add_subdirectory(Transforms)

diff  --git a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td 
b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
index ac5bedf3d6e3..e9cd539cef05 100644
--- a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
+++ b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
@@ -327,7 +327,7 @@ def Shape_ReduceOp : Shape_Op<"reduce",
 
   let arguments = (ins Shape_ShapeType:$shape, Variadic:$initVals);
   let results = (outs Variadic:$result);
-  let regions = (region SizedRegion<1>:$body);
+  let regions = (region SizedRegion<1>:$region);
 
   let builders = [
 OpBuilder<"OpBuilder &builder, OperationState &result, "

diff  --git a/mlir/include/mlir/Dialect/Shape/Transforms/CMakeLists.txt 
b/mlir/include/mlir/Dialect/Shape/Transforms/CMakeLists.txt
new file mode 100644
index ..629b8c0db294
--- /dev/null
+++ b/mlir/include/mlir/Dialect/Shape/Transforms/CMakeLists.txt
@@ -0,0 +1,5 @@
+set(LLVM_TARGET_DEFINITIONS Passes.td)
+mlir_tablegen(Passes.h.inc -gen-pass-decls)
+add_public_tablegen_target(MLIRShapeTransformsIncGen)
+
+add_mlir_doc(Passes -gen-pass-doc ShapePasses ./)

diff  --git a/mlir/include/mlir/Dialect/Shape/Transforms/Passes.h 
b/mlir/include/mlir/Dialect/Shape/Transforms/Passes.h
new file mode 100644
index ..29cf9d1b6715
--- /dev/null
+++ b/mlir/include/mlir/Dialect/Shape/Transforms/Passes.h
@@ -0,0 +1,30 @@
+//===- Passes.h - Pass Entrypoints --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This header file defines prototypes that expose pass constructors in the
+// shape transformation library.
+//
+//===--===//
+
+#ifndef MLIR_DIALECT_SHAPE_TRANSFORMS_PASSES_H_
+#define MLIR_DIALECT_SHAPE_TRANSFORMS_PASSES_H_
+
+#include 
+
+namespace mlir {
+
+class Pass;
+
+/// Creates an instance of the ShapeToShapeLowering pass that legalizes Shape
+/// dialect to be convertible to Standard. For example, `shape.num_elements` 
get
+/// transformed to `shape.reduce`, which can be lowered to SCF and Standard.
+std::unique_ptr createShapeToShapeLowering();
+
+} // end namespace mlir
+
+#endif // MLIR_DIALECT_SHAPE_TRANSFORMS_PASSES_H_

diff  --git a/mlir/include/mlir/Dialect/Shape/Transforms/Passes.td 
b/mlir/include/mlir/Dialect/Shape/Transforms/Passes.td
new file mode 100644
index ..46dc4dc37160
--- /dev/null
+++ b/mlir/include/mlir/Dialect/Shape/Transforms/Passes.td
@@ -0,0 +1,19 @@
+//===-- Passes.td - ShapeOps pass definition file --*- tablegen 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef MLIR_DIALECT_S