Avoid crash in C API and log error.
PiperOrigin-RevId: 314592831 Change-Id: I182a27286b9f31a9c53cf80d4ccfa83849faa205
This commit is contained in:
parent
e19e2d29d5
commit
f672ee2564
tensorflow
@ -589,14 +589,16 @@ void TF_DeleteDeviceList(TF_DeviceList* list) { delete list; }
|
||||
|
||||
TF_DeviceList* TF_SessionListDevices(TF_Session* session, TF_Status* status) {
|
||||
TF_DeviceList* response = new TF_DeviceList;
|
||||
status->status = session->session->ListDevices(&response->response);
|
||||
if (session && session->session)
|
||||
status->status = session->session->ListDevices(&response->response);
|
||||
return response;
|
||||
}
|
||||
|
||||
TF_DeviceList* TF_DeprecatedSessionListDevices(TF_DeprecatedSession* session,
|
||||
TF_Status* status) {
|
||||
TF_DeviceList* response = new TF_DeviceList;
|
||||
status->status = session->session->ListDevices(&response->response);
|
||||
if (session && session->session)
|
||||
status->status = session->session->ListDevices(&response->response);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ -2178,6 +2180,7 @@ TF_Session* TF_NewSession(TF_Graph* graph, const TF_SessionOptions* opt,
|
||||
}
|
||||
return new_session;
|
||||
} else {
|
||||
LOG(ERROR) << status->status;
|
||||
DCHECK_EQ(nullptr, session);
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ Status NewSession(const SessionOptions& options, Session** out_session) {
|
||||
Status s = SessionFactory::GetFactory(options, &factory);
|
||||
if (!s.ok()) {
|
||||
*out_session = nullptr;
|
||||
LOG(ERROR) << s;
|
||||
LOG(ERROR) << "Failed to get session factory: " << s;
|
||||
return s;
|
||||
}
|
||||
// Starts exporting metrics through a platform-specific monitoring API (if
|
||||
@ -88,6 +88,7 @@ Status NewSession(const SessionOptions& options, Session** out_session) {
|
||||
s = factory->NewSession(options, out_session);
|
||||
if (!s.ok()) {
|
||||
*out_session = nullptr;
|
||||
LOG(ERROR) << "Failed to create session: " << s;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user