Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INTEL MKL] Fix a bug within MklFusedBatchNormOp #37901

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 2 additions & 6 deletions tensorflow/core/kernels/mkl_fused_batch_norm_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ class MklFusedBatchNormOp : public OpKernel {
tf_shape_scale, mkl_shape_saved_mean);
DCHECK(*saved_mean_tensor);

// Set NAN mean value in case of empty input tensor
// Set 0 mean value in case of empty input tensor
auto saved_mean_data = (*saved_mean_tensor)->flat<U>().data();
std::fill_n(saved_mean_data, num_elements, static_cast<U>(0));

Expand All @@ -1019,7 +1019,7 @@ class MklFusedBatchNormOp : public OpKernel {
mkl_shape_saved_variance);
DCHECK(*saved_variance_tensor);

// Set NAN variance value in case of empty input tensor
// Set 0 variance value in case of empty input tensor
auto saved_variance_data = (*saved_variance_tensor)->flat<U>().data();
std::fill_n(saved_variance_data, num_elements, static_cast<U>(0));

Expand Down Expand Up @@ -1346,16 +1346,12 @@ class MklFusedBatchNormGradOp : public OpKernel {
mkl_shape_p.SetMklTensor(false);
AllocateOutputSetMklShape(context, kP1Index, &p1_tensor, TensorShape({}),
mkl_shape_p);
#ifndef ENABLE_MKLDNN_V1
std::fill_n(p1_tensor->flat<U>().data(), p1_tensor->shape().num_elements(),
static_cast<U>(0));
#endif // !ENABLE_MKLDNN_V1
AllocateOutputSetMklShape(context, kP2Index, &p2_tensor, TensorShape({}),
mkl_shape_p);
#ifndef ENABLE_MKLDNN_V1
std::fill_n(p2_tensor->flat<U>().data(), p2_tensor->shape().num_elements(),
static_cast<U>(0));
#endif // !ENABLE_MKLDNN_V1
}

memory::dims GetMeanVarianceDims() { return memory::dims({1, depth_}); }
Expand Down