Skip to content

Conversation

@Nishant-ZFYII
Copy link
Contributor

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
Copy link
Contributor

@almilosz almilosz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,
please run npm run format. Codestyle failed:

/__w/openvino/openvino/src/bindings/js/node/tests/unit/basic.test.js
Error:   403:46  error  Replace `⏎········ov.element.u8,⏎········[userStream.length],⏎········uint8Array,⏎······` with `ov.element.u8,·[userStream.length],·uint8Array`  prettier/prettier
Error:   420:46  error  Replace `⏎········ov.element.u8,⏎········[userStream.length],⏎········uint8Array,⏎······` with `ov.element.u8,·[userStream.length],·uint8Array`  prettier/prettier
Error:   439:46  error  Replace `⏎········ov.element.u8,⏎········[userStream.length],⏎········uint8Array,⏎······` with `ov.element.u8,·[userStream.length],·uint8Array`  prettier/prettier
Error:   453:46  error  Replace `⏎········ov.element.u8,⏎········[userStream.length],⏎········uint8Array,⏎······` with `ov.element.u8,·[userStream.length],·uint8Array`  prettier/prettier

@Nishant-ZFYII
Copy link
Contributor Author

Hey, I have made the requested code style formatting.
Thanks for you time.

@Nishant-ZFYII
Copy link
Contributor Author

@almilosz ,
Please review the PR when you have time.

Thanks !!

@Nishant-ZFYII
Copy link
Contributor Author

@almilosz ,

Kindly requestin you to review the changes made.

Thanks and regards,
Nishant.

Copy link
Contributor

@almilosz almilosz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,
functionality and tests looks good. I would change the usage of std::stringstream to ov::SharedStreamBuffer and add std::variant for stream and tensor in ImportModelContext.
If CI's checks are green, I propose to merge this PR. Would you like to work on the improvements I mentioned in a new PR @Nishant-ZFYII ?

@Nishant-ZFYII
Copy link
Contributor Author

Good Day @almilosz ,

Quick question about CI.

On my side, the GitHub Actions checks look green (summary shows success), but the required ci/jenkins check is still showing “Expected — Waiting for status to be reported” for the latest commit, and I’m not able to open any details for it from the PR UI.

Is Jenkins something that needs to be manually triggered/approved (especially since this PR is from a fork), or is there a label/comment I should add to start it?
If it helps, I can also update/rebase the branch onto the latest master to retrigger.

Thanks — just want to make sure I’m not missing a required step on my side.

@Nishant-ZFYII
Copy link
Contributor Author

@almilosz — thanks a lot for the review!

Great to hear the functionality + tests look good.

Yes, I’d be happy to work on the improvements you mentioned in a separate PR:

  • replace std::stringstream with ov::SharedStreamBuffer
  • introduce a std::variant (stream vs tensor) in ImportModelContext

If you’re okay with it, I’ll wait for the remaining CI checks to go green and for this PR to merge first, and then I’ll open a follow-up PR with those refactors.

Quick question so I do this the properly: is there an in-repo reference where ov::SharedStreamBuffer + std::variant is already used in a similar context (import/export or frontend code)? If you can point me to a file or PR, I’ll mirror that pattern.

@Nishant-ZFYII Nishant-ZFYII requested a review from almilosz January 8, 2026 08:28
@almilosz
Copy link
Contributor

almilosz commented Jan 8, 2026

I have to trigger ci/jenkins manually

@almilosz
Copy link
Contributor

almilosz commented Jan 8, 2026

build_jenkins

@Nishant-ZFYII
Copy link
Contributor Author

Good Day @almilosz

I’m seeing a few required checks failing on this PR, and I’m not sure if they’re caused by my changes or otherwise:

  • ci/jenkins (required)
  • ie_tests_cpu_ubuntu22_arm64_release
  • ie_tests_ie_python_api_arm_ubuntu22_arm64_release

Can you please provide some guidance on how to solve this issue.

@Nishant-ZFYII
Copy link
Contributor Author

Good Day @almilosz,
Can you please provide any guidance on this issue, it would be helpful.

Thanks .

@Nishant-ZFYII
Copy link
Contributor Author

Hi @almilosz,

I hope you're doing well. I wanted to follow up on my previous message.

I'm seeing 3 failing checks in the CI:

  • ci/jenkins
  • ie_tests_cpu_ubuntu22_arm64_release
  • ie_tests_ie_python_api_arm_ubuntu22_arm64_release

I'm not sure if these failures are related to my changes or if they are pre-existing/infrastructure issues.

I also see the branch is out-of-date with the base branch. Should I click "Update branch" to sync with master, or would you prefer I wait?

Could you please provide some guidance on:

  1. Whether these failing tests are caused by my changes or are unrelated infrastructure issues?
  2. What steps I should take to resolve them?

I'm new to contributing to this project and would really appreciate any help or direction you can provide.

Thank you for your time!

@almilosz
Copy link
Contributor

Hello, sometimes checks fail due to infrastructure errors. Right now please wait on my feedback. Have a nice day

@almilosz
Copy link
Contributor

build_jenkins

@almilosz
Copy link
Contributor

build_jenkins

@almilosz
Copy link
Contributor

build_jenkins

@almilosz almilosz enabled auto-merge January 14, 2026 10:06
@almilosz almilosz added this pull request to the merge queue Jan 14, 2026
Merged via the queue into openvinotoolkit:master with commit afcda9c Jan 14, 2026
205 checks passed
@mlukasze mlukasze added this to the 2026.0 milestone Jan 14, 2026
@almilosz
Copy link
Contributor

Congrats on merging your PR!
If you want to continue working on this topic, please write .take under this GFI #33601. Unfortunately I cannot assign you myself :)

@Nishant-ZFYII
Copy link
Contributor Author

Thanks a lot for the guidance and being patient with me! Happy to continue on this.

I’m working on #33601 now (SharedStreamBuffer + std::variant refactor for Core.importModel).

PR: #33658

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

4 participants