NFC: Change `classof` on registered operations to use pointer comparison.

The current implementation always uses string comparison, but if the operation is registered the AbstractOperation instance can be used to provide faster pointer comparison.

PiperOrigin-RevId: 272041333
This commit is contained in:
River Riddle 2019-09-30 12:35:21 -07:00 committed by A. Unique TensorFlower
parent c97a9320a0
commit 8e67039e31
1 changed files with 2 additions and 3 deletions

View File

@ -923,10 +923,9 @@ public:
Region *getParentRegion() { return getOperation()->getParentRegion(); }
/// Return true if this "op class" can match against the specified operation.
/// This hook can be overridden with a more specific implementation in
/// the subclass of Base.
///
static bool classof(Operation *op) {
if (auto *abstractOp = op->getAbstractOperation())
return &classof == abstractOp->classof;
return op->getName().getStringRef() == ConcreteType::getOperationName();
}