| 343 | } |
| 344 | |
| 345 | GPUTensorPoolAllocator::Buffer::Buffer(size_t len, size_t chunk_size, |
| 346 | size_t alignment, void* begin) { |
| 347 | auto rounded_bytes = RoundedBytes(chunk_size, alignment); |
| 348 | auto buffer_size = rounded_bytes * len; |
| 349 | begin_ = begin; |
| 350 | if (begin != nullptr) { |
| 351 | end_ = static_cast<char*>(begin) + buffer_size; |
| 352 | } else { |
| 353 | end_ = nullptr; |
| 354 | } |
| 355 | |
| 356 | for (auto i = 0; i < len; ++i) { |
| 357 | buffer_.emplace(static_cast<char*>(begin) + rounded_bytes *i); |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | void* GPUTensorPoolAllocator::Buffer::Allocate() { |
| 362 | std::lock_guard<spin_lock> l(lock_); |
nothing calls this directly
no test coverage detected