Skip to content

Commit 297b0ec

Browse files
committed
[GPU] Changed ExecutionMode::ACCURACY mode behaviour on GPU. Previously, all floating-point data types were upconverted to f32 data type with enabled ExecutionMode::ACCURACY, now we preserve the original model's data types.
1 parent 1fef582 commit 297b0ec

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/plugins/intel_gpu/src/runtime/execution_config.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class InferencePrecisionValidator : public BaseValidator {
1919
public:
2020
bool is_valid(const ov::Any& v) const override {
2121
auto precision = v.as<ov::element::Type>();
22-
return precision == ov::element::f16 || precision == ov::element::f32;
22+
return precision == ov::element::f16 || precision == ov::element::f32 || precision == ov::element::undefined;
2323
}
2424
};
2525

@@ -129,7 +129,7 @@ void ExecutionConfig::apply_execution_hints(const cldnn::device_info& info) {
129129
const auto mode = get_property(ov::hint::execution_mode);
130130
if (!is_set_by_user(ov::hint::inference_precision)) {
131131
if (mode == ov::hint::ExecutionMode::ACCURACY) {
132-
set_property(ov::hint::inference_precision(ov::element::f32));
132+
set_property(ov::hint::inference_precision(ov::element::undefined));
133133
} else if (mode == ov::hint::ExecutionMode::PERFORMANCE) {
134134
if (info.supports_fp16)
135135
set_property(ov::hint::inference_precision(ov::element::f16));

src/plugins/intel_gpu/tests/functional/behavior/inference_precision.cpp

+19-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ TEST_P(InferencePrecisionTests, smoke_canSetInferencePrecisionAndInfer) {
3737
static const std::vector<params> test_params = {
3838
{ov::element::f16, ov::element::f32},
3939
{ov::element::f16, ov::element::f16},
40+
{ov::element::f16, ov::element::undefined},
4041
{ov::element::f32, ov::element::f32},
4142
{ov::element::f32, ov::element::f16},
43+
{ov::element::f32, ov::element::undefined},
4244
};
4345

4446
INSTANTIATE_TEST_SUITE_P(smoke_GPU_BehaviorTests, InferencePrecisionTests, ::testing::ValuesIn(test_params), InferencePrecisionTests::getTestCaseName);
@@ -48,7 +50,6 @@ TEST(InferencePrecisionTests, CantSetInvalidInferencePrecision) {
4850

4951
ASSERT_NO_THROW(core.get_property(ov::test::utils::DEVICE_GPU, ov::hint::inference_precision));
5052
ASSERT_ANY_THROW(core.set_property(ov::test::utils::DEVICE_GPU, ov::hint::inference_precision(ov::element::bf16)));
51-
ASSERT_ANY_THROW(core.set_property(ov::test::utils::DEVICE_GPU, ov::hint::inference_precision(ov::element::undefined)));
5253
}
5354

5455
TEST(ExecutionModeTest, SetCompileGetInferPrecisionAndExecMode) {
@@ -62,10 +63,26 @@ TEST(ExecutionModeTest, SetCompileGetInferPrecisionAndExecMode) {
6263
ASSERT_EQ(ov::element::f32, compiled_model.get_property(ov::hint::inference_precision));
6364
}
6465

66+
{
67+
/* ov::hint::inference_precision has higher priority than ov::hint::execution_mode */
68+
auto compiled_model = core.compile_model(model, ov::test::utils::DEVICE_GPU, ov::hint::inference_precision(ov::element::f16),
69+
ov::hint::execution_mode(ov::hint::ExecutionMode::ACCURACY));
70+
ASSERT_EQ(ov::hint::ExecutionMode::ACCURACY, compiled_model.get_property(ov::hint::execution_mode));
71+
ASSERT_EQ(ov::element::f16, compiled_model.get_property(ov::hint::inference_precision));
72+
}
73+
74+
{
75+
/* ov::hint::inference_precision has higher priority than ov::hint::execution_mode */
76+
auto compiled_model = core.compile_model(model, ov::test::utils::DEVICE_GPU, ov::hint::inference_precision(ov::element::undefined),
77+
ov::hint::execution_mode(ov::hint::ExecutionMode::PERFORMANCE));
78+
ASSERT_EQ(ov::hint::ExecutionMode::PERFORMANCE, compiled_model.get_property(ov::hint::execution_mode));
79+
ASSERT_EQ(ov::element::undefined, compiled_model.get_property(ov::hint::inference_precision));
80+
}
81+
6582
{
6683
auto compiled_model = core.compile_model(model, ov::test::utils::DEVICE_GPU, ov::hint::execution_mode(ov::hint::ExecutionMode::ACCURACY));
6784
ASSERT_EQ(ov::hint::ExecutionMode::ACCURACY, compiled_model.get_property(ov::hint::execution_mode));
68-
ASSERT_EQ(ov::element::f32, compiled_model.get_property(ov::hint::inference_precision));
85+
ASSERT_EQ(ov::element::undefined, compiled_model.get_property(ov::hint::inference_precision));
6986
}
7087

7188
{

0 commit comments

Comments
 (0)