From c93092967eea607072d36aa33f88e5ed02d342ae Mon Sep 17 00:00:00 2001 From: Yong Zhi Date: Tue, 25 Jun 2024 11:58:21 -0500 Subject: [PATCH] plugin: noise_suppression_interface: chromeos support Update plugins.xml path to /etc/openvino/plugins.xml Signed-off-by: Yong Zhi --- .../noise_suppression_interface.cpp | 45 ++++++++++++------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/tools/plugin/modules/ov_noise_suppression/noise_suppression_interface.cpp b/tools/plugin/modules/ov_noise_suppression/noise_suppression_interface.cpp index fa74736d062f..3738f48bf2d4 100644 --- a/tools/plugin/modules/ov_noise_suppression/noise_suppression_interface.cpp +++ b/tools/plugin/modules/ov_noise_suppression/noise_suppression_interface.cpp @@ -4,7 +4,7 @@ // // Author: Ranjani Sridharan - +#define _GLIBCXX_USE_CXX11_ABI 0 #include #include #include @@ -13,6 +13,15 @@ #include "noise_suppression_interface.h" #define NS_MAX_SOURCE_CHANNELS 2 +void printVector(const std::vector& vec) { + std::cout << "Print any plugin" << std::endl; + for (const auto& str : vec) { + std::cout << str << " "; + } + std::cout << std::endl; + std::cout << "Print any plugin done" << std::endl; +} + extern "C" { struct ns_data { std::shared_ptr model; @@ -25,12 +34,31 @@ extern "C" { int ov_ns_init(ns_handle *handle) { struct ns_data *nd; ov::OutputVector inputs, outputs; - ov::Core core; + ov::Core core("/etc/openvino/plugins.xml"); size_t state_size = 0; const char* model_name = std::getenv("NOISE_SUPPRESSION_MODEL_NAME"); std::string device("CPU"); int i; + /* + * query the list of available devices and use NPU if available, otherwise use + * CPU by default + */ + std::vector available_devices = core.get_available_devices(); + printVector(available_devices); + + if (available_devices.empty()) { + std::cout << "Not able to find any plugin" << std::endl; + return -EINVAL; + } + + for (auto &s: available_devices) { + if (!s.compare("NPU")) { + device.assign("NPU"); + break; + } + } + nd = new ns_data(); if(!nd) return -ENOMEM; @@ -67,18 +95,6 @@ extern "C" { if (!state_size) return -EINVAL; - /* - * query the list of available devices and use NPU if available, otherwise use - * CPU by default - */ - std::vector available_devices = core.get_available_devices(); - for (auto &s: available_devices) { - if (!s.compare("NPU")) { - device.assign("NPU"); - break; - } - } - /* save the infer_request objects for each channel separately */ ov::CompiledModel compiled_model = core.compile_model(nd->model, device, {}); for (i = 0; i < NS_MAX_SOURCE_CHANNELS; i++) @@ -171,7 +187,6 @@ extern "C" { if (out >= sink->end_addr) out = (char *)sink->addr + ((char *)out - (char *)sink->end_addr); - v = std::clamp(v, -1.0f, +1.0f); *(int16_t *)out = (int16_t)(v * std::numeric_limits::max()); }