Skip to content

Commit

Permalink
Merge pull request #49531 from geetachavan1/cherrypicks_4JS7U
Browse files Browse the repository at this point in the history
Fix `tf.raw_ops.QuantizeAndDequantizeV3` array index failure.
  • Loading branch information
mihaimaruseac committed May 27, 2021
2 parents 308a5d3 + 2e5b9d7 commit 30589e3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tensorflow/core/kernels/quantize_and_dequantize_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#include "tensorflow/core/framework/op_requires.h"
#define EIGEN_USE_THREADS

#if (defined(GOOGLE_CUDA) && GOOGLE_CUDA) || \
Expand Down Expand Up @@ -151,6 +152,10 @@ class QuantizeAndDequantizeV3Op : public OpKernel {

void Compute(OpKernelContext* ctx) override {
const Tensor& input = ctx->input(0);
OP_REQUIRES(ctx, axis_ < input.dims(),
errors::InvalidArgument(
"Axis requested is larger than input dimensions. Axis: ",
axis_, " Input Dimensions: ", input.dims()));
const int depth = (axis_ == -1) ? 1 : input.dim_size(axis_);
Tensor* output = nullptr;
OP_REQUIRES_OK(ctx, ctx->allocate_output(0, input.shape(), &output));
Expand Down

0 comments on commit 30589e3

Please sign in to comment.