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

Method EncodeToProto

tensorflow/core/lib/histogram/histogram.cc:201–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199}
200
201void Histogram::EncodeToProto(HistogramProto* proto,
202 bool preserve_zero_buckets) const {
203 proto->Clear();
204 proto->set_min(min_);
205 proto->set_max(max_);
206 proto->set_num(num_);
207 proto->set_sum(sum_);
208 proto->set_sum_squares(sum_squares_);
209 for (size_t i = 0; i < buckets_.size();) {
210 double end = bucket_limits_[i];
211 double count = buckets_[i];
212 i++;
213 if (!preserve_zero_buckets && count <= 0.0) {
214 // Find run of empty buckets and collapse them into one
215 while (i < buckets_.size() && buckets_[i] <= 0.0) {
216 end = bucket_limits_[i];
217 count = buckets_[i];
218 i++;
219 }
220 }
221 proto->add_bucket_limit(end);
222 proto->add_bucket(count);
223 }
224 if (proto->bucket_size() == 0.0) {
225 // It's easier when we restore if we always have at least one bucket entry
226 proto->add_bucket_limit(DBL_MAX);
227 proto->add_bucket(0.0);
228 }
229}
230
231// ThreadSafeHistogram implementation.
232bool ThreadSafeHistogram::DecodeFromProto(const HistogramProto& proto) {

Callers 4

ValidateFunction · 0.45
TESTFunction · 0.45
valueMethod · 0.45

Calls 3

bucket_sizeMethod · 0.80
ClearMethod · 0.45
sizeMethod · 0.45

Tested by 2

ValidateFunction · 0.36
TESTFunction · 0.36