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

Class PersistentTensor

tensorflow/core/framework/op_kernel.h:267–287  ·  view source on GitHub ↗

Wraps a tensor that is held by an Op across calls to Compute(). For memory safety when using asynchronous devices like GPUs, the system must be notified when a Tensor is used inside an Op execution. The wrapper ensures that all uses of the Tensor are tracked, because in order to retrieve the Tensor the caller must use AccessTensor which notifies the context.

Source from the content-addressed store, hash-verified

265// order to retrieve the Tensor the caller must use AccessTensor which
266// notifies the context.
267class PersistentTensor {
268 public:
269 PersistentTensor() {}
270 explicit PersistentTensor(const Tensor& tensor) : tensor_(tensor) {}
271
272 // Caller does not own the returned Tensor*.
273 Tensor* AccessTensor(OpKernelConstruction* context);
274 // Caller does not own the returned Tensor*.
275 Tensor* AccessTensor(OpKernelContext* context);
276
277 // The check for initialization does not need to access the
278 // underlying tensor buffer.
279 bool IsInitialized() const { return tensor_.IsInitialized(); }
280
281 int64 NumElements() const { return tensor_.NumElements(); }
282
283 int64 AllocatedBytes() const { return tensor_.AllocatedBytes(); }
284
285 private:
286 Tensor tensor_;
287};
288
289class OpKernelConstruction {
290 public:

Callers 9

CompileMethod · 0.85
allocate_persistentMethod · 0.85
LockedReadMethod · 0.85
TryEnqueueMethod · 0.85
TryEnqueueMethod · 0.85
MutableDenseHashTableMethod · 0.85
LOCKS_EXCLUDEDMethod · 0.85
TryEnqueueMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected