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

Method Compute

tensorflow/core/kernels/count_up_to_op.cc:32–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30 }
31
32 void Compute(OpKernelContext* context) override {
33 T before_increment;
34 {
35 mutex_lock l(*context->input_ref_mutex(0));
36 Tensor tensor = context->mutable_input(0, true);
37 OP_REQUIRES(context, TensorShapeUtils::IsScalar(tensor.shape()),
38 errors::InvalidArgument("input is not a scalar: ",
39 tensor.shape().DebugString()));
40 T* ptr = &tensor.scalar<T>()();
41 before_increment = *ptr;
42 if (*ptr >= limit_) {
43 context->SetStatus(errors::OutOfRange("Reached limit of ", limit_));
44 return;
45 }
46 ++*ptr;
47 }
48 // Output if no error.
49 Tensor* out_tensor;
50 OP_REQUIRES_OK(context, context->allocate_output("output", TensorShape({}),
51 &out_tensor));
52 out_tensor->scalar<T>()() = before_increment;
53 }
54
55 private:
56 T limit_;

Callers

nothing calls this directly

Calls 9

InvalidArgumentFunction · 0.85
allocate_outputMethod · 0.80
input_ref_mutexMethod · 0.60
IsScalarFunction · 0.50
TensorShapeClass · 0.50
mutable_inputMethod · 0.45
shapeMethod · 0.45
DebugStringMethod · 0.45
SetStatusMethod · 0.45

Tested by

no test coverage detected