diff options
author | 2017-08-10 15:11:10 -0700 | |
---|---|---|
committer | 2017-08-10 15:15:04 -0700 | |
commit | 2173b5b0a58a3c28fe11494157e38004fe549d6b (patch) | |
tree | 0a2a527b3648dbf46188432ffeb4eb693e8269af /tensorflow/c/eager/c_api_test.cc | |
parent | 13eb3b90e9ed8778ffd2b1bf6401677938b1ec39 (diff) |
Allow TFE_TensorHandleCopyToDevice to have the same device as src and
destination. It will reuse the same underlying buffer in those cases.
PiperOrigin-RevId: 164909906
Diffstat (limited to 'tensorflow/c/eager/c_api_test.cc')
-rw-r--r-- | tensorflow/c/eager/c_api_test.cc | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tensorflow/c/eager/c_api_test.cc b/tensorflow/c/eager/c_api_test.cc index 797506422b..6614df78d9 100644 --- a/tensorflow/c/eager/c_api_test.cc +++ b/tensorflow/c/eager/c_api_test.cc @@ -170,14 +170,22 @@ TEST(CAPI, TensorHandleCopyBetweenDevices) { ADD_FAILURE() << tag << " -- " << TF_Message(status.get()); continue; } + // Copy from device to the same device. + TFE_TensorHandle* hdevice2 = + TFE_TensorHandleCopyToDevice(hdevice, ctx, name.c_str(), status.get()); + if (TF_GetCode(status.get()) != TF_OK) { + ADD_FAILURE() << tag << " -- " << TF_Message(status.get()); + continue; + } + TFE_DeleteTensorHandle(hdevice); // Copy back to CPU TFE_TensorHandle* hcopy = - TFE_TensorHandleCopyToDevice(hdevice, ctx, kCPUDevice, status.get()); + TFE_TensorHandleCopyToDevice(hdevice2, ctx, kCPUDevice, status.get()); if (TF_GetCode(status.get()) != TF_OK) { ADD_FAILURE() << tag << " -- " << TF_Message(status.get()); continue; } - TFE_DeleteTensorHandle(hdevice); + TFE_DeleteTensorHandle(hdevice2); // Ensure that the contents are the same! TF_Tensor* tcopy = TFE_TensorHandleResolve(hcopy, status.get()); |