OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[OV JS] Fix compileModel() return type (#31122)
Alicja Miloszewska133852e6e216
diff --git a/src/bindings/js/node/src/compiled_model.cpp b/src/bindings/js/node/src/compiled_model.cppindex bb99af718a8..15dcc635066 100644--- a/src/bindings/js/node/src/compiled_model.cpp+++ b/src/bindings/js/node/src/compiled_model.cpp@@ -28,7 +28,6 @@ Napi::Function CompiledModelWrap::get_class(Napi::Env env) {}Napi::Object CompiledModelWrap::wrap(Napi::Env env, ov::CompiledModel compiled_model) {- Napi::HandleScope scope(env);const auto& prototype = env.GetInstanceData<AddonData>()->compiled_model;if (!prototype) {OPENVINO_THROW("Invalid pointer to CompiledModel prototype.");diff --git a/src/bindings/js/node/src/core_wrap.cpp b/src/bindings/js/node/src/core_wrap.cppindex fbf69fe2c24..39d75e5da22 100644--- a/src/bindings/js/node/src/core_wrap.cpp+++ b/src/bindings/js/node/src/core_wrap.cpp@@ -196,12 +196,7 @@ void compileModelThreadModel(TsfnContextModel* context) {context->_compiled_model = core.compile_model(context->_model, context->_device, context->_config);auto callback = [](Napi::Env env, Napi::Function, TsfnContextModel* context) {- Napi::HandleScope scope(env);- auto obj = CompiledModelWrap::get_class(env).New({});- auto cm = Napi::ObjectWrap<CompiledModelWrap>::Unwrap(obj);- cm->set_compiled_model(context->_compiled_model);-- context->deferred.Resolve(obj);+ context->deferred.Resolve(CompiledModelWrap::wrap(env, context->_compiled_model));};context->tsfn.BlockingCall(context, callback);@@ -213,12 +208,7 @@ void compileModelThreadPath(TsfnContextPath* context) {context->_compiled_model = core.compile_model(context->_model, context->_device, context->_config);auto callback = [](Napi::Env env, Napi::Function, TsfnContextPath* context) {- Napi::HandleScope scope(env);- auto obj = CompiledModelWrap::get_class(env).New({});- auto cm = Napi::ObjectWrap<CompiledModelWrap>::Unwrap(obj);- cm->set_compiled_model(context->_compiled_model);-- context->deferred.Resolve(obj);+ context->deferred.Resolve(CompiledModelWrap::wrap(env, context->_compiled_model));};context->tsfn.BlockingCall(context, callback);diff --git a/src/bindings/js/node/tests/unit/basic.test.js b/src/bindings/js/node/tests/unit/basic.test.jsindex 96c90125e11..c6e80a6ffff 100644--- a/src/bindings/js/node/tests/unit/basic.test.js+++ b/src/bindings/js/node/tests/unit/basic.test.js@@ -200,14 +200,20 @@ describe('ov basic tests.', () => {});});- it.skip('compileModel() returns a Promise of CompiledModel', async () => {- // CVS-167943+ it('compileModel(model:Model) returns Promise<CompiledModel>', async () => {const promise = core.compileModel(model, 'CPU');assert.ok(promise instanceof Promise);const cm = await promise;assert.ok(cm instanceof ov.CompiledModel);});+ it('compileModel(model_path) returns Promise<CompiledModel>', async () => {+ const promise = core.compileModel(testModelFP32.xml, 'CPU');+ assert.ok(promise instanceof Promise);+ const cm = await promise;+ assert.ok(cm instanceof ov.CompiledModel);+ });+it('compileModel(model_path, deviceName, config: {}) ', () => {core.compileModel(testModelFP32.xml, 'CPU', tput).then((cm) => {assert.equal(cm.inputs.length, 1);