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
2023-12-13 00:25:49 +03:30
committed by GitHub
parent 942bc8b1ba
commit ff8d8a5b16
4 changed files with 14 additions and 6 deletions

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

View File

@@ -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.

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});
}

View File

@@ -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) {