| 297 | } |
| 298 | |
| 299 | Status SaveNodes() { |
| 300 | const char* sql = R"sql( |
| 301 | INSERT INTO Nodes ( |
| 302 | graph_id, |
| 303 | node_id, |
| 304 | node_name, |
| 305 | op, |
| 306 | device, |
| 307 | node_def) |
| 308 | VALUES (?, ?, ?, ?, ?, ?) |
| 309 | )sql"; |
| 310 | SqliteStatement insert; |
| 311 | TF_RETURN_IF_ERROR(db_->Prepare(sql, &insert)); |
| 312 | for (int node_id = 0; node_id < graph_->node_size(); ++node_id) { |
| 313 | NodeDef* node = graph_->mutable_node(node_id); |
| 314 | insert.BindInt(1, graph_id_); |
| 315 | insert.BindInt(2, node_id); |
| 316 | insert.BindText(3, node->name()); |
| 317 | insert.BindText(4, node->op()); |
| 318 | insert.BindText(5, node->device()); |
| 319 | node->clear_name(); |
| 320 | node->clear_op(); |
| 321 | node->clear_device(); |
| 322 | node->clear_input(); |
| 323 | string node_def; |
| 324 | if (node->SerializeToString(&node_def)) { |
| 325 | insert.BindBlobUnsafe(6, node_def); |
| 326 | } |
| 327 | unflushed_bytes_ += insert.size(); |
| 328 | TF_RETURN_WITH_CONTEXT_IF_ERROR(insert.StepAndReset(), node->name()); |
| 329 | TF_RETURN_IF_ERROR(MaybeFlush()); |
| 330 | } |
| 331 | return Status::OK(); |
| 332 | } |
| 333 | |
| 334 | Status SaveGraph(int64 run_id) { |
| 335 | const char* sql = R"sql( |
no test coverage detected