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

Function TF_TensorMaybeMove

tensorflow/c/tf_tensor.cc:151–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149}
150
151TF_Tensor* TF_TensorMaybeMove(TF_Tensor* tensor) {
152 // It is safe to move the Tensor if and only if we own the unique reference to
153 // it. In that case, we might as well not delete and reallocate, but a future
154 // implementation might need to do so.
155 TensorBuffer* buf = tensorflow::TensorCApi::Buffer(tensor->tensor);
156 if (buf->RefCountIsOne() && buf->root_buffer()->RefCountIsOne() &&
157 buf->OwnsMemory()) {
158 return tensor;
159 }
160 return nullptr;
161}
162
163void TF_DeleteTensor(TF_Tensor* t) { delete t; }
164

Callers 2

TF_TensorToPyArrayFunction · 0.85
TESTFunction · 0.85

Calls 4

BufferClass · 0.50
RefCountIsOneMethod · 0.45
root_bufferMethod · 0.45
OwnsMemoryMethod · 0.45

Tested by 1

TESTFunction · 0.68