-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathops_seq.cpp
More file actions
42 lines (35 loc) · 1.27 KB
/
ops_seq.cpp
File metadata and controls
42 lines (35 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "seq/example/include/ops_seq.hpp"
#include <cmath>
#include <cstddef>
#include <vector>
bool nesterov_a_test_task_seq::TestTaskSequential::PreProcessingImpl() {
// Init value for input and output
unsigned int input_size = task_data->inputs_count[0];
auto *in_ptr = reinterpret_cast<int *>(task_data->inputs[0]);
input_ = std::vector<int>(in_ptr, in_ptr + input_size);
unsigned int output_size = task_data->outputs_count[0];
output_ = std::vector<int>(output_size, 0);
rc_size_ = static_cast<int>(std::sqrt(input_size));
return true;
}
bool nesterov_a_test_task_seq::TestTaskSequential::ValidationImpl() {
// Check equality of counts elements
return task_data->inputs_count[0] == task_data->outputs_count[0];
}
bool nesterov_a_test_task_seq::TestTaskSequential::RunImpl() {
// Multiply matrices
for (int i = 0; i < rc_size_; ++i) {
for (int j = 0; j < rc_size_; ++j) {
for (int k = 0; k < rc_size_; ++k) {
output_[(i * rc_size_) + j] += input_[(i * rc_size_) + k] * input_[(k * rc_size_) + j];
}
}
}
return true;
}
bool nesterov_a_test_task_seq::TestTaskSequential::PostProcessingImpl() {
for (size_t i = 0; i < output_.size(); i++) {
reinterpret_cast<int *>(task_data->outputs[0])[i] = output_[i];
}
return true;
}