Skip to content

Conversation

@Nishant-ZFYII
Copy link

Summary

Expose Core::import_model(tensor, device, config) to the Node.js API so compiled models can be imported from an ov.Tensor, matching the Python bindings (#32651).

Fixes #32725

What/Why

OpenVINO C++ already supports importing a compiled model from a Tensor (#31327). This PR wires that overload into the JavaScript/Node.js bindings so users can round-trip a compiled model via exportModelSync()TensorimportModelSync() (and the async equivalents).

Changes

  • Add a Tensor overload for CoreWrap::import_model() (sync)
  • Add a Tensor overload for CoreWrap::import_model_async() (async)
  • Update TypeScript definitions to accept Tensor as the first parameter
  • Add unit tests covering Tensor import for both sync and async paths

Testing

  • All existing and new tests pass locally
  • Implementation follows existing patterns and reuses helper utilities (validate_value, cast_to_tensor, to_anyMap)

Example

const { addon: ov } = require('openvino-node');
const core = new ov.Core();

// Export compiled model to a buffer
const compiled = core.compileModelSync(model, 'CPU');
const buffer = compiled.exportModelSync();

// Wrap bytes in a Tensor
const uint8Array = new Uint8Array(buffer);
const tensor = new ov.Tensor(ov.element.u8, [buffer.length], uint8Array);

// Import compiled model from Tensor (NEW)
const imported = core.importModelSync(tensor, 'CPU');

## Related PRs
- C++ support: #31327
- Python parity: #32651

- Implement tensor overload in CoreWrap::import_model()
- Implement tensor overload in CoreWrap::import_model_async()
- Add TypeScript definitions for Tensor parameter
- Add comprehensive tests for sync and async variants

Fixes openvinotoolkit#32725
@Nishant-ZFYII Nishant-ZFYII requested a review from a team as a code owner December 29, 2025 22:13
@github-actions github-actions bot added the category: JS API OpenVino JS API Bindings label Dec 29, 2025
@sys-openvino-ci sys-openvino-ci added the ExternalPR External contributor label Dec 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: JS API OpenVino JS API Bindings ExternalPR External contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Good First Issue]: Add import_model(tensor) to JS API

2 participants