[PATCH] D80307: [mlir] Add a shape op that always returns a successful witness

Theodore Popp via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 20 09:16:17 PDT 2020


tpopp created this revision.
Herald added subscribers: llvm-commits, jurahul, Kayjukh, frgossen, grosul1, Joonsoo, stephenneuendorffer, liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, jpienaar, rriddle, mehdi_amini.
Herald added a reviewer: jpienaar.
Herald added a reviewer: silvas.
Herald added a project: LLVM.
tpopp added a reviewer: herhut.

This will later be used during canonicalization steps to replace
statically known passing constraints. This might later be removed once
witnesses can be represented as Attributes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80307

Files:
  mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
  mlir/test/Dialect/Shape/ops.mlir


Index: mlir/test/Dialect/Shape/ops.mlir
===================================================================
--- mlir/test/Dialect/Shape/ops.mlir
+++ mlir/test/Dialect/Shape/ops.mlir
@@ -73,7 +73,8 @@
   %1 = shape.const_shape [1, 2, 3]
   %w0 = shape.cstr_broadcastable %0, %1
   %w1 = shape.cstr_eq %0, %1
-  %w3 = shape.assuming_all %w0, %w1
+  %w2 = shape.true_witness
+  %w3 = shape.assuming_all %w0, %w1, %w2
   shape.assuming %w3 -> !shape.shape {
     %2 = shape.any %0, %1
     shape.assuming_yield %2 : !shape.shape
Index: mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
===================================================================
--- mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
+++ mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
@@ -499,7 +499,25 @@
   let assemblyFormat = "$inputs attr-dict";
 }
 
+// TODO(tpopp): Support witness attributes and then make this ConstantLike.
+// Note: This operation might be replaced with a general op that takes a
+// True/False Attribute.
+def Shape_TrueWitnessOp : Shape_Op<"true_witness", [NoSideEffect]> {
+  let summary = "An operation that returns a successful witness.";
+  let description = [{
+      %0 = shape.const_shape [1, 2, 3]
+      %1 = shape.const_shape [1, 2, 3]
+      %w0 = shape.cstr_eq(%0, %1) // Can be canonicalized to true_witness
+      %w1 = shape.true_witness
+      %w2 = shape.assuming_all(%w0, %w2) // Can be canonicalized to true_witness
+  }];
+  let builders = [OpBuilder<
+    "OpBuilder &b, OperationState &result",
+    "build(b, result, ::mlir::shape::WitnessType::get(b.getContext()));"
+  >];
 
-// Canonicalization patterns.
+  let assemblyFormat = "attr-dict";
+  let results = (outs Shape_WitnessType:$result);
+}
 
 #endif // SHAPE_OPS


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80307.265271.patch
Type: text/x-patch
Size: 1738 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200520/ffde0de0/attachment.bin>


More information about the llvm-commits mailing list