Skip to content
Permalink
Browse files Browse the repository at this point in the history
Disallow negative ngram_widths values in tf.raw_ops.StringNGrams
PiperOrigin-RevId: 387148179
Change-Id: I641395a09a208be72ef9b3ceb128cf8a83a0775b
  • Loading branch information
pak-laura authored and tensorflower-gardener committed Jul 27, 2021
1 parent 9659aea commit c283e54
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tensorflow/core/kernels/string_ngrams_op.cc
Expand Up @@ -53,6 +53,12 @@ class StringNGramsOp : public tensorflow::OpKernel {
}

void Compute(tensorflow::OpKernelContext* context) override {
for (int ngram_width : ngram_widths_) {
OP_REQUIRES(
context, ngram_width > 0,
errors::InvalidArgument("ngram_widths must contain positive values"));
}

const tensorflow::Tensor* data;
OP_REQUIRES_OK(context, context->input("data", &data));
const auto& input_data = data->flat<tstring>().data();
Expand Down

0 comments on commit c283e54

Please sign in to comment.