Skip to content
Permalink
Browse files Browse the repository at this point in the history
Fix one more FPE.
PiperOrigin-RevId: 369346568
Change-Id: I840fd575962adc879713a4c9cc59e6da3331caa7
  • Loading branch information
mihaimaruseac authored and tensorflower-gardener committed Apr 20, 2021
1 parent 988087b commit b12aa1d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tensorflow/core/kernels/conv_ops.cc
Expand Up @@ -260,6 +260,11 @@ struct LaunchConv2DOp<CPUDevice, T> {
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,
Expand All @@ -268,6 +273,11 @@ struct LaunchConv2DOp<CPUDevice, T> {
}

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: ",
Expand Down Expand Up @@ -536,6 +546,9 @@ Status ComputeConv2DDimension(const Conv2DParameters& params,
errors::InvalidArgument("Patch depth too large"));
const int in_depth = static_cast<int>(in_depth_raw);
const int patch_depth = static_cast<int>(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: ",
Expand Down

0 comments on commit b12aa1d

Please sign in to comment.