}
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) {