aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/common_runtime/device_factory.cc
diff options
context:
space:
mode:
authorGravatar Vijay Vasudevan <vrv@google.com>2016-08-08 14:06:20 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-08-08 15:17:22 -0700
commit2d0d126749d6d0cf82fb86691362c923a1bfbfe4 (patch)
tree9823261d38fe3439326da4fdbef5ffb2c5adbfc2 /tensorflow/core/common_runtime/device_factory.cc
parent0204fbd5fec268e2b4d4d4e9185e21725a6c248d (diff)
Change DeviceFactory functions that create devices to propagate
Statuses, so that failures to initialize devices don't crash the program. Changes swig for device_lib to be a lot simpler, thanks to mrry@ and keveman@'s help. Change allocation of eigen scratch memory to go through the allocator. Re-enable test for local devices now that python3 issue is fixed. Change: 129678132
Diffstat (limited to 'tensorflow/core/common_runtime/device_factory.cc')
-rw-r--r--tensorflow/core/common_runtime/device_factory.cc20
1 files changed, 12 insertions, 8 deletions
diff --git a/tensorflow/core/common_runtime/device_factory.cc b/tensorflow/core/common_runtime/device_factory.cc
index 7d0a2380cb..8104f44636 100644
--- a/tensorflow/core/common_runtime/device_factory.cc
+++ b/tensorflow/core/common_runtime/device_factory.cc
@@ -20,6 +20,7 @@ limitations under the License.
#include <unordered_map>
#include <vector>
+#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/mutex.h"
@@ -74,25 +75,26 @@ DeviceFactory* DeviceFactory::GetFactory(const string& device_type) {
return it->second.factory.get();
}
-void DeviceFactory::AddDevices(const SessionOptions& options,
- const string& name_prefix,
- std::vector<Device*>* devices) {
+Status DeviceFactory::AddDevices(const SessionOptions& options,
+ const string& name_prefix,
+ std::vector<Device*>* devices) {
// CPU first.
auto cpu_factory = GetFactory("CPU");
if (!cpu_factory) {
- LOG(FATAL)
- << "CPU Factory not registered. Did you link in threadpool_device?";
+ return errors::NotFound(
+ "CPU Factory not registered. Did you link in threadpool_device?");
}
size_t init_size = devices->size();
cpu_factory->CreateDevices(options, name_prefix, devices);
if (devices->size() == init_size) {
- LOG(FATAL) << "No CPU devices are available in this process";
+ return errors::NotFound("No CPU devices are available in this process");
}
// Then GPU.
auto gpu_factory = GetFactory("GPU");
if (gpu_factory) {
- gpu_factory->CreateDevices(options, name_prefix, devices);
+ TF_RETURN_IF_ERROR(
+ gpu_factory->CreateDevices(options, name_prefix, devices));
}
// Then the rest.
@@ -100,9 +102,11 @@ void DeviceFactory::AddDevices(const SessionOptions& options,
for (auto& p : device_factories()) {
auto factory = p.second.factory.get();
if (factory != cpu_factory && factory != gpu_factory) {
- factory->CreateDevices(options, name_prefix, devices);
+ TF_RETURN_IF_ERROR(factory->CreateDevices(options, name_prefix, devices));
}
}
+
+ return Status::OK();
}
Device* DeviceFactory::NewDevice(const string& type,