From b12aa1d44352de21d1a6faaf04172d8c2508b42b Mon Sep 17 00:00:00 2001 From: Mihai Maruseac Date: Mon, 19 Apr 2021 18:32:56 -0700 Subject: [PATCH] Fix one more FPE. --- tensorflow/core/kernels/conv_ops.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tensorflow/core/kernels/conv_ops.cc b/tensorflow/core/kernels/conv_ops.cc index ef13eb3f..2d357710 100644 --- a/tensorflow/core/kernels/conv_ops.cc +++ b/tensorflow/core/kernels/conv_ops.cc @@ -260,6 +260,11 @@ struct LaunchConv2DOp { const int64 out_depth = output->dim_size(3); const int64 patch_depth = filter.dim_size(2); + if (patch_depth <= 0) { + ctx->SetStatus(errors::InvalidArgument( + "filter depth must be stricly positive, got ", patch_depth)); + return; + } if (in_depth % patch_depth != 0) { ctx->SetStatus(errors::InvalidArgument( "input depth must be evenly divisible by filter depth: ", in_depth, @@ -268,6 +273,11 @@ struct LaunchConv2DOp { } const int64 num_groups = in_depth / patch_depth; + if (num_groups <= 0) { + ctx->SetStatus(errors::InvalidArgument( + "number of groups must be stricly positive, got ", num_groups)); + return; + } if (out_depth % num_groups != 0 || out_depth < num_groups) { ctx->SetStatus(errors::InvalidArgument( "output depth must be evenly divisible by number of groups: ", @@ -536,6 +546,9 @@ Status ComputeConv2DDimension(const Conv2DParameters& params, errors::InvalidArgument("Patch depth too large")); const int in_depth = static_cast(in_depth_raw); const int patch_depth = static_cast(patch_depth_raw); + TF_REQUIRES(patch_depth > 0, + errors::InvalidArgument( + "filter depth must be stricly positive, got", patch_depth)); TF_REQUIRES(in_depth % patch_depth == 0, errors::InvalidArgument( "input depth must be evenly divisible by filter depth: ", -- 2.23.0