Returns a list of C++ expressions that, when executed, will construct the BufferInfo instances in `buffer_infos`.
| 347 | // Returns a list of C++ expressions that, when executed, will construct the |
| 348 | // BufferInfo instances in `buffer_infos`. |
| 349 | std::vector<string> BufferInfosToCppExpression( |
| 350 | const std::vector<BufferInfo>& buffer_infos) { |
| 351 | std::vector<string> buffer_infos_as_strings; |
| 352 | std::transform(buffer_infos.begin(), buffer_infos.end(), |
| 353 | std::back_inserter(buffer_infos_as_strings), |
| 354 | [](const BufferInfo& buffer_info) { |
| 355 | std::pair<uint64, uint64> encoded = buffer_info.Encode(); |
| 356 | string encoded_second_as_str = |
| 357 | encoded.second == ~0ULL |
| 358 | ? "~0ULL" |
| 359 | : absl::StrCat(encoded.second, "ULL"); |
| 360 | return absl::StrCat( |
| 361 | "::xla::cpu_function_runtime::BufferInfo({", |
| 362 | encoded.first, "ULL, ", encoded_second_as_str, "})"); |
| 363 | }); |
| 364 | return buffer_infos_as_strings; |
| 365 | } |
| 366 | } // namespace |
| 367 | |
| 368 | Status GenerateHeader(const CodegenOpts& opts, const tf2xla::Config& config, |