MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / EagerTensor_copy_to_device

Function EagerTensor_copy_to_device

tensorflow/python/eager/pywrap_tensor.cc:660–681  ·  view source on GitHub ↗

Function `_copy_to_device`.

Source from the content-addressed store, hash-verified

658
659// Function `_copy_to_device`.
660static 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.

Callers

nothing calls this directly

Calls 5

GetContextHandleFunction · 0.85
TF_SetStatusFunction · 0.85
EagerTensorFromHandleFunction · 0.85

Tested by

no test coverage detected