Skip to content

Commit 007c23c

Browse files
committed
Apply clang-format to batched scoring element and tests
1 parent e955628 commit 007c23c

4 files changed

Lines changed: 17 additions & 26 deletions

File tree

src/plugins/intel_npu/src/plugin/npuw/llm_compiled_model.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "llm_compiled_model_utils.hpp"
1111
#include "llm_infer_request.hpp"
1212
#include "logging.hpp"
13-
#include "v1/elements/batched.hpp"
1413
#include "moe_transformations/apply_moe_device_routed_transforms.hpp"
1514
#include "npuw_transformations/add_position_ids_param.hpp"
1615
#include "npuw_transformations/convert_kvcache_to_precision.hpp"
@@ -45,6 +44,7 @@
4544
#include "serialization.hpp"
4645
#include "transformations/convert_precision.hpp"
4746
#include "util.hpp"
47+
#include "v1/elements/batched.hpp"
4848
#include "whisper/prepare_whisper_model.hpp"
4949
#include "whisper/whisper_infer_request.hpp"
5050

@@ -1576,8 +1576,8 @@ std::shared_ptr<ov::ISyncInferRequest> ov::npuw::LLMCompiledModel::create_sync_i
15761576
return non_const_this->create_whisper_infer_request();
15771577
}
15781578

1579-
auto inner = m_is_embedding ? non_const_this->create_embedding_infer_request()
1580-
: non_const_this->create_llm_infer_request();
1579+
auto inner =
1580+
m_is_embedding ? non_const_this->create_embedding_infer_request() : non_const_this->create_llm_infer_request();
15811581

15821582
// Batched scoring: wrap the single-sequence request with the batched element so a
15831583
// [N, ...] input is unrolled into N independent [1, ...] inferences (rows are scored

src/plugins/intel_npu/src/plugin/npuw/v1/elements/batched.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ bool has_batch_dim(const ov::SoPtr<ov::ITensor>& tensor) {
2828

2929
} // namespace
3030

