Download ml-stable-diffusion/mlx/benchmarks/cpp/compare_devices.cpp from Fahad-S/FastVLM_SANA: direct link, hf CLI and curl.
- Browser
- Download file 612 Bytes
-
https://huggingface.co/Fahad-S/FastVLM_SANA/resolve/main/ml-stable-diffusion/mlx/benchmarks/cpp/compare_devices.cpp
- Command line
-
hf download hf://Fahad-S/FastVLM_SANA/ml-stable-diffusion/mlx/benchmarks/cpp/compare_devices.cpp
-
curl -L -o compare_devices.cpp https://huggingface.co/Fahad-S/FastVLM_SANA/resolve/main/ml-stable-diffusion/mlx/benchmarks/cpp/compare_devices.cpp
612 Bytes
| // Copyright © 2023 Apple Inc. | |
| namespace mx = mlx::core; | |
| void time_add_op() { | |
| std::vector<int> sizes(1, 1); | |
| for (int i = 0; i < 9; ++i) { | |
| sizes.push_back(10 * sizes.back()); | |
| } | |
| set_default_device(mx::Device::cpu); | |
| for (auto size : sizes) { | |
| auto a = mx::random::uniform({size}); | |
| auto b = mx::random::uniform({size}); | |
| mx::eval(a, b); | |
| std::cout << "Size " << size << std::endl; | |
| TIMEM("cpu", mx::add, a, b, mx::Device::cpu); | |
| TIMEM("gpu", mx::add, a, b, mx::Device::gpu); | |
| } | |
| } | |
| int main() { | |
| time_add_op(); | |
| } | |