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

Function HumanReadableNumOps

tensorflow/compiler/xla/util.cc:202–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

200
201namespace {
202string HumanReadableNumOps(double flops, double nanoseconds,
203 absl::string_view op_prefix) {
204 if (nanoseconds == 0) {
205 return absl::StrCat("NaN ", op_prefix, "OP/s");
206 }
207 double nano_flops = flops / nanoseconds;
208 string throughput = tensorflow::strings::HumanReadableNum(
209 static_cast<int64>(nano_flops * 1e9));
210 absl::string_view sp(throughput);
211 // Use the more common "G(FLOPS)", rather than "B(FLOPS)"
212 if (absl::EndsWith(sp, "B") || // Ends in 'B', ignoring case
213 absl::EndsWith(sp, "b")) {
214 *throughput.rbegin() = 'G';
215 }
216 throughput += absl::StrCat(op_prefix, "OP/s");
217 return throughput;
218}
219} // namespace
220
221string HumanReadableNumFlops(double flops, double nanoseconds) {

Callers 2

HumanReadableNumFlopsFunction · 0.85

Calls 4

HumanReadableNumFunction · 0.85
EndsWithFunction · 0.85
rbeginMethod · 0.80
StrCatFunction · 0.50

Tested by

no test coverage detected