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

Class TensorValue

tensorflow/core/framework/op_kernel.h:538–569  ·  view source on GitHub ↗

Holds a tensor or tensor reference. For tensor references, we need a mutex to prevent concurrent access to the tensor.

Source from the content-addressed store, hash-verified

536// Holds a tensor or tensor reference. For tensor references, we need
537// a mutex to prevent concurrent access to the tensor.
538struct TensorValue {
539 TensorValue() : mutex_if_ref(nullptr), tensor(nullptr) {}
540 explicit TensorValue(Tensor* t) : mutex_if_ref(nullptr), tensor(t) {}
541 TensorValue(mutex* mu, Tensor* t) : mutex_if_ref(mu), tensor(t) {}
542 Tensor* operator->() const { return tensor; }
543 bool is_ref() const { return mutex_if_ref != nullptr; }
544
545 // Return the dtype of the Tensor. For references, return the underlying type.
546 DataType dtype() const {
547 if (is_ref()) {
548 return MakeRefType(tensor->dtype());
549 } else {
550 return tensor->dtype();
551 }
552 }
553
554 // Return the dtype of the Tensor. For references, return the underlying type.
555 // This variation on the dtype() acquires the lock for references.
556 //
557 // TODO(b/133843385): Disallow dtype modifications
558 DataType dtype_safe() const {
559 if (is_ref()) {
560 tf_shared_lock ml(*mutex_if_ref);
561 return MakeRefType(tensor->dtype());
562 } else {
563 return tensor->dtype();
564 }
565 }
566
567 mutex* mutex_if_ref; // nullptr if not a ref, != nullptr if a ref
568 Tensor* tensor;
569};
570
571// Used to store partitioned graphs from function-calling ops.
572struct GraphCollector {

Callers 15

release_outputMethod · 0.85
allocate_outputMethod · 0.85
set_outputMethod · 0.85
set_output_refMethod · 0.85
TEST_FFunction · 0.85
SimplifyPackMethod · 0.85
SimplifySwitchMethod · 0.85

Calls

no outgoing calls

Tested by 15

TEST_FFunction · 0.68
DoGatherMethod · 0.68
DoReduceMethod · 0.68
DoBroadcastMethod · 0.68
BM_KernelAndDeviceRunFunction · 0.68
PrepOpKernelMethod · 0.68
MakeFingerprintOpMethod · 0.68
RunReduceMethod · 0.68
TEST_PFunction · 0.68
TEST_FFunction · 0.68
TEST_PFunction · 0.68
TEST_FFunction · 0.68