| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "zyazeva_s_vector_dot_product/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <cstddef> | ||
| 4 | #include <cstdint> | ||
| 5 | #include <utility> | ||
| 6 | #include <vector> | ||
| 7 | |||
| 8 | #include "zyazeva_s_vector_dot_product/common/include/common.hpp" | ||
| 9 | |||
| 10 | namespace zyazeva_s_vector_dot_product { | ||
| 11 | |||
| 12 | namespace { | ||
| 13 | bool CheckInputValid(const std::vector<std::vector<int32_t>> &input) { | ||
| 14 |
2/2✓ Branch 0 taken 58 times.
✓ Branch 1 taken 8 times.
|
66 | if (input.size() < 2) { |
| 15 | return false; | ||
| 16 | } | ||
| 17 | |||
| 18 | const auto &vector1 = input[0]; | ||
| 19 | const auto &vector2 = input[1]; | ||
| 20 | |||
| 21 |
2/2✓ Branch 0 taken 50 times.
✓ Branch 1 taken 8 times.
|
58 | if (vector1.size() != vector2.size()) { |
| 22 | return false; | ||
| 23 | } | ||
| 24 |
3/4✓ Branch 0 taken 42 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
|
50 | if (vector1.empty() || vector2.empty()) { |
| 25 | return false; | ||
| 26 | } | ||
| 27 | |||
| 28 | return true; | ||
| 29 | } | ||
| 30 | } // namespace | ||
| 31 | |||
| 32 |
1/2✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
|
66 | ZyazevaSVecDotProductSEQ::ZyazevaSVecDotProductSEQ(const InType &in) { |
| 33 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 34 |
1/2✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
|
66 | InType temp = in; |
| 35 | 66 | GetInput() = std::move(temp); | |
| 36 | 66 | GetOutput() = 0; | |
| 37 | 66 | } | |
| 38 | |||
| 39 | 66 | bool ZyazevaSVecDotProductSEQ::ValidationImpl() { | |
| 40 | 66 | return true; | |
| 41 | } | ||
| 42 | |||
| 43 | 66 | bool ZyazevaSVecDotProductSEQ::PreProcessingImpl() { | |
| 44 | 66 | GetOutput() = 0; | |
| 45 | 66 | return true; | |
| 46 | } | ||
| 47 | |||
| 48 |
2/2✓ Branch 0 taken 58 times.
✓ Branch 1 taken 8 times.
|
66 | bool ZyazevaSVecDotProductSEQ::RunImpl() { |
| 49 | auto &input = GetInput(); | ||
| 50 | auto &vec1 = input[0]; | ||
| 51 | auto &vec2 = input[1]; | ||
| 52 | if (!CheckInputValid(input)) { | ||
| 53 | 24 | GetOutput() = 0; | |
| 54 | 24 | return true; | |
| 55 | } | ||
| 56 | |||
| 57 | int64_t dot_product = 0; | ||
| 58 | |||
| 59 |
2/2✓ Branch 0 taken 94 times.
✓ Branch 1 taken 42 times.
|
136 | for (size_t i = 0; i < vec1.size(); i++) { |
| 60 | 94 | dot_product += static_cast<int64_t>(vec1[i]) * static_cast<int64_t>(vec2[i]); | |
| 61 | } | ||
| 62 | |||
| 63 | 42 | GetOutput() = dot_product; | |
| 64 | 42 | return true; | |
| 65 | } | ||
| 66 | |||
| 67 | 66 | bool ZyazevaSVecDotProductSEQ::PostProcessingImpl() { | |
| 68 | 66 | return true; | |
| 69 | } | ||
| 70 | |||
| 71 | } // namespace zyazeva_s_vector_dot_product | ||
| 72 |