static */
| 502 | } |
| 503 | |
| 504 | /* static */ std::unique_ptr<std::vector<float>> |
| 505 | ReferenceUtil::ReduceToColArray2D( |
| 506 | const Array2D<float>& matrix, float init, |
| 507 | const std::function<float(float, float)>& reduce_function) { |
| 508 | int64 rows = matrix.height(); |
| 509 | int64 cols = matrix.width(); |
| 510 | auto result = absl::make_unique<std::vector<float>>(); |
| 511 | for (int64 i = 0; i < rows; ++i) { |
| 512 | float acc = init; |
| 513 | for (int64 j = 0; j < cols; ++j) { |
| 514 | acc = reduce_function(acc, matrix(i, j)); |
| 515 | } |
| 516 | result->push_back(acc); |
| 517 | } |
| 518 | return result; |
| 519 | } |
| 520 | |
| 521 | /* static */ std::unique_ptr<std::vector<float>> |
| 522 | ReferenceUtil::ReduceToRowArray2D( |