| 61 | } |
| 62 | |
| 63 | Session* NewSession(const SessionOptions& options) { |
| 64 | SessionFactory* factory; |
| 65 | Status s = SessionFactory::GetFactory(options, &factory); |
| 66 | if (!s.ok()) { |
| 67 | LOG(ERROR) << s; |
| 68 | return nullptr; |
| 69 | } |
| 70 | // Starts exporting metrics through a platform-specific monitoring API (if |
| 71 | // provided). For builds using "tensorflow/core/platform/default", this is |
| 72 | // currently a no-op. |
| 73 | session_created->GetCell()->Set(true); |
| 74 | monitoring::StartExporter(); |
| 75 | Session* out_session; |
| 76 | s = NewSession(options, &out_session); |
| 77 | if (!s.ok()) { |
| 78 | LOG(ERROR) << "Failed to create session: " << s; |
| 79 | return nullptr; |
| 80 | } |
| 81 | return out_session; |
| 82 | } |
| 83 | |
| 84 | Status NewSession(const SessionOptions& options, Session** out_session) { |
| 85 | SessionFactory* factory; |