Skip to content

Commit 69ae105

Browse files
cantoniostf-text-github-robot
authored andcommitted
Update deprecated Status symbols to use absl::Status.
PiperOrigin-RevId: 739963031
1 parent bae5833 commit 69ae105

File tree

4 files changed

+35
-35
lines changed

4 files changed

+35
-35
lines changed

tensorflow_text/core/kernels/sentencepiece_kernels.cc

+8-8
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ struct SentencepieceResource : public ResourceBase {
6767
(reverse == this->reverse);
6868
}
6969

70-
Status AsGraphDef(GraphDefBuilder* builder, Node** out) const override {
70+
sentencepiece::util::Status AsGraphDef(GraphDefBuilder* builder, Node** out) const override {
7171
absl::ReaderMutexLock l(&mu);
7272
// We set use_node_name_sharing with a unique node name so that the resource
7373
// can outlive the kernel. This means that the lifetime of the re-created
@@ -93,10 +93,10 @@ struct SentencepieceResource : public ResourceBase {
9393
// TODO(broken) Determine a medium cost of a call to the SentencePiece processor
9494
constexpr int64 kCostPerUnit = 10000;
9595

96-
::tensorflow::Status ToTFStatus(const sentencepiece::util::Status& s) {
97-
if (s.ok()) return ::tensorflow::Status();
98-
return ::tensorflow::Status(static_cast<::tensorflow::errors::Code>(s.code()),
99-
::tensorflow::string(s.message()));
96+
absl::Status ToTFStatus(const sentencepiece::util::Status& s) {
97+
if (s.ok()) return sentencepiece::util::Status();
98+
return sentencepiece::util::Status(static_cast<absl::StatusCode>(s.code()),
99+
::tensorflow::string(s.message()));
100100
}
101101

102102
template <typename T>
@@ -114,8 +114,8 @@ int32 GetPieceOrId<int32>(
114114
return sp.id();
115115
}
116116

117-
tensorflow::Status HandleExtraOptions(OpKernelContext* ctx,
118-
SentencepieceResource* sp) {
117+
absl::Status HandleExtraOptions(OpKernelContext* ctx,
118+
SentencepieceResource* sp) {
119119
const Tensor* add_bos_tensor = nullptr;
120120
TF_RETURN_IF_ERROR(ctx->input("add_bos", &add_bos_tensor));
121121
const bool add_bos = add_bos_tensor->scalar<bool>()();
@@ -209,7 +209,7 @@ class SentencepieceOp : public OpKernel {
209209
GetNodeAttr(this->def(), "model", &model_proto_attr));
210210

211211
if (TF_PREDICT_FALSE(model_proto_attr.empty())) {
212-
return Status(tensorflow::errors::InvalidArgument(
212+
return sentencepiece::util::Status(tensorflow::errors::InvalidArgument(
213213
"Model argument must be specified."));
214214
}
215215
// Loads serialized sentencepiece model proto to enable embedding

tensorflow_text/core/kernels/split_merge_tokenize_kernel.cc

+13-13
Original file line numberDiff line numberDiff line change
@@ -64,24 +64,24 @@ bool IsBreakChar(absl::string_view text) {
6464
return u_isUWhiteSpace(c);
6565
}
6666

67-
Status TokenizeByLabel(const absl::string_view& text,
68-
const Tensor& labels_tensor,
69-
bool force_split_at_break_character,
70-
std::vector<std::string>* tokens,
71-
std::vector<int>* begin_offset,
72-
std::vector<int>* end_offset, int* num_tokens) {
67+
absl::Status TokenizeByLabel(const absl::string_view& text,
68+
const Tensor& labels_tensor,
69+
bool force_split_at_break_character,
70+
std::vector<std::string>* tokens,
71+
std::vector<int>* begin_offset,
72+
std::vector<int>* end_offset, int* num_tokens) {
7373
std::vector<absl::string_view> chars;
7474
if (!GetUTF8Chars(text, &chars)) {
75-
return Status(static_cast<tensorflow::errors::Code>(
76-
absl::StatusCode::kInvalidArgument),
77-
absl::StrCat("Input string is not utf8 valid: ", text));
75+
return absl::Status(
76+
static_cast<absl::StatusCode>(absl::StatusCode::kInvalidArgument),
77+
absl::StrCat("Input string is not utf8 valid: ", text));
7878
}
7979

8080
if (chars.size() > labels_tensor.dim_size(0)) {
81-
return Status(static_cast<tensorflow::errors::Code>(
82-
absl::StatusCode::kInvalidArgument),
83-
absl::StrCat("Number of labels ", labels_tensor.dim_size(0),
84-
" is insufficient for text ", text));
81+
return absl::Status(
82+
static_cast<absl::StatusCode>(absl::StatusCode::kInvalidArgument),
83+
absl::StrCat("Number of labels ", labels_tensor.dim_size(0),
84+
" is insufficient for text ", text));
8585
}
8686

8787
const int split_label = 0;

tensorflow_text/core/kernels/tokenizer_from_logits_kernel.cc

+9-9
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,22 @@ bool IsBreakChar(absl::string_view text) {
6868
// allows us to retrieve the corresponding data from logits. I.e., the logits
6969
// for the i-th character from text are logits(batch_index, i, 0) (for the
7070
// "split" action) and logits(batch_index, i, 1) (for the "merge" action).
71-
Status TokenizeByLogits(const absl::string_view& text,
72-
const TTypes<const float, 3>::Tensor& logits,
73-
int batch_index,
74-
bool force_split_at_break_character,
75-
std::vector<std::string>* tokens,
76-
std::vector<int>* begin_offset,
77-
std::vector<int>* end_offset, int* num_tokens) {
71+
absl::Status TokenizeByLogits(const absl::string_view& text,
72+
const TTypes<const float, 3>::Tensor& logits,
73+
int batch_index,
74+
bool force_split_at_break_character,
75+
std::vector<std::string>* tokens,
76+
std::vector<int>* begin_offset,
77+
std::vector<int>* end_offset, int* num_tokens) {
7878
std::vector<absl::string_view> chars;
7979
if (!GetUTF8Chars(text, &chars)) {
80-
return Status(
80+
return absl::Status(
8181
static_cast<absl::StatusCode>(absl::StatusCode::kInvalidArgument),
8282
absl::StrCat("Input string is not utf8 valid: ", text));
8383
}
8484

8585
if (chars.size() > logits.dimension(1)) {
86-
return Status(
86+
return absl::Status(
8787
static_cast<absl::StatusCode>(absl::StatusCode::kInvalidArgument),
8888
absl::StrCat("Number of logits, ", logits.dimension(1),
8989
", is insufficient for text \"", text, "\""));

tensorflow_text/core/kernels/wordpiece_kernel.cc

+5-5
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ bool GetSplitUnknownCharacters(OpKernelConstruction* ctx) {
8282
return split_unknown_characters;
8383
}
8484

85-
Status GetTableHandle(const string& input_name, OpKernelContext* ctx,
86-
string* container, string* table_handle) {
85+
absl::Status GetTableHandle(const string& input_name, OpKernelContext* ctx,
86+
string* container, string* table_handle) {
8787
{
8888
mutex* mu;
8989
TF_RETURN_IF_ERROR(ctx->input_ref_mutex(input_name, &mu));
@@ -105,8 +105,8 @@ Status GetTableHandle(const string& input_name, OpKernelContext* ctx,
105105
// Gets the LookupTable stored in the ctx->resource_manager() with key
106106
// passed by attribute with name input_name, returns null if the table
107107
// doesn't exist.
108-
Status GetLookupTable(const string& input_name, OpKernelContext* ctx,
109-
lookup::LookupInterface** table) {
108+
absl::Status GetLookupTable(const string& input_name, OpKernelContext* ctx,
109+
lookup::LookupInterface** table) {
110110
string container;
111111
string table_handle;
112112
DataType handle_dtype;
@@ -135,7 +135,7 @@ class LookupTableVocab : public WordpieceVocab {
135135
Tensor default_value_;
136136
};
137137

138-
Status ToStatus(const LookupStatus& status) {
138+
absl::Status ToStatus(const LookupStatus& status) {
139139
if (status.success) {
140140
return absl::OkStatus();
141141
}

0 commit comments

Comments
 (0)