Skip to content

Commit

Permalink
Add new test case for changing priority, turbo and workload type
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Pereanu <[email protected]>
  • Loading branch information
pereanub committed Jan 29, 2025
1 parent 4ad0028 commit 3d28ec1
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1066,15 +1066,13 @@ using InferRunTestsOnNewerDrivers = InferRequestRunTests;
TEST_P(InferRunTestsOnNewerDrivers, MultipleCompiledModelsTestsSyncInfers) {
// Skip test according to plugin specific disabledTestPatterns() (if any)
SKIP_IF_CURRENT_TEST_IS_DISABLED()
// Load CNNNetwork to target plugins
const int no_of_iterations = 256;
std::array<ov::CompiledModel, no_of_iterations> compiled_models;

for (int i = 0; i < no_of_iterations; ++i) {
OV_ASSERT_NO_THROW(compiled_models[i] = core->compile_model(ov_model, target_device, configuration));
}

// Create InferRequests
std::array<ov::InferRequest, no_of_iterations> infer_reqs;
std::array<std::thread, no_of_iterations> infer_reqs_threads;
for (int i = 0; i < no_of_iterations; ++i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,11 @@ INSTANTIATE_TEST_SUITE_P(compatibility_smoke_BehaviorTests,
{ov::intel_npu::defer_weights_load(false)}})),
ov::test::utils::appendPlatformTypeTestName<OVCompileAndInferRequestTurbo>);

INSTANTIATE_TEST_SUITE_P(compatibility_smoke_BehaviorTests,
OVCompileAndInferRequesOnNewerDrivers,
::testing::Combine(::testing::Values(getConstantGraph(ov::element::f32)),
::testing::Values(ov::test::utils::DEVICE_NPU),
::testing::ValuesIn(configs)),
ov::test::utils::appendPlatformTypeTestName<OVCompileAndInferRequest>);

} // namespace
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,85 @@ TEST_P(OVCompileAndInferRequestTurbo, CompiledModelTurbo) {
}
}

using OVCompileAndInferRequesOnNewerDrivers = OVCompileAndInferRequest;

TEST_P(OVCompileAndInferRequesOnNewerDrivers, MultipleCompiledModelsTestsSyncInfers) {
// Skip test according to plugin specific disabledTestPatterns() (if any)
SKIP_IF_CURRENT_TEST_IS_DISABLED()

auto supportedProperties = core->get_property("NPU", supported_properties.name()).as<std::vector<PropertyName>>();
bool isTurboSupported =
std::any_of(supportedProperties.begin(), supportedProperties.end(), [](const PropertyName& property) {
return property == intel_npu::turbo.name();
});

if (isCommandQueueExtSupported()) {
ASSERT_TRUE(isTurboSupported);

const int no_of_iterations = 256;
std::array<ov::CompiledModel, no_of_iterations> compiled_models;

for (int i = 0; i < no_of_iterations; ++i) {
if (i % 4) {
configuration[intel_npu::turbo.name()] = false;
} else {
configuration[intel_npu::turbo.name()] = true;
}

if (i % 5 == 1) {
configuration[workload_type.name()] = WorkloadType::DEFAULT;
} else if (i % 5 == 2) {
configuration[workload_type.name()] = WorkloadType::EFFICIENT;
}

if (i % 3 == 0) {
configuration[ov::hint::model_priority.name()] = ov::hint::Priority::LOW;
} else if (i % 3 == 1) {
configuration[ov::hint::model_priority.name()] = ov::hint::Priority::MEDIUM;
} else if (i % 3 == 2) {
configuration[ov::hint::model_priority.name()] = ov::hint::Priority::HIGH;
}

OV_ASSERT_NO_THROW(compiled_models[i] = core->compile_model(function, target_device, configuration));
}

std::array<ov::InferRequest, no_of_iterations> infer_reqs;
std::array<std::thread, no_of_iterations> infer_reqs_threads;
for (int i = 0; i < no_of_iterations; ++i) {
OV_ASSERT_NO_THROW(infer_reqs[i] = compiled_models[i].create_infer_request());
}

for (int i = 0; i < no_of_iterations; ++i) {
infer_reqs_threads[i] = std::thread([&compiled_models, &infer_reqs, i]() -> void {
OV_ASSERT_NO_THROW(infer_reqs[i].infer());

ov::AnyMap modelConfiguration;
if (i % 5 == 0) {
modelConfiguration[workload_type.name()] = WorkloadType::DEFAULT;
OV_ASSERT_NO_THROW(compiled_models[i].set_property(modelConfiguration));
} else if (i % 5 == 1) {
modelConfiguration[workload_type.name()] = WorkloadType::EFFICIENT;
OV_ASSERT_NO_THROW(compiled_models[i].set_property(modelConfiguration));
} else if (i % 5 == 2) {
modelConfiguration[workload_type.name()] = WorkloadType::DEFAULT;
OV_ASSERT_NO_THROW(compiled_models[i].set_property(modelConfiguration));
} else if (i % 5 == 3) {
modelConfiguration[workload_type.name()] = WorkloadType::EFFICIENT;
OV_ASSERT_NO_THROW(compiled_models[i].set_property(modelConfiguration));
}

OV_ASSERT_NO_THROW(infer_reqs[i].infer());

infer_reqs[i] = {};
});
}

for (int i = 0; i < no_of_iterations; ++i) {
infer_reqs_threads[i].join();
}
}
}

} // namespace behavior
} // namespace test
} // namespace ov

0 comments on commit 3d28ec1

Please sign in to comment.