Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix#27796 Added condition and test case for the getData parameter input functionality #27843

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/bindings/js/node/src/tensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ Napi::Object TensorWrap::wrap(Napi::Env env, ov::Tensor tensor) {
}

Napi::Value TensorWrap::get_data(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
if (info.Length() > 0) {
reportError(env, "getData() does not accept any arguments.");
return env.Undefined()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return env.Undefined()
return env.Undefined();

there is a semicolon missing ;) I recommend checking git status carefully, building the project and running tests before pushing changes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done @almilosz

}

auto type = _tensor.get_element_type();

switch (type) {
Expand Down
6 changes: 6 additions & 0 deletions src/bindings/js/node/tests/unit/tensor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ describe('ov.Tensor tests', () => {
assert.deepStrictEqual(tensor.getData(), data);
});

it('getData should throw an error if arguments are provided', () => {
const tensor = new ov.Tensor(ov.element.f32, shape, data);
assert.throws(() => tensor.getData(1), {
message: 'getData() does not accept any arguments.',
});
});
it('test tensor.data setter - different element type throws', () => {
const float64Data = Float64Array.from([1, 2, 3]);
const tensor = new ov.Tensor(ov.element.f32, [1, 3]);
Expand Down