[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:48:53 PDT 2020
tpopp updated this revision to Diff 265278.
tpopp added a comment.
Remove named TODO.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D80307/new/
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
@@ -368,7 +368,7 @@
// Shape constraint related ops.
//===----------------------------------------------------------------------===//
-//TODO(tpopp): Move the code below and witnesses to a different file.
+//TODO: Move the code below and witnesses to a different file.
def Shape_AnyOp : Shape_Op<"any",
[NoSideEffect, DeclareOpInterfaceMethods<InferTypeOpInterface>]> {
let summary = "Return any combination of the input shapes.";
@@ -499,7 +499,25 @@
let assemblyFormat = "$inputs attr-dict";
}
+// TODO: 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.265278.patch
Type: text/x-patch
Size: 2175 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200520/9ecbaea9/attachment.bin>
More information about the llvm-commits
mailing list