-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GPU] Parse runtime_options from model RT info and apply to config
Signed-off-by: Vladimir Paramuzov <[email protected]>
- Loading branch information
1 parent
398f703
commit 8b0137b
Showing
4 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
src/plugins/intel_gpu/tests/functional/behavior/properties.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "openvino/runtime/properties.hpp" | ||
#include "base/ov_behavior_test_utils.hpp" | ||
#include "openvino/runtime/core.hpp" | ||
#include "common_test_utils/subgraph_builders/conv_pool_relu.hpp" | ||
|
||
namespace { | ||
|
||
class TestPropertiesGPU : public ::testing::Test { | ||
public: | ||
std::shared_ptr<ov::Model> model; | ||
|
||
void SetUp() override { | ||
SKIP_IF_CURRENT_TEST_IS_DISABLED(); | ||
model = ov::test::utils::make_conv_pool_relu(); | ||
} | ||
}; | ||
|
||
TEST_F(TestPropertiesGPU, RTInfoPropertiesWithDefault) { | ||
ov::Core core; | ||
ov::Any type; | ||
ov::Any size; | ||
ov::Any scale; | ||
ov::CompiledModel compiled_model; | ||
model->set_rt_info("f16", "runtime_options", ov::hint::kv_cache_precision.name()); | ||
model->set_rt_info("0", "runtime_options", ov::hint::dynamic_quantization_group_size.name()); | ||
model->set_rt_info("8.0", "runtime_options", ov::hint::activations_scale_factor.name()); | ||
|
||
OV_ASSERT_NO_THROW(compiled_model = core.compile_model(model, ov::test::utils::DEVICE_GPU)); | ||
OV_ASSERT_NO_THROW(type = compiled_model.get_property(ov::hint::kv_cache_precision)); | ||
OV_ASSERT_NO_THROW(size = compiled_model.get_property(ov::hint::dynamic_quantization_group_size)); | ||
OV_ASSERT_NO_THROW(scale = compiled_model.get_property(ov::hint::activations_scale_factor)); | ||
ASSERT_EQ(type.as<ov::element::Type>(), ov::element::f16); | ||
ASSERT_EQ(size.as<uint64_t>(), 0); | ||
ASSERT_EQ(scale.as<float>(), 8.0f); | ||
} | ||
|
||
TEST_F(TestPropertiesGPU, RTInfoPropertiesWithUserValuesFromCore) { | ||
ov::Core core; | ||
ov::Any type; | ||
ov::Any size; | ||
ov::Any scale; | ||
ov::CompiledModel compiled_model; | ||
model->set_rt_info("f16", "runtime_options", ov::hint::kv_cache_precision.name()); | ||
model->set_rt_info("0", "runtime_options", ov::hint::dynamic_quantization_group_size.name()); | ||
model->set_rt_info("8.0", "runtime_options", ov::hint::activations_scale_factor.name()); | ||
core.set_property(ov::hint::kv_cache_precision(ov::element::u8)); | ||
core.set_property(ov::hint::dynamic_quantization_group_size(16)); | ||
core.set_property(ov::hint::activations_scale_factor(4.0f)); | ||
|
||
OV_ASSERT_NO_THROW(compiled_model = core.compile_model(model, ov::test::utils::DEVICE_GPU)); | ||
OV_ASSERT_NO_THROW(type = compiled_model.get_property(ov::hint::kv_cache_precision)); | ||
OV_ASSERT_NO_THROW(size = compiled_model.get_property(ov::hint::dynamic_quantization_group_size)); | ||
OV_ASSERT_NO_THROW(scale = compiled_model.get_property(ov::hint::activations_scale_factor)); | ||
ASSERT_EQ(type.as<ov::element::Type>(), ov::element::u8); | ||
ASSERT_EQ(size.as<uint64_t>(), 16); | ||
ASSERT_EQ(scale.as<float>(), 4.0f); | ||
} | ||
|
||
TEST_F(TestPropertiesGPU, RTInfoPropertiesWithUserValuesFromCompileModel) { | ||
ov::Core core; | ||
ov::Any type; | ||
ov::Any size; | ||
ov::Any scale; | ||
ov::CompiledModel compiled_model; | ||
model->set_rt_info("f16", "runtime_options", ov::hint::kv_cache_precision.name()); | ||
model->set_rt_info("0", "runtime_options", ov::hint::dynamic_quantization_group_size.name()); | ||
model->set_rt_info("8.0", "runtime_options", ov::hint::activations_scale_factor.name()); | ||
ov::AnyMap config; | ||
config[ov::hint::kv_cache_precision.name()] = "u8"; | ||
config[ov::hint::dynamic_quantization_group_size.name()] = "16"; | ||
config[ov::hint::activations_scale_factor.name()] = "4.0"; | ||
|
||
OV_ASSERT_NO_THROW(compiled_model = core.compile_model(model, ov::test::utils::DEVICE_GPU, config)); | ||
OV_ASSERT_NO_THROW(type = compiled_model.get_property(ov::hint::kv_cache_precision)); | ||
OV_ASSERT_NO_THROW(size = compiled_model.get_property(ov::hint::dynamic_quantization_group_size)); | ||
OV_ASSERT_NO_THROW(scale = compiled_model.get_property(ov::hint::activations_scale_factor)); | ||
ASSERT_EQ(type.as<ov::element::Type>(), ov::element::u8); | ||
ASSERT_EQ(size.as<uint64_t>(), 16); | ||
ASSERT_EQ(scale.as<float>(), 4.0f); | ||
} | ||
|
||
} // namespace |