Function `_copy_to_device`.
| 658 | |
| 659 | // Function `_copy_to_device`. |
| 660 | static PyObject* EagerTensor_copy_to_device(EagerTensor* self, PyObject* args, |
| 661 | PyObject* kwds) { |
| 662 | if (!_PyArg_NoKeywords("copy_to_device", kwds)) return nullptr; |
| 663 | |
| 664 | const char* device_name = nullptr; |
| 665 | if (!PyArg_ParseTuple(args, "O&:copy_to_device", ConvertDeviceName, |
| 666 | &device_name)) { |
| 667 | return nullptr; |
| 668 | } |
| 669 | |
| 670 | // Note that this is a shallow copy and will share the underlying buffer |
| 671 | // if copying to the same device. |
| 672 | TFE_TensorHandle* handle = TFE_TensorHandleCopyToDevice( |
| 673 | self->handle, GetContextHandle(self->context), device_name, self->status); |
| 674 | if (MaybeRaiseExceptionFromTFStatus(self->status, PyExc_RuntimeError)) { |
| 675 | // Cleanup self->status before returning. |
| 676 | TF_SetStatus(self->status, TF_OK, ""); |
| 677 | return nullptr; |
| 678 | } |
| 679 | |
| 680 | return EagerTensorFromHandle(handle); |
| 681 | } |
| 682 | |
| 683 | // Function `_numpy`. |
| 684 | // Convert an EagerTensor to a Python numpy.ndarray object. |
nothing calls this directly
no test coverage detected