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

Function BuildXlaOps

tensorflow/compiler/jit/build_xla_ops_pass_test.cc:57–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55using ::testing::_;
56
57Status BuildXlaOps(const Scope& s, const FunctionDefLibrary& fdef_lib,
58 std::unique_ptr<Graph>* result) {
59 auto graph = absl::make_unique<Graph>(OpRegistry::Global());
60 TF_RETURN_IF_ERROR(s.ToGraph(graph.get()));
61 FunctionLibraryDefinition flib_def(graph->op_registry(), fdef_lib);
62
63 // Assign all nodes to the CPU device.
64 static const char* kCpuDevice = "/job:localhost/replica:0/task:0/cpu:0";
65 for (Node* n : graph->nodes()) {
66 if (n->requested_device().empty()) {
67 n->set_assigned_device_name(kCpuDevice);
68 } else {
69 n->set_assigned_device_name(n->requested_device());
70 }
71 }
72
73 FixupSourceAndSinkEdges(graph.get());
74
75 SessionOptions session_options;
76 GraphOptimizationPassOptions opt_options;
77 opt_options.session_options = &session_options;
78 opt_options.flib_def = &flib_def;
79 opt_options.graph = &graph;
80 BuildXlaOpsPass pass(/*enable_lazy_compilation=*/true);
81 TF_RETURN_IF_ERROR(pass.Run(opt_options));
82 VLOG(3) << graph->ToGraphDefDebug().DebugString();
83 *result = std::move(graph);
84 return Status::OK();
85}
86
87Status MakeXlaCompiledKernel(Graph* graph, const string& callee_name,
88 const string& node_name, int num_constant_args,

Callers 1

TEST_FFunction · 0.85

Calls 10

FixupSourceAndSinkEdgesFunction · 0.85
ToGraphMethod · 0.80
ToGraphDefDebugMethod · 0.80
getMethod · 0.45
op_registryMethod · 0.45
nodesMethod · 0.45
emptyMethod · 0.45
RunMethod · 0.45
DebugStringMethod · 0.45

Tested by

no test coverage detected