From: Alexandre Passos Date: Fri, 16 Feb 2018 23:30:46 +0000 (-0800) Subject: Default eager tensor device name should match default device name. X-Git-Tag: upstream/v1.7.0~31^2~594 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9739b75fe965ad497b37d209e6a33965010bdc61;p=platform%2Fupstream%2Ftensorflow.git Default eager tensor device name should match default device name. PiperOrigin-RevId: 186055679 --- diff --git a/tensorflow/c/eager/c_api.cc b/tensorflow/c/eager/c_api.cc index 8e834eb99c..98ef6f0d0a 100644 --- a/tensorflow/c/eager/c_api.cc +++ b/tensorflow/c/eager/c_api.cc @@ -161,10 +161,11 @@ int64_t TFE_TensorHandleDim(TFE_TensorHandle* h, int dim_index) { } const char* TFE_TensorHandleDeviceName(TFE_TensorHandle* h) { - // This might be a bit confusing as a tensor on CPU can sometimes return - // "CPU:0" and sometimes "/job:localhost/replica:0/task:0/cpu:0". - // TODO(ashankar): Figure out which one would be nicer. - return (h->d == nullptr) ? "CPU:0" : h->d->name().c_str(); + // TODO(apassos) this will be potentially incorrect in the distributed case as + // our local device will have a name which depends on the ClusterSpec and + // hence will require the context to resolve. + return (h->d == nullptr) ? "/job:localhost/replica:0/task:0/device:CPU:0" + : h->d->name().c_str(); } TF_Tensor* TFE_TensorHandleResolve(TFE_TensorHandle* h, TF_Status* status) {