framework/pytorch/op_profile.cc
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "framework/pytorch/op_profile.h" | ||
| 2 | |||
| 3 | #include <torch/extension.h> | ||
| 4 | |||
| 5 | #include "framework/pytorch/op_internal.h" | ||
| 6 | |||
| 7 | namespace recstore { | ||
| 8 | namespace framework { | ||
| 9 | namespace { | ||
| 10 | |||
| 11 | ✗ | std::vector<double> get_last_local_lookup_flat_profile_torch() { | |
| 12 | ✗ | return g_last_local_lookup_flat_profile; | |
| 13 | } | ||
| 14 | |||
| 15 | ✗ | std::vector<double> get_last_local_update_flat_profile_torch() { | |
| 16 | ✗ | return g_last_local_update_flat_profile; | |
| 17 | } | ||
| 18 | |||
| 19 | ✗ | std::vector<double> get_last_gpu_cache_profile_torch() { | |
| 20 | #ifdef RECSTORE_ENABLE_GPU_CACHE | ||
| 21 | const auto profile = gpu::GetLastGpuCacheProfile(); | ||
| 22 | return { | ||
| 23 | profile.query_ms, | ||
| 24 | profile.backend_lookup_ms, | ||
| 25 | profile.fill_ms, | ||
| 26 | profile.update_ms, | ||
| 27 | profile.hit_count, | ||
| 28 | profile.invalidate_ms, | ||
| 29 | profile.request_count, | ||
| 30 | profile.miss_count, | ||
| 31 | }; | ||
| 32 | #else | ||
| 33 | ✗ | return {}; | |
| 34 | #endif | ||
| 35 | } | ||
| 36 | |||
| 37 | } // namespace | ||
| 38 | |||
| 39 | 16 | void RegisterProfileOps(torch::Library& m) { | |
| 40 | 16 | m.def("get_last_local_lookup_flat_profile", | |
| 41 | get_last_local_lookup_flat_profile_torch); | ||
| 42 | 16 | m.def("get_last_local_update_flat_profile", | |
| 43 | get_last_local_update_flat_profile_torch); | ||
| 44 | 16 | m.def("get_last_gpu_cache_profile", get_last_gpu_cache_profile_torch); | |
| 45 | 16 | } | |
| 46 | |||
| 47 | } // namespace framework | ||
| 48 | } // namespace recstore | ||
| 49 |