tensorflow/core/tpu/graph_rewrite/update_tpu_embedding_ops_passes.cc
// Update the graph for a specific enqueue op.
Update the graph for a specific enqueue op.
Update the graph for a specific enqueue op .
Status UpdateTPUEmbeddingModePass::UpdateGraphEnqueueOp(bool training,
                                                     Graph* graph,
                                                     Node* enqueue) {
  const Edge* select_edge;
  TF_RETURN_IF_ERROR(
      enqueue->input_edge(enqueue->num_inputs() - 1, &select_edge));
  if (select_edge->src()->type_string() == "SelectV2") {
    TF_RET_CHECK(select_edge->src()->num_inputs() == 3);
    Node* mode;
    TF_RETURN_IF_ERROR(select_edge->src()->input_node(training ? 1 : 2, &mode));
    graph->AddEdge(mode, 0, enqueue, enqueue->num_inputs() - 1);
    graph->RemoveEdge(select_edge);
  }
  return Status::OK();
}
Status UpdateTPUEmbeddingModePass :: UpdateGraphEnqueueOp ( bool training , Graph * graph , Node * enqueue ) { const Edge * select_edge ; TF_RETURN_IF_ERROR ( enqueue -> input_edge ( enqueue -> num_inputs ( ) - 1 , & select_edge ) ) ; if ( select_edge -> src ( ) -> type_string ( ) == " " ) { TF_RET_CHECK ( select_edge -> src ( ) -> num_inputs ( ) == 3 ) ; Node * mode ; TF_RETURN_IF_ERROR ( select_edge -> src ( ) -> input_node ( training ? 1 : 2 , & mode ) ) ; graph -> AddEdge ( mode , 0 , enqueue , enqueue -> num_inputs ( ) - 1 ) ; graph -> RemoveEdge ( select_edge ) ; } return Status :: OK ( ) ; }
Update the graph for a specific enqueue op.
Update the graph for a specific enqueue op .
// When using the layer, the mode override input is a SelectV2 op (unless this // pass has already run), which takes a training and eval op as input. We will // simply short circut the SelectV2 and take input from the correct op.