tensorflow/compiler/mlir/tensorflow/utils/export_utils.cc
// Returns true if the executor/control dialect op should map to Ref node in
// TensorFlow Graph. For control dialect NextIteration it uses the 1st operand
// type. For executor dialect NextIteration it uses the 2nd operand type. For
// all others (Enter/Exit/Merge/Switch), if the output type is ref, they
// correspond to the Ref equivalent op in TF Graph.
Returns true if the executor/control dialect op should map to Ref node in
TensorFlow Graph. For control dialect NextIteration it uses the 1st operand
type. For executor dialect NextIteration it uses the 2nd operand type. For
all others (Enter/Exit/Merge/Switch), if the output type is ref, they
correspond to the Ref equivalent op in TF Graph.
Returns true if the executor / control dialect op should map to Ref node in TensorFlow Graph . For control dialect NextIteration it uses the 1st operand type . For executor dialect NextIteration it uses the 2nd operand type . For all others ( Enter / Exit / Merge / Switch ) if the output type is ref they correspond to the Ref equivalent op in TF Graph .
static bool IsRefTypeControlOp(mlir::Operation* op) {
  if (auto next_iter_sink =
          llvm::dyn_cast<mlir::tf_executor::NextIterationSinkOp>(op))
    return mlir::getElementTypeOrSelf(next_iter_sink.input().getType())
        .isa<mlir::TF::TensorFlowRefType>();
  auto op_name_or_status = GetTensorFlowOpName(op->getName().getStringRef());
  if (!op_name_or_status.ok()) return false;
  auto op_name = op_name_or_status.ConsumeValueOrDie();
  if (op_name.equals("NextIteration"))
    return mlir::getElementTypeOrSelf(op->getOperand(0).getType())
        .isa<mlir::TF::TensorFlowRefType>();
  if (op_name.equals("Enter") || op_name.equals("Exit") ||
      op_name.equals("Switch") || op_name.equals("Merge")) {
    return getElementTypeOrSelf(op->getResult(0).getType())
        .isa<mlir::TF::TensorFlowRefType>();
  }
  return false;
}
static bool IsRefTypeControlOp ( mlir :: Operation * op ) { if ( auto next_iter_sink = llvm :: dyn_cast < mlir :: tf_executor :: NextIterationSinkOp > ( op ) ) return mlir :: getElementTypeOrSelf ( next_iter_sink . input ( ) . getType ( ) ) . isa < mlir :: TF :: TensorFlowRefType > ( ) ; auto op_name_or_status = GetTensorFlowOpName ( op -> getName ( ) . getStringRef ( ) ) ; if ( ! op_name_or_status . ok ( ) ) return false ; auto op_name = op_name_or_status . ConsumeValueOrDie ( ) ; if ( op_name . equals ( " " ) ) return mlir :: getElementTypeOrSelf ( op -> getOperand ( 0 ) . getType ( ) ) . isa < mlir :: TF :: TensorFlowRefType > ( ) ; if ( op_name . equals ( " " ) || op_name . equals ( " " ) || op_name . equals ( " " ) || op_name . equals ( " " ) ) { return getElementTypeOrSelf ( op -> getResult ( 0 ) . getType ( ) ) . isa < mlir :: TF :: TensorFlowRefType > ( ) ; } return false ; }
Returns true if the executor/control dialect op should map to Ref node in
TensorFlow Graph.
Returns true if the executor / control dialect op should map to Ref node in TensorFlow Graph .