Added argument check and corresponding node runner test for the get_shape method (#23637)

This Fixes #23441 issue.

Details:

1. Modified get_shape() method to report error in case any argument is
passed.
2. Added Required Tests for the above in `tensor.test.js`.

---------

Co-authored-by: Vishniakov Nikolai <nikolai.vishniakov@intel.com>
Co-authored-by: Alicja Miloszewska <alicja.miloszewska@intel.com>
This commit is contained in:
adismort14 2024-04-17 17:41:46 +05:30 committed by GitHub
parent e03e716752
commit ef2ca66b8b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View File

@ -133,6 +133,10 @@ Napi::Value TensorWrap::get_data(const Napi::CallbackInfo& info) {
}
Napi::Value TensorWrap::get_shape(const Napi::CallbackInfo& info) {
if (info.Length() > 0) {
reportError(info.Env(), "No parameters are allowed for the getShape() method.");
return info.Env().Undefined();
}
return cpp_to_js<ov::Shape, Napi::Array>(info, _tensor.get_shape());
}

View File

@ -120,6 +120,14 @@ describe('Tensor shape', () => {
/Cannot convert argument./
);
});
it('getShape() method does not accept parameters', () => {
const tensor = new ov.Tensor(ov.element.f32, [1, 3, 224, 224], data);
assert.throws(
() => tensor.getShape(1, 2, 3),
{ message: 'No parameters are allowed for the getShape() method.'}
);
});
});
describe('Tensor element type', () => {