Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ class TFSentencepieceDetokenizerOp : public tensorflow::OpKernel {
void Compute(tensorflow::OpKernelContext* ctx) override {
const auto& model_tensor = ctx->input(kSPModelIndex);
const auto& input_values_tensor = ctx->input(kInputIndex);
const auto input_values_flat =
input_values_tensor.flat<tensorflow::int32>();
const auto input_values_flat = input_values_tensor.flat<int32_t>();
const auto& input_splits_tensor = ctx->input(kInputSplits);
const auto input_splits_flat = input_splits_tensor.flat<Tsplits>();
const int num_of_sentences = input_splits_flat.size() - 1;
Expand Down Expand Up @@ -81,10 +80,10 @@ class TFSentencepieceDetokenizerOp : public tensorflow::OpKernel {
REGISTER_KERNEL_BUILDER(
Name("TFText>FastSentencepieceDetokenize")
.Device(tensorflow::DEVICE_CPU)
.TypeConstraint<tensorflow::int32>("Tsplits"),
tensorflow::text::TFSentencepieceDetokenizerOp<tensorflow::int32>);
.TypeConstraint<int32_t>("Tsplits"),
tensorflow::text::TFSentencepieceDetokenizerOp<int32_t>);
REGISTER_KERNEL_BUILDER(
Name("TFText>FastSentencepieceDetokenize")
.Device(tensorflow::DEVICE_CPU)
.TypeConstraint<tensorflow::int64>("Tsplits"),
tensorflow::text::TFSentencepieceDetokenizerOp<tensorflow::int64>);
.TypeConstraint<int64_t>("Tsplits"),
tensorflow::text::TFSentencepieceDetokenizerOp<int64_t>);
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class TFSentencepieceOp : public tensorflow::OpKernel {
const auto& reverse_tensor = ctx->input(kReverseInput);
const bool reverse = reverse_tensor.scalar<bool>()();

std::vector<int32> encoded;
std::vector<int32> splits;
std::vector<int32_t> encoded;
std::vector<int32_t> splits;
for (int i = 0; i < num_of_input_values; ++i) {
const auto res = sentencepiece::EncodeString(
input_values_flat(i), model_tensor.data(), add_bos, add_eos, reverse);
Expand All @@ -89,8 +89,8 @@ class TFSentencepieceOp : public tensorflow::OpKernel {
ctx, ctx->allocate_output(1, {static_cast<int32_t>(splits.size()) + 1},
&output_splits_tensor));

auto values_tensor_flat = output_values_tensor->vec<int32>();
auto splits_tensor_flat = output_splits_tensor->vec<int32>();
auto values_tensor_flat = output_values_tensor->vec<int32_t>();
auto splits_tensor_flat = output_splits_tensor->vec<int32_t>();
for (int32_t i = 0; i < encoded.size(); ++i) {
values_tensor_flat(i) = encoded[i];
}
Expand Down