|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#include "ggml-impl.h" |
| 4 | + |
| 5 | +// GGML internal header |
| 6 | + |
| 7 | +#ifdef __cplusplus |
| 8 | +extern "C" { |
| 9 | +#endif |
| 10 | + |
| 11 | +// op profile data (per op / per thread) |
| 12 | +enum ggml_profile_event { |
| 13 | + GGML_PROF_OP_START, |
| 14 | + GGML_PROF_OP_SYNC, |
| 15 | + GGML_PROF_OP_END |
| 16 | +}; |
| 17 | + |
| 18 | +struct ggml_profile_data { |
| 19 | + uint64_t nsec[GGML_PROF_OP_END + 1]; // event times in nsec |
| 20 | +}; |
| 21 | + |
| 22 | +#ifndef GGML_GRAPH_PROFILER |
| 23 | + |
| 24 | +// Stub out all profiler functions |
| 25 | + |
| 26 | +static inline void ggml_profile_graph_init(struct ggml_cgraph *cg, int n_threads) |
| 27 | +{ |
| 28 | + GGML_UNUSED(cg); |
| 29 | + GGML_UNUSED(n_threads); |
| 30 | +} |
| 31 | + |
| 32 | +static inline void ggml_profile_graph_start(struct ggml_cgraph *cg, int n_threads) |
| 33 | +{ |
| 34 | + GGML_UNUSED(cg); |
| 35 | + GGML_UNUSED(n_threads); |
| 36 | +} |
| 37 | + |
| 38 | +static inline void ggml_profile_graph_finish(struct ggml_cgraph *cg, int n_threads) |
| 39 | +{ |
| 40 | + GGML_UNUSED(cg); |
| 41 | + GGML_UNUSED(n_threads); |
| 42 | +} |
| 43 | + |
| 44 | +static inline void ggml_profile_graph_free(struct ggml_cgraph *cg) |
| 45 | +{ |
| 46 | + GGML_UNUSED(cg); |
| 47 | +} |
| 48 | + |
| 49 | +static inline void ggml_profile_op_event(const struct ggml_cgraph *cg, enum ggml_profile_event e, int node_n, int ith) |
| 50 | +{ |
| 51 | + GGML_UNUSED(cg); |
| 52 | + GGML_UNUSED(e); |
| 53 | + GGML_UNUSED(node_n); |
| 54 | + GGML_UNUSED(ith); |
| 55 | +} |
| 56 | + |
| 57 | +#else |
| 58 | + |
| 59 | +void ggml_profile_graph_init(struct ggml_cgraph *cg, int n_threads); |
| 60 | +void ggml_profile_graph_start(struct ggml_cgraph *cg, int n_threads); |
| 61 | +void ggml_profile_graph_finish(struct ggml_cgraph *cg, int n_threads); |
| 62 | +void ggml_profile_graph_free(struct ggml_cgraph *cg); |
| 63 | +void ggml_profile_op_event(const struct ggml_cgraph *cg, enum ggml_profile_event e, int node_n, int ith); |
| 64 | + |
| 65 | +#endif // GGML_GRAPH_PROFILER |
| 66 | + |
| 67 | +#ifdef __cplusplus |
| 68 | +} |
| 69 | +#endif |
0 commit comments