tensorflow/compiler/jit/resource_operation_safety_analysis.cc
// Maps `n` to the XlaResourceOpKind corresponding to its operation.  If `n` is
// not a resource operation recognized by XLA then sets `out_resource_op_kind`
// to nullopt.
Maps `n` to the XlaResourceOpKind corresponding to its operation.  If `n` is
not a resource operation recognized by XLA then sets `out_resource_op_kind`
to nullopt.
Maps ` n ` to the XlaResourceOpKind corresponding to its operation . If ` n ` is not a resource operation recognized by XLA then sets ` out_resource_op_kind ` to nullopt .
Status XlaResourceOpKindForNode(
    const Node& n, const FunctionLibraryDefinition* flib_def,
    const std::function<Status(const Node&, bool*)>& resource_ops_to_ignore,
    absl::optional<XlaResourceOpKind>* out_resource_op_kind) {
  bool should_ignore = false;
  if (resource_ops_to_ignore) {
    TF_RETURN_IF_ERROR(resource_ops_to_ignore(n, &should_ignore));
  }
  if (should_ignore) {
    *out_resource_op_kind = absl::nullopt;
    return Status::OK();
  }
  const XlaResourceOpInfo* op_info = GetResourceOpInfoForOp(n.type_string());
  if (op_info) {
    *out_resource_op_kind = op_info->kind();
    return Status::OK();
  }
  if (MayCallFunction(n, flib_def)) {
    *out_resource_op_kind = XlaResourceOpKind::kReadWrite;
  } else {
    *out_resource_op_kind = absl::nullopt;
  }
  return Status::OK();
}
Status XlaResourceOpKindForNode ( const Node & n , const FunctionLibraryDefinition * flib_def , const std :: function < Status ( const Node & , bool * ) > & resource_ops_to_ignore , absl :: optional < XlaResourceOpKind > * out_resource_op_kind ) { bool should_ignore = false ; if ( resource_ops_to_ignore ) { TF_RETURN_IF_ERROR ( resource_ops_to_ignore ( n , & should_ignore ) ) ; } if ( should_ignore ) { * out_resource_op_kind = absl :: nullopt ; return Status :: OK ( ) ; } const XlaResourceOpInfo * op_info = GetResourceOpInfoForOp ( n . type_string ( ) ) ; if ( op_info ) { * out_resource_op_kind = op_info -> kind ( ) ; return Status :: OK ( ) ; } if ( MayCallFunction ( n , flib_def ) ) { * out_resource_op_kind = XlaResourceOpKind :: kReadWrite ; } else { * out_resource_op_kind = absl :: nullopt ; } return Status :: OK ( ) ; }
Maps `n` to the XlaResourceOpKind corresponding to its operation.
Maps ` n ` to the XlaResourceOpKind corresponding to its operation .
// We conservatively assume that functions will both read and write resource // variables.  In the future we may consider doing some form of // inter-procedural analysis.