Skip to content

Commit

Permalink
Merge pull request #52326 from penpornk/cherrypicks_YDERV
Browse files Browse the repository at this point in the history
r2.7 cherry-pick request: Fix oneDNN-related eager nightly test failures
  • Loading branch information
mihaimaruseac committed Oct 18, 2021
2 parents aeff194 + 3970a4c commit e51e5e7
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions tensorflow/core/common_runtime/eager/execute.cc
Expand Up @@ -726,6 +726,16 @@ Status PopulateRetMap(FunctionDef* fdef, const AbstractOpAttrs* op_attrs,
return Status::OK();
}

#ifdef INTEL_MKL
inline void GetMKLNodeDef(NodeDef* ndef) {
// All MKL eager ops have `_kernel` private attribute that needs to be set
// to a fixed label.
AttrValue attr_kernel;
attr_kernel.set_s(mkl_op_registry::kMklNameChangeOpLabel);
(*ndef->mutable_attr()).insert({"_kernel", attr_kernel});
}
#endif // INTEL_MKL

Status WrapInCallOp(EagerOperation* op, EagerOperation** wrapped_op) {
DCHECK(!op->is_function());
const OpDef& opdef = OpRegistry::Global()->LookUp(op->Name())->op_def;
Expand Down Expand Up @@ -775,11 +785,7 @@ Status WrapInCallOp(EagerOperation* op, EagerOperation** wrapped_op) {
#ifdef INTEL_MKL
if (IsMklEnabled() &&
absl::StartsWith(op->Name(), mkl_op_registry::kMklOpPrefix)) {
// All MKL eager ops have `_kernel` private attribute that needs to be set
// to a fixed label.
AttrValue attr_kernel;
attr_kernel.set_s(mkl_op_registry::kMklNameChangeOpLabel);
(*ndef->mutable_attr()).insert({"_kernel", attr_kernel});
GetMKLNodeDef(ndef);
}
#endif // INTEL_MKL

Expand Down Expand Up @@ -926,7 +932,14 @@ Status GetOrCreateKernelAndDevice(
// place the wrapped op on a GPU (if one is available) which leads to
// errors because placer pins the function output nodes to GPU thereby
// forcing a H2D copy of the dataset variant which is not supported.
const NodeDef& ndef = op->MutableAttrs()->BuildNodeDef();
auto ndef = op->MutableAttrs()->BuildNodeDef();
#ifdef INTEL_MKL
if (IsMKLEnabled() &&
absl::StartsWith(op->Name(), mkl_op_registry::kMklOpPrefix)) {
GetMKLNodeDef(&ndef);
}
#endif // INTEL_MKL

TF_RETURN_IF_ERROR(ctx.SelectDevice(preferred_device, ndef, &device));

VLOG(1) << "PreferredDevice " << op->Name() << ": " << preferred_device;
Expand Down

0 comments on commit e51e5e7

Please sign in to comment.