| 200 | |
| 201 | namespace { |
| 202 | string 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 | |
| 221 | string HumanReadableNumFlops(double flops, double nanoseconds) { |
no test coverage detected