tensorflow/compiler/mlir/tensorflow/analysis/side_effect_analysis.cc
// Returns if `op` is know to not have any side effect.
Returns if `op` is know to not have any side effect.
Returns if ` op ` is know to not have any side effect .
bool OpIsKnownToHaveNoSideEffect(Operation* op) {
  if (op->hasNoSideEffect()) return true;
  if (auto if_op = llvm::dyn_cast<TF::IfOp>(op)) {
    return if_op.is_stateless();
  }
  if (auto while_op = llvm::dyn_cast<TF::WhileOp>(op)) {
    return while_op.is_stateless();
  }
   TODO(yuanzx): Remove this after all ops are defined in the dialect.
  if (op->getName().getDialect() !=
      TF::TensorFlowDialect::getDialectNamespace()) {
    return false;
  }
  StringRef op_name = op->getName().getStringRef();
   Drop the `tf.` prefix to query TF registry.
  auto node_name =
      op_name.drop_front(TensorFlowDialect::getDialectNamespace().size() + 1);
  const tensorflow::OpRegistrationData* op_reg_data =
      tensorflow::OpRegistry::Global()->LookUp(node_name.data());
  return op_reg_data && !op_reg_data->op_def.is_stateful();
}
bool OpIsKnownToHaveNoSideEffect ( Operation * op ) { if ( op -> hasNoSideEffect ( ) ) return true ; if ( auto if_op = llvm :: dyn_cast < TF :: IfOp > ( op ) ) { return if_op . is_stateless ( ) ; } if ( auto while_op = llvm :: dyn_cast < TF :: WhileOp > ( op ) ) { return while_op . is_stateless ( ) ; } if ( op -> getName ( ) . getDialect ( ) != TF :: TensorFlowDialect :: getDialectNamespace ( ) ) { return false ; } StringRef op_name = op -> getName ( ) . getStringRef ( ) ; auto node_name = op_name . drop_front ( TensorFlowDialect :: getDialectNamespace ( ) . size ( ) + 1 ) ; const tensorflow :: OpRegistrationData * op_reg_data = tensorflow :: OpRegistry :: Global ( ) -> LookUp ( node_name . data ( ) ) ; return op_reg_data && ! op_reg_data -> op_def . is_stateful ( ) ; }
Returns if `op` is know to not have any side effect.
Returns if ` op ` is know to not have any side effect .
// Try to get the statefulness flag from the registry. // // TODO(yuanzx): Remove this after all ops are defined in the dialect. // Drop the `tf.` prefix to query TF registry.