Download utils.cpp from Agnuxo/Pure_Optical_CUDA: direct link, hf CLI and curl.
- Browser
- Download file 912 Bytes
-
https://huggingface.co/Agnuxo/Pure_Optical_CUDA/resolve/main/utils.cpp
- Command line
-
hf download hf://Agnuxo/Pure_Optical_CUDA/utils.cpp
-
curl -L -o utils.cpp https://huggingface.co/Agnuxo/Pure_Optical_CUDA/resolve/main/utils.cpp
912 Bytes
| void check_cuda(cudaError_t st, const char* msg) { | |
| if (st != cudaSuccess) { | |
| std::cerr << "[CUDA ERROR] " << msg << ": " << cudaGetErrorString(st) << "\n"; | |
| std::exit(1); | |
| } | |
| } | |
| void write_submission_csv(const std::string& path, | |
| const std::vector<std::string>& ids, | |
| const std::vector<float>& probabilities) { | |
| std::ofstream ofs(path); | |
| if (!ofs.is_open()) { | |
| throw std::runtime_error("Cannot open submission file: " + path); | |
| } | |
| ofs << "id,label\n"; | |
| ofs << std::fixed << std::setprecision(8); | |
| for (size_t i = 0; i < ids.size(); ++i) { | |
| ofs << ids[i] << "," << probabilities[i] << "\n"; | |
| } | |
| ofs.close(); | |
| std::cout << "[INFO] Submission saved to: " << path << " (" << ids.size() << " rows)\n"; | |
| } | |