Skip to content
Permalink
Browse files Browse the repository at this point in the history
Fix tf.raw_ops.QuantizeAndDequantizeV3 array index failure.
PiperOrigin-RevId: 370577691
Change-Id: Ifeae64212f6bcd139435824fa2748d1329213c4c
  • Loading branch information
Amit Patankar authored and tensorflower-gardener committed Apr 27, 2021
1 parent 11ff7f8 commit 99085e8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tensorflow/core/kernels/quantize_and_dequantize_op.cc
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 @@ -234,6 +235,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 99085e8

Please sign in to comment.