Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[NPU] Mark cancel() method for inferences unsupported (#36340)

Bogdan Pereanua86a56d661ea
diff --git a/src/plugins/intel_npu/src/plugin/include/async_infer_request.hpp b/src/plugins/intel_npu/src/plugin/include/async_infer_request.hpp
index 3a590fbe5a8..f3aa57990d6 100644
--- a/src/plugins/intel_npu/src/plugin/include/async_infer_request.hpp
+++ b/src/plugins/intel_npu/src/plugin/include/async_infer_request.hpp
@@ -23,6 +23,8 @@ public:
AsyncInferRequest& operator=(const AsyncInferRequest&) = delete;
+ void cancel() override;
+
~AsyncInferRequest();
private:
diff --git a/src/plugins/intel_npu/src/plugin/src/async_infer_request.cpp b/src/plugins/intel_npu/src/plugin/src/async_infer_request.cpp
index 8b3abc96c5b..d7a5a8421cd 100644
--- a/src/plugins/intel_npu/src/plugin/src/async_infer_request.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/async_infer_request.cpp
@@ -26,6 +26,10 @@ AsyncInferRequest::AsyncInferRequest(const std::shared_ptr<InferRequest>& inferR
}
}
+void AsyncInferRequest::cancel() {
+ OPENVINO_THROW("Inference cancellation is not supported by the Intel NPU plugin");
+}
+
AsyncInferRequest::~AsyncInferRequest() {
stop_and_wait();
}
diff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/cancellation.cpp b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/cancellation.cpp
deleted file mode 100644
index c80b5db8bb8..00000000000
--- a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/cancellation.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (C) 2018-2026 Intel Corporation
-// SPDX-License-Identifier: Apache-2.0
-//
-
-#include "cancellation.hpp"
-
-#include "common/npu_test_env_cfg.hpp"
-
-namespace {
-const std::vector<ov::AnyMap> configs = {{}};
-
-INSTANTIATE_TEST_SUITE_P(compatibility_smoke_BehaviorTests,
- OVInferRequestCancellationTestsNPU,
- ::testing::Combine(::testing::Values(ov::test::utils::DEVICE_NPU),
- ::testing::ValuesIn(configs)),
- InferRequestParamsAnyMapTestName::getTestCaseName);
-} // namespace
diff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/cancellation.hpp b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/cancellation.hpp
deleted file mode 100644
index 10c3c49f44f..00000000000
--- a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/cancellation.hpp
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (C) 2018-2026 Intel Corporation
-// SPDX-License-Identifier: Apache-2.0
-//
-
-#pragma once
-
-#include <future>
-
-#include "common/utils.hpp"
-#include "openvino/runtime/exception.hpp"
-
-namespace ov {
-namespace test {
-namespace behavior {
-using OVInferRequestCancellationTestsNPU = OVInferRequestTestsNPU;
-
-TEST_P(OVInferRequestCancellationTestsNPU, canCancelAsyncRequest) {
- ov::InferRequest req;
- OV_ASSERT_NO_THROW(req = execNet.create_infer_request());
- OV_ASSERT_NO_THROW(req.start_async());
- OV_ASSERT_NO_THROW(req.cancel());
- try {
- req.wait();
- } catch (const ov::Cancelled&) {
- SUCCEED();
- }
-}
-
-TEST_P(OVInferRequestCancellationTestsNPU, CanResetAfterCancelAsyncRequest) {
- ov::InferRequest req;
- OV_ASSERT_NO_THROW(req = execNet.create_infer_request());
- OV_ASSERT_NO_THROW(req.start_async());
- OV_ASSERT_NO_THROW(req.cancel());
- try {
- req.wait();
- } catch (const ov::Cancelled&) {
- SUCCEED();
- }
- OV_ASSERT_NO_THROW(req.start_async());
- OV_ASSERT_NO_THROW(req.wait());
-}
-
-TEST_P(OVInferRequestCancellationTestsNPU, canCancelBeforeAsyncRequest) {
- ov::InferRequest req;
- OV_ASSERT_NO_THROW(req = execNet.create_infer_request());
- OV_ASSERT_NO_THROW(req.cancel());
-}
-
-TEST_P(OVInferRequestCancellationTestsNPU, canCancelInferRequest) {
- ov::InferRequest req;
- OV_ASSERT_NO_THROW(req = execNet.create_infer_request());
- auto infer = std::async(std::launch::async, [&req] {
- req.infer();
- });
- while (!req.wait_for({})) {
- }
- OV_ASSERT_NO_THROW(req.cancel());
- try {
- infer.get();
- } catch (const ov::Cancelled&) {
- SUCCEED();
- }
-}
-} // namespace behavior
-} // namespace test
-} // namespace ov
diff --git a/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/ov_infer_request/cancellation.cpp b/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/ov_infer_request/cancellation.cpp
deleted file mode 100644
index ce930c01cc3..00000000000
--- a/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/ov_infer_request/cancellation.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (C) 2018-2026 Intel Corporation
-// SPDX-License-Identifier: Apache-2.0
-//
-
-#include <behavior/ov_infer_request/cancellation.hpp>
-
-#include "common/npu_test_env_cfg.hpp"
-
-using namespace ov::test::behavior;
-
-namespace {
-const std::vector<ov::AnyMap> configs = {{}};
-
-INSTANTIATE_TEST_SUITE_P(compatibility_smoke_BehaviorTests,
- OVInferRequestCancellationTests,
- ::testing::Combine(::testing::Values(ov::test::utils::DEVICE_NPU),
- ::testing::ValuesIn(configs)),
- InferRequestParamsAnyMapTestName::getTestCaseName);
-
-} // namespace