Download ml-stable-diffusion/mlx/benchmarks/cpp/time_utils.h from Fahad-S/FastVLM_SANA: direct link, hf CLI and curl.
- Browser
- Download file 1.24 kB
-
https://huggingface.co/Fahad-S/FastVLM_SANA/resolve/main/ml-stable-diffusion/mlx/benchmarks/cpp/time_utils.h
- Command line
-
hf download hf://Fahad-S/FastVLM_SANA/ml-stable-diffusion/mlx/benchmarks/cpp/time_utils.h
-
curl -L -o time_utils.h https://huggingface.co/Fahad-S/FastVLM_SANA/resolve/main/ml-stable-diffusion/mlx/benchmarks/cpp/time_utils.h
1.24 kB
| // Copyright © 2023 Apple Inc. | |
| template <typename F, typename... Args> | |
| double time_fn(F fn, Args&&... args) { | |
| // warmup | |
| for (int i = 0; i < 5; ++i) { | |
| eval(fn(std::forward<Args>(args)...)); | |
| } | |
| int num_iters = 100; | |
| auto start = time_now(); | |
| for (int i = 0; i < num_iters; i++) { | |
| eval(fn(std::forward<Args>(args)...)); | |
| } | |
| auto end = time_now(); | |
| return milliseconds(end - start) / static_cast<double>(num_iters); | |
| } | |