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

Implemented getOutputElementType #25760

Merged
merged 42 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
7d6a2c7
implemented getOutputElementType
Pey-crypto Jul 14, 2024
acfffa7
Fixed errors in variable names
Pey-crypto Jul 14, 2024
9a67e56
Fixed Error in error string
Pey-crypto Jul 15, 2024
7c671cc
Merge branch 'master' into master
Pey-crypto Jul 16, 2024
74122ce
Update src/bindings/js/node/include/model_wrap.hpp
Pey-crypto Jul 17, 2024
f301d12
Update src/bindings/js/node/lib/addon.ts
Pey-crypto Jul 17, 2024
2718d0b
Update src/bindings/js/node/src/model_wrap.cpp
Pey-crypto Jul 17, 2024
950ab0d
Updates to get_output_element_type
Pey-crypto Jul 17, 2024
a38ccf1
Merge branch 'openvinotoolkit:master' into master
Pey-crypto Jul 17, 2024
9fd778e
Updated
Pey-crypto Jul 20, 2024
4ea1ba6
Merge branch 'openvinotoolkit:master' into master
Pey-crypto Jul 20, 2024
5e961c5
Fixed allowed signatures and used the format described in type_valida…
Pey-crypto Jul 20, 2024
285a94a
addon.ts
Pey-crypto Jul 20, 2024
350cbea
Updated the method to use the type_validation.
Pey-crypto Jul 24, 2024
be5b9a6
Updates to method and tests.
Pey-crypto Jul 26, 2024
2b824e7
Resolved merge conflicts
Pey-crypto Jul 27, 2024
12fa8f7
Fixed formatting error
Pey-crypto Jul 27, 2024
1a77dbb
Fixed allowed signatures and used the format described in type_valida…
Pey-crypto Jul 20, 2024
01bca61
Fixed addon.ts
Pey-crypto Jul 20, 2024
7cf0c70
Updated the method to use the type_validation.
Pey-crypto Jul 24, 2024
1dca9e4
Updates to method and tests.
Pey-crypto Jul 26, 2024
2b9d119
Fixed formatting error
Pey-crypto Jul 27, 2024
46cf4fd
Merge branch 'outputDataType' of https://github.com/Pey-crypto/openvi…
Pey-crypto Jul 27, 2024
118807c
Revert changes in package-lock.json and model.test.js to resolve merg…
Pey-crypto Jul 27, 2024
84d8256
fixing merge errors
Pey-crypto Jul 27, 2024
368b990
Merge branch 'outputDataType' of https://github.com/Pey-crypto/openvi…
Pey-crypto Jul 27, 2024
94dea69
resolved error functions
Pey-crypto Jul 27, 2024
a8778d4
Reverted changes committed to open_model_zoo to the previous state
Pey-crypto Jul 28, 2024
4e8ceaa
Removed the correct package-lock file.
Pey-crypto Jul 28, 2024
9a235eb
Updated files to the last commit.
Pey-crypto Jul 28, 2024
fb72d48
Merge branch 'master' into outputDataType
Pey-crypto Jul 29, 2024
933dfb6
Applied suggestions:
Pey-crypto Jul 29, 2024
78d899d
Merge branch 'master' into outputDataType
Pey-crypto Jul 30, 2024
4447083
deleted file
Pey-crypto Jul 30, 2024
7568016
Merge branch 'openvinotoolkit:master' into outputDataType
Pey-crypto Jul 30, 2024
10d3865
Applied suggestions
Pey-crypto Aug 1, 2024
b96f04c
Merge branch 'outputDataType' of https://github.com/Pey-crypto/openvi…
Pey-crypto Aug 1, 2024
954a72e
Fixed merge issue
Pey-crypto Aug 1, 2024
2f2827a
Merge branch 'master' into outputDataType
Pey-crypto Aug 1, 2024
d50c812
Merge branch 'master' into outputDataType
Pey-crypto Aug 2, 2024
54b6e28
Fix documentation comment
almilosz Aug 2, 2024
5bc3023
Update src/bindings/js/node/lib/addon.ts
almilosz Aug 2, 2024
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ coverage
/src/plugins/intel_cpu/tools/commit_slider/*.json
/src/plugins/intel_cpu/tools/commit_slider/slider_cache/*
/src/plugins/intel_cpu/thirdparty/ComputeLibrary/build/*
.github/GITHUB_OUTPUT
.github/GITHUB_OUTPUT
13 changes: 13 additions & 0 deletions src/bindings/js/node/include/model_wrap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,19 @@ class ModelWrap : public Napi::ObjectWrap<ModelWrap> {
* @return Napi::Array containing a shape of requested output.
*/
Napi::Value get_output_shape(const Napi::CallbackInfo& info);

