29 lines
1.1 KiB
Diff
29 lines
1.1 KiB
Diff
From 4071d8e2f6c45c1955a811fee757ca2adbe462c1 Mon Sep 17 00:00:00 2001
|
|
From: Amit Patankar <amitpatankar@google.com>
|
|
Date: Thu, 29 Apr 2021 12:24:18 -0700
|
|
Subject: [PATCH] Fix FPE issue with `tf.raw_ops.Reverse`.
|
|
|
|
PiperOrigin-RevId: 371176973
|
|
Change-Id: Ic6d483bfc95313ec2299c2d1c956cfe96c96626c
|
|
---
|
|
tensorflow/core/kernels/reverse_op.cc | 6 ++++++
|
|
1 file changed, 6 insertions(+)
|
|
|
|
diff --git a/tensorflow/core/kernels/reverse_op.cc b/tensorflow/core/kernels/reverse_op.cc
|
|
index 5555a141b6c7b..560fac7133667 100644
|
|
--- a/tensorflow/core/kernels/reverse_op.cc
|
|
+++ b/tensorflow/core/kernels/reverse_op.cc
|
|
@@ -155,6 +155,12 @@ class ReverseOp : public OpKernel {
|
|
|
|
void Compute(OpKernelContext* context) override {
|
|
const Tensor& input = context->input(0);
|
|
+ // If input is provided, check to make sure the first dimension is valid.
|
|
+ if (input.dims() > 0) {
|
|
+ OP_REQUIRES(
|
|
+ context, input.dim_size(0) != 0,
|
|
+ errors::InvalidArgument("Invalid input first dimension. Found 0."));
|
|
+ }
|
|
const Tensor& dims = context->input(1);
|
|
|
|
if (TensorShapeUtils::IsScalar(input.shape())) {
|