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:
parent
e03e716752
commit
ef2ca66b8b
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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', () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue