Add a convenient `clone()` method on the `Op` class that forward to the underlying `Operation` (NFC)

PiperOrigin-RevId: 266685852
This commit is contained in:
Mehdi Amini 2019-09-01 16:15:14 -07:00 committed by A. Unique TensorFlower
parent 765d60fd4d
commit 8ce2274d0d
2 changed files with 17 additions and 1 deletions

View 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(); }

View 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.