31-
ov::SoPtr<ov::ICompiledModel> ov::npuw::batched::CompiledModel::create(
32-
const std::shared_ptr<ov::Model>& model,
33-
const std::shared_ptr<const ov::IPlugin>& plugin,
34-
ov::SoPtr<ov::ICompiledModel> inner_compiled,
35-
bool enabled) {
31+
ov::SoPtr<ov::ICompiledModel> ov::npuw::batched::CompiledModel::create(const std::shared_ptr<ov::Model>& model,
32+
const std::shared_ptr<const ov::IPlugin>& plugin,
33+
ov::SoPtr<ov::ICompiledModel> inner_compiled,
34+
bool enabled) {
3635
OPENVINO_ASSERT(inner_compiled._ptr != nullptr, "Batched compiled model requires an inner compiled model");
3736

3837
// No-op wrapper: hand back the inner model unchanged for the zero-overhead path.

src/plugins/intel_npu/tests/unit/npuw/batched_element_test.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ class MockState : public ov::IVariableState {
6060
std::shared_ptr<Recorder> m_rec;
6161
};
6262

63-
ov::Output<const ov::Node> port_named(const std::vector<ov::Output<const ov::Node>>& ports,
64-
const std::string& needle) {
63+
ov::Output<const ov::Node> port_named(const std::vector<ov::Output<const ov::Node>>& ports, const std::string& needle) {
6564
for (const auto& port : ports) {
6665
if (port.get_any_name().find(needle) != std::string::npos) {
6766
return port;
@@ -253,8 +252,7 @@ TEST_F(NPUWBatchedElementTest, EachRowScoredIndependentlyAndStacked) {
253252
}
254253

255254
// One inner inference per row, each preceded by a state reset, in order.
256-
EXPECT_EQ(m_recorder->events,
257-
(std::vector<std::string>{"reset", "infer", "reset", "infer", "reset", "infer"}));
255+
EXPECT_EQ(m_recorder->events, (std::vector<std::string>{"reset", "infer", "reset", "infer", "reset", "infer"}));
258256
}
259257

260258
TEST_F(NPUWBatchedElementTest, SingleRowScored) {
@@ -325,8 +323,7 @@ TEST_F(NPUWBatchedElementTest, SyncInnerConstructorScoresEachRow) {
325323
for (std::size_t r = 0; r < ids.size(); ++r) {
326324
EXPECT_FLOAT_EQ(row_value(out, r), static_cast<float>(ids[r].front())) << "output row " << r;
327325
}
328-
EXPECT_EQ(m_recorder->events,
329-
(std::vector<std::string>{"reset", "infer", "reset", "infer", "reset", "infer"}));
326+
EXPECT_EQ(m_recorder->events, (std::vector<std::string>{"reset", "infer", "reset", "infer", "reset", "infer"}));
330327
}
331328

332329
// A shared/broadcast input (batch 1) is fed to every row unsliced -- the slice guard only fires
@@ -346,8 +343,7 @@ TEST_F(NPUWBatchedElementTest, BroadcastInputSharedAcrossRows) {
346343
for (std::size_t r = 0; r < ids.size(); ++r) {
347344
EXPECT_FLOAT_EQ(row_value(out, r), static_cast<float>(ids[r].front())) << "output row " << r;
348345
}
349-
EXPECT_EQ(m_recorder->events,
350-
(std::vector<std::string>{"reset", "infer", "reset", "infer", "reset", "infer"}));
346+
EXPECT_EQ(m_recorder->events, (std::vector<std::string>{"reset", "infer", "reset", "infer", "reset", "infer"}));
351347
}
352348

353349
// Regression: a leading batch-1 input (here input_ids, shared) must not pin the batch to 1 when a
@@ -367,8 +363,7 @@ TEST_F(NPUWBatchedElementTest, BatchSizeFromNonLeadingInput) {
367363
for (std::size_t r = 0; r < 3; ++r) {
368364
EXPECT_FLOAT_EQ(row_value(out, r), 7.0f) << "output row " << r; // input_ids broadcast to every row
369365
}
370-
EXPECT_EQ(m_recorder->events,
371-
(std::vector<std::string>{"reset", "infer", "reset", "infer", "reset", "infer"}));
366+
EXPECT_EQ(m_recorder->events, (std::vector<std::string>{"reset", "infer", "reset", "infer", "reset", "infer"}));
372367
}
373368

374369
// Each model output is stacked into its own [N, ...] tensor. The mock offsets output k by k, so the
@@ -393,8 +388,7 @@ TEST_F(NPUWBatchedElementTest, MultipleOutputsStackedIndependently) {
393388
EXPECT_FLOAT_EQ(row_value(score, r), static_cast<float>(ids[r].front()));
394389
EXPECT_FLOAT_EQ(row_value(hidden, r), static_cast<float>(ids[r].front()) + kOutputChannelOffset);
395390
}
396-
EXPECT_EQ(m_recorder->events,
397-
(std::vector<std::string>{"reset", "infer", "reset", "infer", "reset", "infer"}));
391+
EXPECT_EQ(m_recorder->events, (std::vector<std::string>{"reset", "infer", "reset", "infer", "reset", "infer"}));
398392
}
399393

400394
} // namespace

src/plugins/intel_npu/tests/unit/npuw/llm_test_helpers.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ inline std::shared_ptr<ov::Model> build_dynamic_attention_llm_model() {
6969
for (const auto& input : model->inputs()) {
7070
const auto& name = input.get_any_name();
7171
const auto& pshape = input.get_partial_shape();
72-
if (name.find("input_ids") != std::string::npos ||
73-
name.find("token_type_ids") != std::string::npos) {
72+
if (name.find("input_ids") != std::string::npos || name.find("token_type_ids") != std::string::npos) {
7473
new_shapes[name] = ov::PartialShape{1, kSeq};
7574
} else if (name.find("attention_mask") != std::string::npos) {
7675
new_shapes[name] = ov::PartialShape{1, kSeq + kPast};
@@ -129,8 +128,7 @@ inline std::shared_ptr<ov::Model> build_llm_test_model_with_kv_fake_convert(cons
129128
auto inject_fake_convert = [&](size_t input_idx, const std::string& suffix) {
130129
auto fake_convert_1 =
131130
std::make_shared<ov::op::v13::FakeConvert>(sdpa->input_value(input_idx), scale, fake_convert_type);
132-
auto fake_convert_2 =
133-
std::make_shared<ov::op::v13::FakeConvert>(fake_convert_1, scale, fake_convert_type);
131+
auto fake_convert_2 = std::make_shared<ov::op::v13::FakeConvert>(fake_convert_1, scale, fake_convert_type);
134132
fake_convert_1->set_friendly_name(sdpa->get_friendly_name() + "/" + suffix + "_1");
135133
fake_convert_2->set_friendly_name(sdpa->get_friendly_name() + "/" + suffix + "_2");
136134
sdpa->input(input_idx).replace_source_output(fake_convert_2);
@@ -280,8 +278,8 @@ class MockSubCompiledModel : public ov::npuw::ICompiledModel_v0 {
280278
};
281279

282280
struct CompileCall {
283-
std::string friendly_name;
284-
ov::AnyMap props;
281+
std::string friendly_name;
282+
ov::AnyMap props;
285283
std::shared_ptr<ov::Model> model;
286284
};
287285

0 commit comments

Comments
 (0)