This buffer is an alias to buf[delta, delta + n).
| 875 | public: |
| 876 | // This buffer is an alias to buf[delta, delta + n). |
| 877 | SubBuffer(TensorBuffer* buf, int64 delta, int64 n) |
| 878 | : TensorBuffer(buf->base<T>() + delta), |
| 879 | root_(buf->root_buffer()), |
| 880 | elem_(n) { |
| 881 | // Sanity check. The caller should ensure the sub buffer is valid. |
| 882 | CHECK_LE(root_->base<T>(), this->base<T>()); |
| 883 | T* root_limit = root_->base<T>() + root_->size() / sizeof(T); |
| 884 | CHECK_LE(this->base<T>(), root_limit); |
| 885 | CHECK_LE(this->base<T>() + n, root_limit); |
| 886 | // Hold a ref of the underlying root buffer. |
| 887 | // NOTE: 'buf' is a sub-buffer inside the 'root_' buffer. |
| 888 | root_->Ref(); |
| 889 | } |
| 890 | |
| 891 | size_t size() const override { return sizeof(T) * elem_; } |
| 892 | TensorBuffer* root_buffer() override { return root_; } |
nothing calls this directly
no test coverage detected