| 229 | } |
| 230 | |
| 231 | int main(int32_t argc, char** argv) { |
| 232 | |
| 233 | // Required arguments |
| 234 | std::string models_base_path = ""; |
| 235 | std::string prompt = ""; |
| 236 | size_t cpu_threads = -1; |
| 237 | |
| 238 | // Optional arguments |
| 239 | std::string output_file = ""; |
| 240 | size_t seed = k_seed_default; |
| 241 | size_t num_steps = k_num_steps_default; |
| 242 | float audio_len_sec = static_cast<float>(k_audio_len_sec_default); |
| 243 | bool run_dummy_run = false; |
| 244 | |
| 245 | int32_t opt; |
| 246 | while ((opt = getopt(argc, argv, "m:p:t:s:n:o:l:d:h")) != -1) { |
| 247 | switch (opt) { |
| 248 | case 'm': models_base_path = optarg; break; |
| 249 | case 'p': prompt = optarg; break; |
| 250 | case 't': cpu_threads = std::stoull(optarg); break; |
| 251 | case 'o': output_file = optarg; break; |
| 252 | case 's': seed = std::stoull(optarg); break; |
| 253 | case 'n': num_steps = std::stoull(optarg); break; |
| 254 | case 'l': audio_len_sec = static_cast<float>(std::stoull(optarg)); break; |
| 255 | case 'd': run_dummy_run = (std::string(optarg) == "true"); break; |
| 256 | case 'h': |
| 257 | default: |
| 258 | print_usage(argv[0]); |
| 259 | return EXIT_FAILURE; |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | // Check the mandatory arguments |
| 264 | if (models_base_path.empty() || prompt.empty() || cpu_threads <= 0) { |
| 265 | fprintf(stderr, "ERROR: Missing required arguments.\n\n"); |
| 266 | print_usage(argv[0]); |
| 267 | return EXIT_FAILURE; |
| 268 | } |
| 269 | |
| 270 | std::string t5_model = models_base_path + "/conditioners_model.pte"; |
| 271 | std::string dit_model = models_base_path + "/dit_model.pte"; |
| 272 | std::string autoencoder_model = models_base_path + "/autoencoder_model.pte"; |
| 273 | std::string sentence_model_path = models_base_path + "/spiece.model"; |
| 274 | |
| 275 | #if defined(ET_USE_THREADPOOL) |
| 276 | uint32_t num_performant_cores = cpu_threads == -1 |
| 277 | ? ::executorch::extension::cpuinfo::get_num_performant_cores() |
| 278 | : static_cast<uint32_t>(cpu_threads); |
| 279 | ET_LOG( |
| 280 | Info, "Resetting threadpool with num threads = %d", num_performant_cores); |
| 281 | if (num_performant_cores > 0) { |
| 282 | ::executorch::extension::threadpool::get_threadpool() |
| 283 | ->_unsafe_reset_threadpool(num_performant_cores); |
| 284 | } |
| 285 | #else |
| 286 | uint32_t num_performant_cores = 4; |
| 287 | #endif |
| 288 | ET_LOG(Info, "Using %d threads", num_performant_cores); |
nothing calls this directly
no test coverage detected