GCC Code Coverage Report


Directory: ./
File: tasks/perepelkin_i_matrix_mult_horizontal_strip_only_a/seq/src/ops_seq.cpp
Date: 2026-01-27 01:59:34
Exec Total Coverage
Lines: 36 36 100.0%
Functions: 5 5 100.0%
Branches: 23 30 76.7%

Line Branch Exec Source
1 #include "perepelkin_i_matrix_mult_horizontal_strip_only_a/seq/include/ops_seq.hpp"
2
3 #include <cstddef>
4 #include <functional>
5 #include <numeric>
6 #include <vector>
7
8 #include "perepelkin_i_matrix_mult_horizontal_strip_only_a/common/include/common.hpp"
9
10 namespace perepelkin_i_matrix_mult_horizontal_strip_only_a {
11
12
1/2
✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
128 PerepelkinIMatrixMultHorizontalStripOnlyASEQ::PerepelkinIMatrixMultHorizontalStripOnlyASEQ(const InType &in) {
13 SetTypeOfTask(GetStaticTypeOfTask());
14 GetInput() = in;
15 128 GetOutput() = std::vector<std::vector<double>>();
16 128 }
17
18
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 bool PerepelkinIMatrixMultHorizontalStripOnlyASEQ::ValidationImpl() {
19 const auto &[matrix_a, matrix_b] = GetInput();
20
21
2/4
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
128 if (matrix_a.empty() || matrix_b.empty()) {
22 return false;
23 }
24
25 const size_t width_a = matrix_a[0].size();
26 const size_t width_b = matrix_b[0].size();
27 const size_t height_b = matrix_b.size();
28
29
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if (width_a != height_b) {
30 return false;
31 }
32
33
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 128 times.
328 for (size_t i = 1; i < matrix_a.size(); i++) {
34
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if (matrix_a[i].size() != width_a) {
35 return false;
36 }
37 }
38
39
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 128 times.
328 for (size_t i = 1; i < matrix_b.size(); i++) {
40
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if (matrix_b[i].size() != width_b) {
41 return false;
42 }
43 }
44
45 128 return GetOutput().empty();
46 }
47
48 128 bool PerepelkinIMatrixMultHorizontalStripOnlyASEQ::PreProcessingImpl() {
49 const auto &[matrix_a, matrix_b] = GetInput();
50
51 // Store original sizes
52 128 height_a_ = matrix_a.size();
53 128 height_b_ = matrix_b.size();
54 128 width_a_ = matrix_a[0].size();
55 128 width_b_ = matrix_b[0].size();
56
57 // Flatten matrix A
58 128 flat_a_.reserve(width_a_ * height_a_);
59
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 128 times.
456 for (const auto &row : matrix_a) {
60 328 flat_a_.insert(flat_a_.end(), row.begin(), row.end());
61 }
62
63 // Create transposed-and-flattened matrix B
64 128 flat_b_t_.resize(width_b_ * height_b_);
65
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 128 times.
456 for (size_t row = 0; row < height_b_; row++) {
66
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 328 times.
1120 for (size_t col = 0; col < width_b_; col++) {
67 792 flat_b_t_[(col * height_b_) + row] = matrix_b[row][col];
68 }
69 }
70
71 128 return true;
72 }
73
74 128 bool PerepelkinIMatrixMultHorizontalStripOnlyASEQ::RunImpl() {
75 auto &output = GetOutput();
76 128 output.resize(height_a_);
77
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 128 times.
456 for (auto &row : output) {
78 328 row.resize(width_b_);
79 }
80
81
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 128 times.
456 for (size_t i = 0; i < height_a_; ++i) {
82 328 const auto a_it = flat_a_.begin() + static_cast<DiffT>(i * width_a_);
83 const auto a_end = a_it + static_cast<DiffT>(width_a_);
84
2/2
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 328 times.
1144 for (size_t j = 0; j < width_b_; ++j) {
85 816 const auto b_it = flat_b_t_.begin() + static_cast<DiffT>(j * width_a_);
86 816 output[i][j] = std::transform_reduce(a_it, a_end, b_it, 0.0, std::plus<>(), std::multiplies<>());
87 }
88 }
89
90 128 return true;
91 }
92
93 128 bool PerepelkinIMatrixMultHorizontalStripOnlyASEQ::PostProcessingImpl() {
94 128 return true;
95 }
96
97 } // namespace perepelkin_i_matrix_mult_horizontal_strip_only_a
98