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

Method Compute

tensorflow/core/kernels/summary_op.cc:81–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79 explicit SummaryHistoOp(OpKernelConstruction* context) : OpKernel(context) {}
80
81 void Compute(OpKernelContext* c) override {
82 const Tensor& tags = c->input(0);
83 const Tensor& values = c->input(1);
84 const auto flat = values.flat<T>();
85 OP_REQUIRES(c, IsLegacyScalar(tags.shape()),
86 errors::InvalidArgument("tags must be scalar"));
87 // Build histogram of values in "values" tensor
88 histogram::Histogram histo;
89 for (int64 i = 0; i < flat.size(); i++) {
90 const double double_val = static_cast<double>(flat(i));
91 if (Eigen::numext::isnan(double_val)) {
92 c->SetStatus(
93 errors::InvalidArgument("Nan in summary histogram for: ", name()));
94 break;
95 } else if (Eigen::numext::isinf(double_val)) {
96 c->SetStatus(errors::InvalidArgument(
97 "Infinity in summary histogram for: ", name()));
98 break;
99 }
100 histo.Add(double_val);
101 }
102
103 Summary s;
104 Summary::Value* v = s.add_value();
105 v->set_tag(string(tags.scalar<tstring>()())); // NOLINT
106 histo.EncodeToProto(v->mutable_histo(), false /* Drop zero buckets */);
107
108 Tensor* summary_tensor = nullptr;
109 OP_REQUIRES_OK(c, c->allocate_output(0, TensorShape({}), &summary_tensor));
110 CHECK(SerializeToTString(s, &summary_tensor->scalar<tstring>()()));
111 }
112};
113
114#define REGISTER(T) \

Callers

nothing calls this directly

Calls 14

InvalidArgumentFunction · 0.85
isnanClass · 0.85
nameFunction · 0.85
isinfClass · 0.85
SerializeToTStringFunction · 0.85
set_tagMethod · 0.80
allocate_outputMethod · 0.80
TensorShapeClass · 0.50
inputMethod · 0.45
shapeMethod · 0.45
sizeMethod · 0.45
SetStatusMethod · 0.45

Tested by

no test coverage detected