Introduced "reset_state" method to reset all model states in one line (#21595)

* added reset_state method to simplify the user API

* using reset_state method in the tests
This commit is contained in:
Ivan Tikhonov authored and GitHub committed 2023-12-13 00:55:49 +04:00
1 parent 942bc8b1ba
commit ff8d8a5b16
4 files changed
+14 -6

No files matched your search

+1 -3
View File
@@ -57,9 +57,7 @@ int main(int argc, char* argv[]) {
}
// 7. Initialize memory state before starting
for (auto&& state : infer_request.query_state()) {
state.reset();
}
infer_request.reset_state();
//! [part1]
// input data
@@ -315,6 +315,12 @@ public:
*/
std::vector<VariableState> query_state();
/**
* @brief Resets all internal variable states for relevant infer request to a value specified as
* default for the corresponding `ReadValue` node
*/
void reset_state();
/**
* @brief Returns a compiled model that creates this inference request.
* @return Compiled model object.
+6
View File
@@ -291,6 +291,12 @@ std::vector<VariableState> InferRequest::query_state() {
return variable_states;
}
void InferRequest::reset_state(){OV_INFER_REQ_CALL_STATEMENT({
for (auto&& state : _impl->query_state()) {
state->reset();
}
})}
CompiledModel InferRequest::get_compiled_model() {
OV_INFER_REQ_CALL_STATEMENT(return {std::const_pointer_cast<ICompiledModel>(_impl->get_compiled_model()), _so});
}
@@ -27,9 +27,7 @@ public:
}
void reset_state() {
for (auto&& state : inferRequest.query_state()) {
state.reset();
}
inferRequest.reset_state();
}
static void float_compare(const float* expected_res, const float* actual_res, size_t size) {