| 55 | using ::testing::_; |
| 56 | |
| 57 | Status 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 | |
| 87 | Status MakeXlaCompiledKernel(Graph* graph, const string& callee_name, |
| 88 | const string& node_name, int num_constant_args, |
no test coverage detected