| 36 | TfAllocatorAdapter::~TfAllocatorAdapter() {} |
| 37 | |
| 38 | port::StatusOr<OwningDeviceMemory> TfAllocatorAdapter::Allocate( |
| 39 | int device_ordinal, uint64 size, bool retry_on_failure, |
| 40 | int64 memory_space) { |
| 41 | CHECK_EQ(memory_space, 0); |
| 42 | tensorflow::AllocationAttributes attrs; |
| 43 | attrs.no_retry_on_failure = !retry_on_failure; |
| 44 | void *data = nullptr; |
| 45 | if (size != 0) { |
| 46 | data = wrapped_->AllocateRaw(tensorflow::Allocator::kAllocatorAlignment, |
| 47 | size, attrs); |
| 48 | if (data == nullptr) { |
| 49 | return tensorflow::errors::ResourceExhausted( |
| 50 | "Out of memory while trying to allocate ", size, " bytes."); |
| 51 | } |
| 52 | } |
| 53 | return OwningDeviceMemory(DeviceMemoryBase(data, size), device_ordinal, this); |
| 54 | } |
| 55 | |
| 56 | port::Status TfAllocatorAdapter::Deallocate(int device_ordinal, |
| 57 | DeviceMemoryBase mem) { |
nothing calls this directly
no test coverage detected