/**
* @brief Helper function to access model output elements types.
* @return Napi::String representing the element type of the requested output.
*
*/
Napi::Value get_output_element_type(const Napi::CallbackInfo& info);

/**
* @brief Helper function to access model output elements types.
* @return Napi::String representing the element type of the requested output.
*
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

The method description should be placed only once, above the declaration. This one can be deleted.

Suggested change
/**
* @brief Helper function to access model output elements types.
* @return Napi::String representing the element type of the requested output.
*
*/


private:
std::shared_ptr<ov::Model> _model;
Expand Down
5 changes: 5 additions & 0 deletions src/bindings/js/node/lib/addon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ interface Model {
* It gets the input of the model.
* If a model has more than one input, this method throws an exception.
*/
getOutputElementType(index: number): string;
/**
* It gets the input of the model.
* if a model has more than one input, this method throws an exception.
almilosz marked this conversation as resolved.
Show resolved Hide resolved
*/
input(): Output;
almilosz marked this conversation as resolved.
Show resolved Hide resolved
/**
* It gets the input of the model identified by the tensor name.
Expand Down
18 changes: 18 additions & 0 deletions src/bindings/js/node/src/model_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "node/include/errors.hpp"
#include "node/include/helper.hpp"
#include "node/include/node_output.hpp"
#include "node/include/type_validation.hpp"

ModelWrap::ModelWrap(const Napi::CallbackInfo& info)
: Napi::ObjectWrap<ModelWrap>(info),
Expand All @@ -25,6 +26,7 @@ Napi::Function ModelWrap::get_class(Napi::Env env) {
InstanceMethod("setFriendlyName", &ModelWrap::set_friendly_name),
InstanceMethod("getFriendlyName", &ModelWrap::get_friendly_name),
InstanceMethod("getOutputShape", &ModelWrap::get_output_shape),
InstanceMethod("getOutputElementType", &ModelWrap::get_output_element_type),
InstanceAccessor<&ModelWrap::get_inputs>("inputs"),
InstanceAccessor<&ModelWrap::get_outputs>("outputs")});
}
Expand Down Expand Up @@ -171,3 +173,19 @@ Napi::Value ModelWrap::get_output_shape(const Napi::CallbackInfo& info) {
return info.Env().Undefined();
}
}

Napi::Value ModelWrap::get_output_element_type(const Napi::CallbackInfo& info) {
std::vector<std::string> allowed_signatures;
try {
if (ov::js::validate<int>(info, allowed_signatures)) {
auto idx = info[0].As<Napi::Number>().Int32Value();
const auto& output = _model->output(idx);
return cpp_to_js<ov::element::Type_t, Napi::String>(info, output.get_element_type());
} else {
OPENVINO_THROW("'getOutputElementType'", ov::js::get_parameters_error_msg(info, allowed_signatures));
}
} catch (const std::exception& e) {
reportError(info.Env(), e.what());
return info.Env().Undefined();
}
}
45 changes: 45 additions & 0 deletions src/bindings/js/node/tests/unit/model.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,48 @@ describe('Model.getOutputSize()', () => {
assert.strictEqual(model.getOutputSize(), 1, 'Expected getOutputSize to return 1 for the default model');
});
});

describe('Model.getOutputElementType()', () => {
it('should return a string for the element type ', () => {
const result = model.getOutputElementType(0);
assert.strictEqual(typeof result, 'string',
'getOutputElementType() should return a string');
});

it('should accept a single integer argument', () => {
assert.throws(() => {
model.getOutputElementType();
}, /'getOutputElementType' method called with incorrect parameters/,
'Should throw when called without arguments');

assert.throws(() => {
model.getOutputElementType('unexpected argument');
}, /'getOutputElementType' method called with incorrect parameters/,
'Should throw on non-number argument');

assert.throws(() => {
model.getOutputElementType(0, 1);
}, /'getOutputElementType' method called with incorrect parameters/,
'Should throw on multiple arguments');

assert.throws(() => {
model.getOutputElementType(3.14);
}, /'getOutputElementType' method called with incorrect parameters/,
'Should throw on non-integer number');
});

it('should return a valid element type for the default model', () => {
const elementType = model.getOutputElementType(0);
assert.ok(typeof elementType === 'string' && elementType.length > 0,
`Expected a non-empty string, got ${elementType}`);
});

it('should throw an error for out-of-range index', () => {
const outputSize = model.getOutputSize();
assert.throws(
() => { model.getOutputElementType(outputSize); },
/^Error: /,
'Should throw for out-of-range index'
);
});
});
2 changes: 1 addition & 1 deletion thirdparty/open_model_zoo
Pey-crypto marked this conversation as resolved.
Show resolved Hide resolved
Submodule open_model_zoo updated 30 files
+0 −1 .github/workflows/accuracy_checker.yml
+0 −1 .github/workflows/cpp_gapi-demos.yml
+0 −1 .github/workflows/model_api.yml
+1 −1 demos/classification_benchmark_demo/cpp/main.cpp
+2 −2 demos/common/python/model_zoo/model_api/README.md
+0 −5 tools/accuracy_checker/accuracy_checker/adapters/README.md
+0 −2 tools/accuracy_checker/accuracy_checker/adapters/__init__.py
+0 −68 tools/accuracy_checker/accuracy_checker/adapters/yolo.py
+1 −3 tools/accuracy_checker/accuracy_checker/annotation_converters/__init__.py
+3 −39 tools/accuracy_checker/accuracy_checker/annotation_converters/convert.py
+0 −192 tools/accuracy_checker/accuracy_checker/annotation_converters/hpatches.py
+3 −4 tools/accuracy_checker/accuracy_checker/annotation_converters/ms_coco.py
+1 −1 tools/accuracy_checker/accuracy_checker/config/config_validator.py
+1 −2 tools/accuracy_checker/accuracy_checker/data_readers/__init__.py
+2 −36 tools/accuracy_checker/accuracy_checker/data_readers/annotation_readers.py
+1 −10 tools/accuracy_checker/accuracy_checker/data_readers/data_reader.py
+0 −10 tools/accuracy_checker/accuracy_checker/launcher/input_feeder.py
+12 −93 tools/accuracy_checker/accuracy_checker/launcher/pytorch_launcher.py
+0 −12 tools/accuracy_checker/accuracy_checker/launcher/pytorch_launcher_readme.md
+0 −2 tools/accuracy_checker/accuracy_checker/metrics/__init__.py
+0 −169 tools/accuracy_checker/accuracy_checker/metrics/matches_homography.py
+1 −7 tools/accuracy_checker/accuracy_checker/representation/__init__.py
+0 −29 tools/accuracy_checker/accuracy_checker/representation/image_feature_representation.py
+1 −1 tools/accuracy_checker/requirements-test.in
+1 −1 tools/accuracy_checker/setup.py
+3 −4 tools/accuracy_checker/tests/test_adapters.py
+0 −67 tools/accuracy_checker/tests/test_convert.py
+16 −26 tools/accuracy_checker/tests/test_detection_metrics.py
+7 −7 tools/accuracy_checker/tests/test_preprocessor.py
+2 −2 tools/accuracy_checker/tests/test_regression_metrics.py
Loading