MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / FixMklMetaDataEdgeIfNeeded

Method FixMklMetaDataEdgeIfNeeded

tensorflow/core/graph/mkl_layout_pass.cc:4004–4029  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////// Post-rewrite OneDNN metadata fixup pass //////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

4002// Post-rewrite OneDNN metadata fixup pass
4003///////////////////////////////////////////////////////////////////////////////
4004bool MklLayoutRewritePass::FixMklMetaDataEdgeIfNeeded(std::unique_ptr<Graph>* g,
4005 const Edge* e_data,
4006 const Edge* e_metadata) {
4007 if (g == nullptr || e_data == nullptr || e_metadata == nullptr) {
4008 return false;
4009 }
4010
4011 Node* n_data = e_data->src();
4012 int n_data_op_slot = e_data->src_output();
4013 int n_metadata_op_slot =
4014 GetTensorMetaDataIndex(n_data_op_slot, n_data->num_outputs());
4015
4016 // If the source of meta edge is a constant node (producing dummy OneDNN metadata
4017 // tensor), then we will need to fix.
4018 if (IsConstant(e_metadata->src())) {
4019 Node* e_metadata_dst = e_metadata->dst();
4020 int e_metadata_in_slot = e_metadata->dst_input();
4021 auto new_edge = (*g)->AddEdge(n_data, n_metadata_op_slot, e_metadata_dst,
4022 e_metadata_in_slot);
4023 DCHECK(new_edge);
4024 (*g)->RemoveEdge(e_metadata);
4025 return true;
4026 }
4027
4028 return false;
4029}
4030
4031bool MklLayoutRewritePass::FixMklMetaDataEdges(std::unique_ptr<Graph>* g,
4032 Node* n) {

Callers

nothing calls this directly

Calls 9

GetTensorMetaDataIndexFunction · 0.85
IsConstantFunction · 0.70
srcMethod · 0.45
src_outputMethod · 0.45
num_outputsMethod · 0.45
dstMethod · 0.45
dst_inputMethod · 0.45
AddEdgeMethod · 0.45
RemoveEdgeMethod · 0.45

Tested by

no test coverage detected