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

Method Compute

tensorflow/core/kernels/count_up_to_op.cc:68–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66 }
67
68 void Compute(OpKernelContext* context) override {
69 core::RefCountPtr<Var> variable;
70 OP_REQUIRES_OK(context, LookupResource(context, HandleFromInput(context, 0),
71 &variable));
72 mutex_lock l(*variable->mu());
73 Tensor before_increment = *variable->tensor();
74 OP_REQUIRES(
75 context, TensorShapeUtils::IsScalar(before_increment.shape()),
76 errors::InvalidArgument("input is not a scalar: ",
77 before_increment.shape().DebugString()));
78 if (before_increment.scalar<T>()() >= limit_) {
79 context->SetStatus(errors::OutOfRange("Reached limit of ", limit_));
80 return;
81 }
82 // Allocate new buffer
83 AllocatorAttributes attr;
84 attr.set_gpu_compatible(true);
85 attr.set_nic_compatible(true);
86 PersistentTensor unused;
87 Tensor* tmp;
88 OP_REQUIRES_OK(context, context->allocate_persistent(
89 dtype_, TensorShape({}), &unused, &tmp, attr));
90 *variable->tensor() = *tmp;
91 tmp->scalar<T>()() = before_increment.scalar<T>()() + 1;
92 context->set_output(0, before_increment);
93 }
94
95 private:
96 T limit_;

Callers

nothing calls this directly

Calls 14

LookupResourceFunction · 0.85
HandleFromInputFunction · 0.85
InvalidArgumentFunction · 0.85
set_gpu_compatibleMethod · 0.80
set_nic_compatibleMethod · 0.80
IsScalarFunction · 0.50
TensorShapeClass · 0.50
muMethod · 0.45
tensorMethod · 0.45
shapeMethod · 0.45
DebugStringMethod · 0.45
SetStatusMethod · 0.45

Tested by

no test coverage detected