Notice that buf_ either points to a regular TensorBuffer or a SubBuffer. For the latter case, we have to make sure that the refcount is one both for the SubBuffer _and_ the underlying TensorBuffer.
| 751 | // For the latter case, we have to make sure that the refcount is |
| 752 | // one both for the SubBuffer _and_ the underlying TensorBuffer. |
| 753 | bool Tensor::RefCountIsOne() const { |
| 754 | return buf_ != nullptr && buf_->RefCountIsOne() && |
| 755 | buf_->root_buffer()->RefCountIsOne() && buf_->OwnsMemory(); |
| 756 | } |
| 757 | |
| 758 | // The macro CASES() expands to a switch statement conditioned on |
| 759 | // TYPE_ENUM. Each case expands the STMTS after a typedef for T. |