MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / SubBuffer

Method SubBuffer

tensorflow/core/framework/tensor.cc:877–889  ·  view source on GitHub ↗

This buffer is an alias to buf[delta, delta + n).

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

root_bufferMethod · 0.45
sizeMethod · 0.45
RefMethod · 0.45

Tested by

no test coverage detected