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

Method Compute

tensorflow/core/kernels/variable_ops.cc:55–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55void VariableOp::Compute(OpKernelContext* ctx) {
56 mutex_lock l(init_mu_);
57 if (!initialized_) {
58 OP_REQUIRES_OK(ctx, cinfo_.Init(ctx->resource_manager(), def(),
59 true /* use name() */));
60 initialized_ = true;
61 }
62 auto creator = [this](LegacyVar** var) {
63 *var = new LegacyVar(dtype_);
64 (*var)->tensor()->set_shape(shape_);
65 return Status::OK();
66 };
67 LegacyVar* var;
68 OP_REQUIRES_OK(ctx, cinfo_.resource_manager()->LookupOrCreate<LegacyVar>(
69 cinfo_.container(), cinfo_.name(), &var, creator));
70 // Output a reference to our tensor, so it may be updated.
71 //
72 // As long as the resource manager hasn't been cleared the ref we return
73 // here is valid because it owns a ref on var.
74 ctx->set_output_ref(0, var->mu(), var->tensor());
75 if (ctx->track_allocations() && var->tensor()->IsInitialized()) {
76 ctx->record_persistent_memory_allocation(var->tensor()->AllocatedBytes());
77 }
78 var->Unref();
79}
80
81class TemporaryVariableOp : public OpKernel {
82 public:

Callers

nothing calls this directly

Calls 13

set_output_refMethod · 0.80
track_allocationsMethod · 0.80
nameMethod · 0.65
InitMethod · 0.45
resource_managerMethod · 0.45
set_shapeMethod · 0.45
tensorMethod · 0.45
containerMethod · 0.45
muMethod · 0.45
IsInitializedMethod · 0.45
AllocatedBytesMethod · 0.45

Tested by

no test coverage detected