From 392352fae10794d58aa767541d5755f5a2962711 Mon Sep 17 00:00:00 2001 From: iarangou Date: Tue, 18 Nov 2025 22:09:54 -0500 Subject: [PATCH 1/2] JSAPPI: ASS SUPP FOR importModel(tensor) in CoreWrap --- src/bindings/js/node/src/core_wrap.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/bindings/js/node/src/core_wrap.cpp b/src/bindings/js/node/src/core_wrap.cpp index 39d75e5da2260d..28b580d434dc38 100644 --- a/src/bindings/js/node/src/core_wrap.cpp +++ b/src/bindings/js/node/src/core_wrap.cpp @@ -313,6 +313,21 @@ Napi::Value CoreWrap::get_versions(const Napi::CallbackInfo& info) { Napi::Value CoreWrap::import_model(const Napi::CallbackInfo& info) { try { + + if (info.Length() == 1 && + info[0].IsObject() && + info[0].As().InstanceOf(TensorWrap::get_class(info.Env()))) { + + Napi::Object tensorObj = info[0].As(); + TensorWrap* tensorWrap = Napi::ObjectWrap::Unwrap(tensorObj); + + ov::Tensor nativeTensor = tensorWrap->get_tensor(); + + ov::CompiledModel compiled = _core.import_model(nativeTensor); + + return CompiledModelWrap::wrap(info.Env(), compiled); + } + if (!info[0].IsBuffer()) { OPENVINO_THROW("The first argument must be of type Buffer."); } From 7c4192dfb7c538d2f986ec0337318b3a6f531520 Mon Sep 17 00:00:00 2001 From: iarangou Date: Tue, 18 Nov 2025 22:17:41 -0500 Subject: [PATCH 2/2] Tests: add unit test for importModel(tensor) --- .../js/node/tests/test_import_model_tensor.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/bindings/js/node/tests/test_import_model_tensor.js diff --git a/src/bindings/js/node/tests/test_import_model_tensor.js b/src/bindings/js/node/tests/test_import_model_tensor.js new file mode 100644 index 00000000000000..92434c87b95129 --- /dev/null +++ b/src/bindings/js/node/tests/test_import_model_tensor.js @@ -0,0 +1,13 @@ +const { Core, Tensor } = require('../lib/openvino'); + +test('importModel should accept a Tensor without throwing errors', () => { + const core = new Core(); + + // Minimal tensor for API checking + const data = new Uint8Array([1, 2, 3]); + const tensor = new Tensor('u8', data, [data.length]); + + expect(() => { + core.importModel(tensor); + }).not.toThrow(); +});