| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "smyshlaev_a_mat_mul/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <cstddef> | ||
| 4 | #include <vector> | ||
| 5 | |||
| 6 | #include "smyshlaev_a_mat_mul/common/include/common.hpp" | ||
| 7 | |||
| 8 | namespace smyshlaev_a_mat_mul { | ||
| 9 | |||
| 10 |
1/2✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
|
96 | SmyshlaevAMatMulSEQ::SmyshlaevAMatMulSEQ(const InType &in) { |
| 11 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 12 | GetInput() = in; | ||
| 13 | 96 | } | |
| 14 | |||
| 15 | 96 | bool SmyshlaevAMatMulSEQ::ValidationImpl() { | |
| 16 | const auto &num_rows_a = std::get<0>(GetInput()); | ||
| 17 | const auto &mat_a = std::get<1>(GetInput()); | ||
| 18 | const auto &num_rows_b = std::get<2>(GetInput()); | ||
| 19 | const auto &mat_b = std::get<3>(GetInput()); | ||
| 20 | |||
| 21 |
2/4✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
|
96 | if (num_rows_a <= 0 || num_rows_b <= 0) { |
| 22 | return false; | ||
| 23 | } | ||
| 24 | |||
| 25 |
2/4✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
|
96 | if (mat_a.empty() || mat_b.empty()) { |
| 26 | return false; | ||
| 27 | } | ||
| 28 | |||
| 29 |
2/4✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
|
96 | if (mat_a.size() % num_rows_a != 0 || mat_b.size() % num_rows_b != 0) { |
| 30 | return false; | ||
| 31 | } | ||
| 32 | |||
| 33 | 96 | const auto &num_cols_a = static_cast<int>(mat_a.size()) / num_rows_a; | |
| 34 | 96 | return (num_cols_a == num_rows_b); | |
| 35 | } | ||
| 36 | |||
| 37 | 96 | bool SmyshlaevAMatMulSEQ::PreProcessingImpl() { | |
| 38 | 96 | return true; | |
| 39 | } | ||
| 40 | |||
| 41 | 96 | bool SmyshlaevAMatMulSEQ::RunImpl() { | |
| 42 | const auto &num_rows_a = std::get<0>(GetInput()); | ||
| 43 | const auto &mat_a = std::get<1>(GetInput()); | ||
| 44 | const auto &num_rows_b = std::get<2>(GetInput()); | ||
| 45 | const auto &mat_b = std::get<3>(GetInput()); | ||
| 46 | |||
| 47 | 96 | const auto &num_cols_b = static_cast<int>(mat_b.size()) / num_rows_b; | |
| 48 | const auto &num_cols_a = num_rows_b; | ||
| 49 | |||
| 50 | 96 | std::vector<double> result(static_cast<size_t>(num_rows_a) * num_cols_b, 0.0); | |
| 51 | |||
| 52 |
2/2✓ Branch 0 taken 616 times.
✓ Branch 1 taken 96 times.
|
712 | for (int i = 0; i < num_rows_a; ++i) { |
| 53 |
2/2✓ Branch 0 taken 9792 times.
✓ Branch 1 taken 616 times.
|
10408 | for (int j = 0; j < num_cols_b; ++j) { |
| 54 | double sum = 0.0; | ||
| 55 |
2/2✓ Branch 0 taken 272880 times.
✓ Branch 1 taken 9792 times.
|
282672 | for (int k = 0; k < num_cols_a; ++k) { |
| 56 | 272880 | sum += mat_a[(i * num_cols_a) + k] * mat_b[(k * num_cols_b) + j]; | |
| 57 | } | ||
| 58 | 9792 | result[(i * num_cols_b) + j] = sum; | |
| 59 | } | ||
| 60 | } | ||
| 61 | |||
| 62 |
1/2✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
|
96 | GetOutput() = result; |
| 63 | 96 | return true; | |
| 64 | } | ||
| 65 | |||
| 66 | 96 | bool SmyshlaevAMatMulSEQ::PostProcessingImpl() { | |
| 67 | 96 | return true; | |
| 68 | } | ||
| 69 | |||
| 70 | } // namespace smyshlaev_a_mat_mul | ||
| 71 |