EagerTensor.device reflects the op's device and not the tensor's memory space.
authorAlexandre Passos <apassos@google.com>
Thu, 1 Mar 2018 22:49:49 +0000 (14:49 -0800)
committerTensorFlower Gardener <gardener@tensorflow.org>
Thu, 1 Mar 2018 22:53:30 +0000 (14:53 -0800)
This matches graph mode's behavior.

PiperOrigin-RevId: 187537818

tensorflow/c/eager/c_api.cc

index 252ceab54aef6006326ef20525117b38406004fd..4b619dc4e162baaede56a0d96a95acba288bb22e 100644 (file)
@@ -180,12 +180,10 @@ int64_t TFE_TensorHandleDim(TFE_TensorHandle* h, int dim_index,
 }
 
 const char* TFE_TensorHandleDeviceName(TFE_TensorHandle* h, TF_Status* status) {
-  // 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.
   status->status = tensorflow::Status::OK();
-  return (h->d == nullptr) ? "/job:localhost/replica:0/task:0/device:CPU:0"
-                           : h->d->name().c_str();
+  return (h->op_device == nullptr)
+             ? "/job:localhost/replica:0/task:0/device:CPU:0"
+             : h->op_device->name().c_str();
 }
 
 TF_Tensor* TFE_TensorHandleResolve(TFE_TensorHandle* h, TF_Status* status) {