| 64 | } |
| 65 | |
| 66 | Status TensorStore::SaveTensors(const std::vector<string>& output_names, |
| 67 | SessionState* session_state) { |
| 68 | mutex_lock l(lock_); |
| 69 | if (!tensors_.empty()) { |
| 70 | // Save only the tensors in output_names in the session. |
| 71 | for (const string& name : output_names) { |
| 72 | TensorId id(ParseTensorName(name)); |
| 73 | const string op_name(id.first); |
| 74 | auto it = tensors_.find(op_name); |
| 75 | if (it != tensors_.end()) { |
| 76 | // Save the tensor to the session state. |
| 77 | string key = it->second.GetHandle(op_name); |
| 78 | TF_RETURN_IF_ERROR(session_state->AddTensor(key, it->second.tensor)); |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | return Status::OK(); |
| 83 | } |
| 84 | |
| 85 | } // namespace tensorflow |