message: [Intel MKL] Fixed a bug in mkl_conv2d constant filter caching which caused the filter output tensor not get updated
diff: @@ -570,15 +570,13 @@ class MklConvOp : public OpKernel {
  OP_REQUIRES(context, dilations_.size() == 5,
  errors::InvalidArgument("Dilation rates field must "
  "specify 5 dimensions"));
  - OP_REQUIRES(context,
  - (GetTensorDim(dilations_, data_format_, 'N') == 1 &&
  + OP_REQUIRES(context, (GetTensorDim(dilations_, data_format_, 'N') == 1 &&
  GetTensorDim(dilations_, data_format_, 'C') == 1),
  errors::InvalidArgument(
  "Current implementation does not yet support "
  "dilations rates in the batch and depth dimensions."));
  OP_REQUIRES(
  - context,
  - (GetTensorDim(dilations_, data_format_, '0') > 0 &&
  + context, (GetTensorDim(dilations_, data_format_, '0') > 0 &&
  GetTensorDim(dilations_, data_format_, '1') > 0 &&
  GetTensorDim(dilations_, data_format_, '2') > 0),
  errors::InvalidArgument("Dilated rates should be larger than 0."));
  @@ -792,7 +790,9 @@ class MklConvOp : public OpKernel {
  // Tensorflow format to MKL format by caching the filter when it is
  // converted for the first time. This cached filter can then be reused
  // in subsequent iterations.
  - if (is_filter_const_) {
  + bool do_cache_filter =
  + src_dims[MklDnnDims::Dim_N] > kSmallBatchSize ? true : false;
  + if (is_filter_const_ && do_cache_filter) {
  if (IsFilterCacheEmpty(context)) {
  // Cache filter if it is not already cached.
  CacheFilter(context, conv_fwd_pd, filter_data, filter_tensor,
  @@ -805,6 +805,13 @@ class MklConvOp : public OpKernel {
  filter_data = GetCachedFilter(
  context, GET_WEIGHTS_FORMAT_FROM_OP_PD(conv_fwd_pd, conv_fwd));
  is_filter_cached = (filter_data != nullptr);
  + if (filter_out_tensor != nullptr) {
  + Tfilter* filter_out_tensor_buf =
  + static_cast<Tfilter*>(const_cast<Tfilter*>(
  + filter_out_tensor->flat<Tfilter>().data()));
  + memcpy(filter_out_tensor_buf, filter_data,
  + filter_out_tensor->AllocatedBytes());
  + }
  }
  if (!is_filter_cached) {
  filter.SetUsrMem(filter_md, &filter_tensor);
  