Skip to content

Commit 59458ae

Browse files
No public description
PiperOrigin-RevId: 970042531
1 parent 6fd5c1d commit 59458ae

2 files changed

Lines changed: 13 additions & 14 deletions

File tree

tensorflow_text/core/kernels/sentencepiece/sentencepiece_detokenizer_kernel.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ class TFSentencepieceDetokenizerOp : public tensorflow::OpKernel {
4848
void Compute(tensorflow::OpKernelContext* ctx) override {
4949
const auto& model_tensor = ctx->input(kSPModelIndex);
5050
const auto& input_values_tensor = ctx->input(kInputIndex);
51-
const auto input_values_flat =
52-
input_values_tensor.flat<tensorflow::int32>();
51+
const auto input_values_flat = input_values_tensor.flat<int32_t>();
5352
const auto& input_splits_tensor = ctx->input(kInputSplits);
5453
const auto input_splits_flat = input_splits_tensor.flat<Tsplits>();
5554
OP_REQUIRES(ctx, input_splits_flat.size() > 0,
@@ -92,10 +91,10 @@ class TFSentencepieceDetokenizerOp : public tensorflow::OpKernel {
9291
REGISTER_KERNEL_BUILDER(
9392
Name("TFText>FastSentencepieceDetokenize")
9493
.Device(tensorflow::DEVICE_CPU)
95-
.TypeConstraint<tensorflow::int32>("Tsplits"),
96-
tensorflow::text::TFSentencepieceDetokenizerOp<tensorflow::int32>);
94+
.TypeConstraint<int32_t>("Tsplits"),
95+
tensorflow::text::TFSentencepieceDetokenizerOp<int32_t>);
9796
REGISTER_KERNEL_BUILDER(
9897
Name("TFText>FastSentencepieceDetokenize")
9998
.Device(tensorflow::DEVICE_CPU)
100-
.TypeConstraint<tensorflow::int64>("Tsplits"),
101-
tensorflow::text::TFSentencepieceDetokenizerOp<tensorflow::int64>);
99+
.TypeConstraint<int64_t>("Tsplits"),
100+
tensorflow::text::TFSentencepieceDetokenizerOp<int64_t>);

tensorflow_text/core/kernels/sentencepiece/sentencepiece_tokenizer_kernel.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ class TFSentencepieceOp : public tensorflow::OpKernel {
6161
const auto& reverse_tensor = ctx->input(kReverseInput);
6262
const bool reverse = reverse_tensor.scalar<bool>()();
6363

64-
std::vector<int32> encoded;
65-
std::vector<int32> splits;
64+
std::vector<int32_t> encoded;
65+
std::vector<int32_t> splits;
6666
for (int i = 0; i < num_of_input_values; ++i) {
6767
const auto res = sentencepiece::EncodeString(
6868
input_values_flat(i), model_tensor.data(), add_bos, add_eos, reverse);
@@ -77,20 +77,20 @@ class TFSentencepieceOp : public tensorflow::OpKernel {
7777
tensorflow::Tensor* output_values_tensor = nullptr;
7878
tensorflow::Tensor* output_splits_tensor = nullptr;
7979
OP_REQUIRES(ctx, encoded.size() < std::numeric_limits<int32_t>::max(),
80-
errors::InvalidArgument(
80+
absl::InvalidArgumentError(
8181
"Encoded input must contain less than 2^31 characters."));
82-
OP_REQUIRES(
83-
ctx, splits.size() + 1 < std::numeric_limits<int32_t>::max(),
84-
errors::InvalidArgument("Splits tensor is limited to 2^31-1 values."));
82+
OP_REQUIRES(ctx, splits.size() + 1 < std::numeric_limits<int32_t>::max(),
83+
absl::InvalidArgumentError(
84+
"Splits tensor is limited to 2^31-1 values."));
8585
OP_REQUIRES_OK(
8686
ctx, ctx->allocate_output(0, {static_cast<int32_t>(encoded.size())},
8787
&output_values_tensor));
8888
OP_REQUIRES_OK(
8989
ctx, ctx->allocate_output(1, {static_cast<int32_t>(splits.size()) + 1},
9090
&output_splits_tensor));
9191

92-
auto values_tensor_flat = output_values_tensor->vec<int32>();
93-
auto splits_tensor_flat = output_splits_tensor->vec<int32>();
92+
auto values_tensor_flat = output_values_tensor->vec<int32_t>();
93+
auto splits_tensor_flat = output_splits_tensor->vec<int32_t>();
9494
for (int32_t i = 0; i < encoded.size(); ++i) {
9595
values_tensor_flat(i) = encoded[i];
9696
}

0 commit comments

Comments
 (0)