Add a convenient `clone()` method on the `Op` class that forward to the underlying...
authorMehdi Amini <aminim@google.com>
Sun, 1 Sep 2019 23:15:14 +0000 (16:15 -0700)
committerA. Unique TensorFlower <gardener@tensorflow.org>
Sun, 1 Sep 2019 23:15:45 +0000 (16:15 -0700)
PiperOrigin-RevId: 266685852

mlir/include/mlir/IR/OpDefinition.h
mlir/include/mlir/IR/Operation.h

index 883e994..7edd56a 100644 (file)
@@ -906,6 +906,16 @@ public:
   /// Return the operation that this refers to.
   Operation *getOperation() { return OpState::getOperation(); }
 
+  /// Create a deep copy of this operation.
+  ConcreteType clone() { return cast<ConcreteType>(getOperation()->clone()); }
+
+  /// Create a partial copy of this operation without traversing into attached
+  /// regions. The new operation will have the same number of regions as the
+  /// original one, but they will be left empty.
+  ConcreteType cloneWithoutRegions() {
+    return cast<ConcreteType>(getOperation()->cloneWithoutRegions());
+  }
+
   /// Return the dialect that this refers to.
   Dialect *getDialect() { return getOperation()->getDialect(); }
 
index 97225d0..76e6c77 100644 (file)
@@ -94,10 +94,16 @@ public:
   Operation *clone(BlockAndValueMapping &mapper);
   Operation *clone();
 
-  /// Create a deep copy of this operation but keep the operation regions empty.
+  /// Create a partial copy of this operation without traversing into attached
+  /// regions. The new operation will have the same number of regions as the
+  /// original one, but they will be left empty.
   /// Operands are remapped using `mapper` (if present), and `mapper` is updated
   /// to contain the results.
   Operation *cloneWithoutRegions(BlockAndValueMapping &mapper);
+
+  /// Create a partial copy of this operation without traversing into attached
+  /// regions. The new operation will have the same number of regions as the
+  /// original one, but they will be left empty.
   Operation *cloneWithoutRegions();
 
   /// Returns the operation block that contains this operation.