From c9f63ad1f3423dea735fbe52268b5493325504f8 Mon Sep 17 00:00:00 2001 From: Sachin Kumawat Date: Tue, 23 Jun 2026 15:46:37 -0700 Subject: [PATCH] Let flexmlrt detect device type --- src/vitisai/whisper-vitisai-encoder.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/vitisai/whisper-vitisai-encoder.cpp b/src/vitisai/whisper-vitisai-encoder.cpp index 580bcfe36..ef151dff5 100644 --- a/src/vitisai/whisper-vitisai-encoder.cpp +++ b/src/vitisai/whisper-vitisai-encoder.cpp @@ -102,6 +102,8 @@ struct whisper_vitisai_context * whisper_vitisai_init(const char * path_model) { auto * ctx = new whisper_vitisai_context; ctx->model_path = path_model; + ctx->fbs_buffer = nullptr; + ctx->fbs_buffer_size = 0; // Override the model path with the environment variable if it is set if (const char * env_model_path = std::getenv("OVERRIDE_VITISAI_MODEL_PATH")) { @@ -113,7 +115,6 @@ struct whisper_vitisai_context * whisper_vitisai_init(const char * path_model) { // Step 1: Set up the model flexmlrt::client::Options options; options.modelPath = ctx->model_path; - options.deviceName = "stx"; options.debug = false; options.executeMode = 2; options.extOptions["enable_preemption"] = true; @@ -121,18 +122,20 @@ struct whisper_vitisai_context * whisper_vitisai_init(const char * path_model) { // Check if model_path is rai file and if so, add fbs_buffer and fbs_buffer_size to the options if (ctx->model_path.find(".rai") != std::string::npos) { // mmap rai file for both Linux and Windows and pass the buffer to the options - ctx->fbs_buffer = nullptr; - ctx->fbs_buffer_size = 0; if (map_rai_file(ctx->model_path.c_str(), &ctx->fbs_buffer, &ctx->fbs_buffer_size)) { options.extOptions["fbs_buffer"] = ctx->fbs_buffer; options.extOptions["fbs_buffer_size"] = ctx->fbs_buffer_size; - options.subgraphName = "vaiml_par_0"; options.extOptions["cache_dir"] = std::string("."); } else { std::fprintf(stderr, "%s: Failed to mmap rai file '%s'\n", __func__, ctx->model_path.c_str()); delete ctx; return nullptr; } + } else { + options.deviceName = "stx"; +#if defined(WHISPER_DEBUG) + std::fprintf(stderr, "%s: Using default device name 'stx'\n", __func__); +#endif } try {