| 39 | string XlaDeviceAllocator::Name() { return "xla"; } |
| 40 | |
| 41 | void* XlaDeviceAllocator::AllocateRaw(size_t alignment, size_t num_bytes) { |
| 42 | // We always return an empty XlaTensor object, encoded as an opaque tagged |
| 43 | // pointer. We can return an empty object and ignore num_bytes here because we |
| 44 | // have control over all of the uses of this device tensor, and can lazily |
| 45 | // allocate memory when used. This allows us to also know the shape of the |
| 46 | // allocated Tensor, which is useful if the device's tensor representation |
| 47 | // differs from the host. |
| 48 | return XlaTensor::ToOpaquePointer(new XlaTensor()); |
| 49 | } |
| 50 | |
| 51 | void XlaDeviceAllocator::DeallocateRaw(void* ptr) { |
| 52 | delete XlaTensor::FromOpaquePointer(ptr); |
no outgoing calls