tf_1.8_xla_doc
|
Functions | |
Status | RewriteAndPruneGraph (Graph *graph, const tf2xla::Config &config, const std::unordered_map< string, string > &feed_remapping) |
Status | ConvertGraphToXla (std::unique_ptr< Graph > graph, xla::Client *client, xla::Computation *computation) |
Converts the TensorFlow graph into an XLA computation, by executing the graph symbolically, with each op building up the XLA HLO. More... | |
Status | InitGraph (const GraphDef &graph_def, const tf2xla::Config &config, std::unique_ptr< Graph > *graph) |
InitGraph creates a graph based on the graph_def, that may then be convert to an xla::Computation via ConvertGraphToXla. More... | |
Status tensorflow::anonymous_namespace{tf2xla.cc}::ConvertGraphToXla | ( | std::unique_ptr< Graph > | graph, |
xla::Client * | client, | ||
xla::Computation * | computation | ||
) |
Converts the TensorFlow graph into an XLA computation, by executing the graph symbolically, with each op building up the XLA HLO.
tensorflow::XlaOpRegistry::RegisterCompilationKernels()
_Arg
nodes (Ensure the index and type attrs of each nodes initialized correctly first)XlaCompiler
CompileGraph
, method of object XlaCompiler
Status tensorflow::anonymous_namespace{tf2xla.cc}::InitGraph | ( | const GraphDef & | graph_def, |
const tf2xla::Config & | config, | ||
std::unique_ptr< Graph > * | graph | ||
) |
InitGraph creates a graph based on the graph_def, that may then be convert to an xla::Computation via ConvertGraphToXla.
Google Doc:
The graph is rewritten with _Arg and _Retval nodes, representing the inputs and outputs of the function that will be compiled. Each feed id causes a new _Arg node to be created, where we first collect all existing edges pointing from the named node's output index, and then rewrite them to point from that _Arg node instead. Each fetch id causes a new _Retval node to be created, with a new edge pointing from the named node's output index to that _Retval node.
tensorflow::ValidateConfig()
tensorflow::AddPlaceholdersForFeeds()
tensorflow::PruneGraphDefInfo()
tensorflow::AddDefaultAttrsToGraphDef()
tensorflow::ConvertGraphDefToGraph()
tensorflow::RewriteAndPruneGraph()
Status tensorflow::anonymous_namespace{tf2xla.cc}::RewriteAndPruneGraph | ( | Graph * | graph, |
const tf2xla::Config & | config, | ||
const std::unordered_map< string, string > & | feed_remapping | ||
) |
_Arg
node and remove the original placeholder node by removing edge and add a new edge to _Arg
node._Retval
node and add it to the end._Retval
nodes and remove all unreachable nodes. Thus removing placeholders creating by tensorflow::AddPlaceholdersForFeeds()
Source
node by using control edge. And Sink
node to nodes without output edge.Google Docs:
RewriteAndPruneGraph identifies input and output edges (named by the feed and fetch ids respectively), and rewrites the edges so that inputs flow from _Arg nodes, and outputs flow to _Retval nodes. This allows the symbolic graph execution to know the input and output args for the generated function.