OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[NPU][WS] New test that asserts size(weightless compiled model) > size(weightfull compiled model) (#33168)
Razvan Apetroaie1ed670089910
diff --git a/src/plugins/intel_npu/tests/functional/behavior/weights_separation.hpp b/src/plugins/intel_npu/tests/functional/behavior/weights_separation.hppindex 1adcc1513fe..f33e9bc2f2e 100644--- a/src/plugins/intel_npu/tests/functional/behavior/weights_separation.hpp+++ b/src/plugins/intel_npu/tests/functional/behavior/weights_separation.hpp@@ -103,8 +103,8 @@ public:const bool alternativeWeights = false) {constexpr auto precision = element::f32;- const float weightsValue = !alternativeWeights ? 1.0f : 2.0f;- auto weights = std::make_shared<op::v0::Constant>(element::f32, Shape{5}, std::vector<float>{weightsValue});+ const uint8_t weightsValue = !alternativeWeights ? 1 : 2;+ auto weights = std::make_shared<op::v0::Constant>(precision, Shape{50000}, std::vector<uint8_t>{weightsValue});auto input = std::make_shared<op::v0::Parameter>(precision, Shape{1});auto add = std::make_shared<op::v1::Add>(input, weights);@@ -122,6 +122,29 @@ public:return model;}+ /**+ * @brief This model was fine-tuned in order to compile fast and yield a light init schedule.+ */+ std::shared_ptr<ov::Model> createTestModelLightInitSchedule() {+ ov::ParameterVector parameter_vector;+ auto data = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::Shape{1});+ parameter_vector.push_back(data);+ auto add_constant = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{50}, {0.5});+ auto add = std::make_shared<ov::op::v1::Add>(data, add_constant);++ for (int i = 0; i < 10; i++) {+ auto intermediate_input = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::Shape{1});+ parameter_vector.push_back(intermediate_input);+ add_constant = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{10, 10, 20, 50}, {i});+ add_constant->get_rt_info()[ov::WeightlessCacheAttribute::get_type_info_static()] =+ ov::WeightlessCacheAttribute(add_constant->get_byte_size(), i, add_constant->get_element_type());+ add = std::make_shared<ov::op::v1::Add>(add, intermediate_input);+ add = std::make_shared<ov::op::v1::Add>(add, add_constant);+ }++ return std::make_shared<ov::Model>(ov::OutputVector{add}, parameter_vector);+ }+Tensor from_stream(std::istream& stream, const size_t size) {ov::Tensor t(element::from<char>(), Shape{size});stream.read(t.data<char>(), size);@@ -442,6 +465,29 @@ TEST_P(WeightsSeparationTests, WeightlessBlobHasPriorityOverCacheModeIfCachingIscreate_infer_request_and_check_result();}+/**+ * @brief The weightless blob should have a smaller size compared to the standard one.+ */+TEST_P(WeightsSeparationTests, WeightlessBlobIsSmaller) {+ model = createTestModelLightInitSchedule();+ std::ostringstream weightfullBlobStream;+ configuration.insert(ov::intel_npu::weightless_blob(false));++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ASSERT_TRUE(compiled_model);+ OV_ASSERT_NO_THROW(compiled_model.export_model(weightfullBlobStream));++ std::ostringstream weightlessBlobStream;+ configuration.at(ov::intel_npu::weightless_blob.name()) = true;++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ASSERT_TRUE(compiled_model);+ OV_ASSERT_NO_THROW(compiled_model.export_model(weightlessBlobStream));++ // At the moment of creating this test, the sizes on platform 3720 are 2019328 vs. 331776+ ASSERT_TRUE(weightfullBlobStream.str().size() > weightlessBlobStream.str().size());+}+using WeightsSeparationOneShotTests = WeightsSeparationTests;/**