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 #25657

Closed
wants to merge 0 commits into from

Conversation

Pey-crypto
Copy link
Contributor

Implemented Method on c++ side.
Updated typescript definitions.
Created unit tests.
For Issue #25406

@Pey-crypto Pey-crypto requested a review from a team as a code owner July 20, 2024 19:09
@github-actions github-actions bot added the category: JS API OpenVino JS API Bindings label Jul 20, 2024
@sys-openvino-ci sys-openvino-ci added the ExternalPR External contributor label Jul 20, 2024
@mlukasze
Copy link
Contributor

hey @Pey-crypto there is a conflict to solve, will you have a time to fix it, please?

@mlukasze mlukasze linked an issue Jul 25, 2024 that may be closed by this pull request
@Pey-crypto
Copy link
Contributor Author

Will do it soon👍

@mlukasze
Copy link
Contributor

awesome, thank you in advance!

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.

Please apply suggestions and update tests, but it looks fine

Comment on lines 112 to 117
/**
* @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);
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
/**
* @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.
*/
Napi::Value get_output_element_type(const Napi::CallbackInfo& info);

Comment on lines 238 to 241
* 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 element type of a specific output of the model.
*/
input(): Output;
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
* 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 element type of a specific output of the model.
*/
input(): Output;
* It gets the element type of a specific output of the model.
* @param index The index of the output.
*/
getOutputElementType(index: number): string;
/**
* It gets the input of the model.
* If a model has more than one input, this method throws an exception.
*/
input(): Output;

Typedoc comments have to be above the method you are adding

reportError(info.Env(), e.what());
return info.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
}
}

/^Error:/,
'Should throw for out-of-range index'
);
});
});
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
});
});

#include "node/include/addon.hpp"
#include "node/include/errors.hpp"
#include "node/include/helper.hpp"
#include "node/include/model_wrap.hpp"
Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert this change and move #include "node/include/model_wrap.hpp" to the top.
Probably you are using a different formatting tool than is specified here

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));
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
OPENVINO_THROW("getOutputElementType", ov::js::get_parameters_error_msg(info, allowed_signatures));
OPENVINO_THROW("'getOutputElementType'", ov::js::get_parameters_error_msg(info, allowed_signatures));

it('should accept a single integer argument', () => {
assert.throws(() => {
model.getOutputElementType();
}, /^Error: getOutputElementType method called with incorrect parameters\./,
Copy link
Contributor

Choose a reason for hiding this comment

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

You forgot to update error messages ;)


assert.throws(() => {
model.getOutputElementType('unexpected argument');
}, /^Error: getOutputElementType method called with incorrect parameters\./,
Copy link
Contributor

Choose a reason for hiding this comment

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

.


assert.throws(() => {
model.getOutputElementType(0, 1);
}, /^Error: getOutputElementType method called with incorrect parameters\./,
Copy link
Contributor

Choose a reason for hiding this comment

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

.


assert.throws(() => {
model.getOutputElementType(3.14);
}, /^Error: getOutputElementType method called with incorrect parameters\./,
Copy link
Contributor

Choose a reason for hiding this comment

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

.

@Pey-crypto Pey-crypto requested a review from almilosz July 26, 2024 13:06
@Pey-crypto Pey-crypto requested a review from a team as a code owner July 26, 2024 13:06
@Pey-crypto Pey-crypto requested review from ilya-lavrenov and removed request for a team July 26, 2024 13:06
@Pey-crypto Pey-crypto closed this Jul 27, 2024
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 no-match-files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Good First Issue]: Enable Model.getOutputElementType(idx)
4 participants