Skip to content

Commit

Permalink
tools: plugin: modules: Pass device_name with environment variable
Browse files Browse the repository at this point in the history
Add environment variable to compile model for different target device
without rebuild.

Signed-off-by: Yong Zhi <yong.zhi@intel.com>
  • Loading branch information
yongzhi1 committed May 13, 2024
1 parent 529a4c6 commit ca2cefe
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ extern "C" {
ov::Core core;
size_t state_size = 0;
const char* model_name = std::getenv("NOISE_SUPPRESSION_MODEL_NAME");
const char* device_name = std::getenv("NOISE_SUPPRESSION_DEVICE_NAME");
int i;

nd = new ns_data();
Expand All @@ -39,6 +40,13 @@ extern "C" {
inputs = nd->model->inputs();
outputs = nd->model->outputs();

/*
* Specify the target device to infer on, for example: CPU, GPU or NPU, the default
* OpenVINO device will be selected by AUTO plugin when not specified.
*/
if (!device_name)
device_name = "CPU";

/* get state name pairs */
for (size_t i = 0; i < inputs.size(); i++) {
std::string inp_state_name = inputs[i].get_any_name();
Expand Down Expand Up @@ -67,10 +75,10 @@ extern "C" {
return -EINVAL;

/*
* compile the model for the CPU and save the infer_request objects for each
* compile the model for the target device and save the infer_request objects for each
* channel separately
*/
ov::CompiledModel compiled_model = core.compile_model(nd->model, "CPU", {});
ov::CompiledModel compiled_model = core.compile_model(nd->model, device_name, {});
for (i = 0; i < NS_MAX_SOURCE_CHANNELS; i++)
nd->infer_request[i] = compiled_model.create_infer_request();

Expand Down

0 comments on commit ca2cefe

Please sign in to comment.