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

Method Compute

tensorflow/core/kernels/summary_op.cc:39–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37 explicit SummaryScalarOp(OpKernelConstruction* context) : OpKernel(context) {}
38
39 void Compute(OpKernelContext* c) override {
40 const Tensor& tags = c->input(0);
41 const Tensor& values = c->input(1);
42
43 OP_REQUIRES(
44 c,
45 tags.IsSameSize(values) ||
46 (IsLegacyScalar(tags.shape()) && IsLegacyScalar(values.shape())),
47 errors::InvalidArgument(
48 "tags and values not the same shape: ", tags.shape().DebugString(),
49 " != ", values.shape().DebugString(), SingleTag(tags)));
50 auto Ttags = tags.flat<tstring>();
51 auto Tvalues = values.flat<T>();
52 Summary s;
53 for (int i = 0; i < Ttags.size(); i++) {
54 Summary::Value* v = s.add_value();
55 v->set_tag(string(Ttags(i))); // NOLINT
56 v->set_simple_value(float(Tvalues(i)));
57 }
58
59 Tensor* summary_tensor = nullptr;
60 OP_REQUIRES_OK(c, c->allocate_output(0, TensorShape({}), &summary_tensor));
61 CHECK(SerializeToTString(s, &summary_tensor->scalar<tstring>()()));
62 }
63
64 // If there's only one tag, include it in the error message
65 static string SingleTag(const Tensor& tags) {

Callers

nothing calls this directly

Calls 10

InvalidArgumentFunction · 0.85
SerializeToTStringFunction · 0.85
set_tagMethod · 0.80
allocate_outputMethod · 0.80
TensorShapeClass · 0.50
inputMethod · 0.45
IsSameSizeMethod · 0.45
shapeMethod · 0.45
DebugStringMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected