Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No public description #1368

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions tensorflow_text/core/kernels/sentencepiece_kernels.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct SentencepieceResource : public ResourceBase {
(reverse == this->reverse);
}

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

::tensorflow::Status ToTFStatus(const sentencepiece::util::Status& s) {
if (s.ok()) return ::tensorflow::Status();
return ::tensorflow::Status(static_cast<::tensorflow::errors::Code>(s.code()),
::tensorflow::string(s.message()));
absl::Status ToTFStatus(const sentencepiece::util::Status& s) {
if (s.ok()) return sentencepiece::util::Status();
return sentencepiece::util::Status(static_cast<absl::StatusCode>(s.code()),
::tensorflow::string(s.message()));
}

template <typename T>
Expand All @@ -114,8 +114,8 @@ int32 GetPieceOrId<int32>(
return sp.id();
}

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

if (TF_PREDICT_FALSE(model_proto_attr.empty())) {
return Status(tensorflow::errors::InvalidArgument(
return sentencepiece::util::Status(tensorflow::errors::InvalidArgument(
"Model argument must be specified."));
}
// Loads serialized sentencepiece model proto to enable embedding
Expand Down
26 changes: 13 additions & 13 deletions tensorflow_text/core/kernels/split_merge_tokenize_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,24 @@ bool IsBreakChar(absl::string_view text) {
return u_isUWhiteSpace(c);
}

Status TokenizeByLabel(const absl::string_view& text,
const Tensor& labels_tensor,
bool force_split_at_break_character,
std::vector<std::string>* tokens,
std::vector<int>* begin_offset,
std::vector<int>* end_offset, int* num_tokens) {
absl::Status TokenizeByLabel(const absl::string_view& text,
const Tensor& labels_tensor,
bool force_split_at_break_character,
std::vector<std::string>* tokens,
std::vector<int>* begin_offset,
std::vector<int>* end_offset, int* num_tokens) {
std::vector<absl::string_view> chars;
if (!GetUTF8Chars(text, &chars)) {
return Status(static_cast<tensorflow::errors::Code>(
absl::StatusCode::kInvalidArgument),
absl::StrCat("Input string is not utf8 valid: ", text));
return absl::Status(
static_cast<absl::StatusCode>(absl::StatusCode::kInvalidArgument),
absl::StrCat("Input string is not utf8 valid: ", text));
}

if (chars.size() > labels_tensor.dim_size(0)) {
return Status(static_cast<tensorflow::errors::Code>(
absl::StatusCode::kInvalidArgument),
absl::StrCat("Number of labels ", labels_tensor.dim_size(0),
" is insufficient for text ", text));
return absl::Status(
static_cast<absl::StatusCode>(absl::StatusCode::kInvalidArgument),
absl::StrCat("Number of labels ", labels_tensor.dim_size(0),
" is insufficient for text ", text));
}

const int split_label = 0;
Expand Down
18 changes: 9 additions & 9 deletions tensorflow_text/core/kernels/tokenizer_from_logits_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,22 @@ bool IsBreakChar(absl::string_view text) {
// allows us to retrieve the corresponding data from logits. I.e., the logits
// for the i-th character from text are logits(batch_index, i, 0) (for the
// "split" action) and logits(batch_index, i, 1) (for the "merge" action).
Status TokenizeByLogits(const absl::string_view& text,
const TTypes<const float, 3>::Tensor& logits,
int batch_index,
bool force_split_at_break_character,
std::vector<std::string>* tokens,
std::vector<int>* begin_offset,
std::vector<int>* end_offset, int* num_tokens) {
absl::Status TokenizeByLogits(const absl::string_view& text,
const TTypes<const float, 3>::Tensor& logits,
int batch_index,
bool force_split_at_break_character,
std::vector<std::string>* tokens,
std::vector<int>* begin_offset,
std::vector<int>* end_offset, int* num_tokens) {
std::vector<absl::string_view> chars;
if (!GetUTF8Chars(text, &chars)) {
return Status(
return absl::Status(
static_cast<absl::StatusCode>(absl::StatusCode::kInvalidArgument),
absl::StrCat("Input string is not utf8 valid: ", text));
}

if (chars.size() > logits.dimension(1)) {
return Status(
return absl::Status(
static_cast<absl::StatusCode>(absl::StatusCode::kInvalidArgument),
absl::StrCat("Number of logits, ", logits.dimension(1),
", is insufficient for text \"", text, "\""));
Expand Down
10 changes: 5 additions & 5 deletions tensorflow_text/core/kernels/wordpiece_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ bool GetSplitUnknownCharacters(OpKernelConstruction* ctx) {
return split_unknown_characters;
}

Status GetTableHandle(const string& input_name, OpKernelContext* ctx,
string* container, string* table_handle) {
absl::Status GetTableHandle(const string& input_name, OpKernelContext* ctx,
string* container, string* table_handle) {
{
mutex* mu;
TF_RETURN_IF_ERROR(ctx->input_ref_mutex(input_name, &mu));
Expand All @@ -105,8 +105,8 @@ Status GetTableHandle(const string& input_name, OpKernelContext* ctx,
// Gets the LookupTable stored in the ctx->resource_manager() with key
// passed by attribute with name input_name, returns null if the table
// doesn't exist.
Status GetLookupTable(const string& input_name, OpKernelContext* ctx,
lookup::LookupInterface** table) {
absl::Status GetLookupTable(const string& input_name, OpKernelContext* ctx,
lookup::LookupInterface** table) {
string container;
string table_handle;
DataType handle_dtype;
Expand Down Expand Up @@ -135,7 +135,7 @@ class LookupTableVocab : public WordpieceVocab {
Tensor default_value_;
};

Status ToStatus(const LookupStatus& status) {
absl::Status ToStatus(const LookupStatus& status) {
if (status.success) {
return absl::OkStatus();
}
Expand Down