Teach XlaTensorBuffer to not deallocate null pointers
Zero sized XlaTensorBuffer can have null as the backing storage. De-allocating a null pointer produces an annoying warning from the BFCAllocator. PiperOrigin-RevId: 205314271
This commit is contained in:
parent
97f89dcd6e
commit
b7b86af242
@ -122,7 +122,11 @@ class XlaTensorBuffer : public TensorBuffer {
|
||||
data_ = const_cast<void*>(ptr);
|
||||
}
|
||||
|
||||
~XlaTensorBuffer() override { allocator_->DeallocateRaw(data_); }
|
||||
~XlaTensorBuffer() override {
|
||||
if (data_) {
|
||||
allocator_->DeallocateRaw(data_);
|
||||
}
|
||||
}
|
||||
|
||||
void* data() const override { return data_; }
|
||||
size_t size() const override { return expected_size_; }
|
||||
|
Loading…
Reference in New Issue
Block a user