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:
Sanjoy Das 2018-07-19 15:39:25 -07:00 committed by TensorFlower Gardener
parent 97f89dcd6e
commit b7b86af242

View File

@ -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_; }