static */
| 519 | } |
| 520 | |
| 521 | /* static */ std::unique_ptr<std::vector<float>> |
| 522 | ReferenceUtil::ReduceToRowArray2D( |
| 523 | const Array2D<float>& matrix, float init, |
| 524 | const std::function<float(float, float)>& reduce_function) { |
| 525 | int64 rows = matrix.height(); |
| 526 | int64 cols = matrix.width(); |
| 527 | auto result = absl::make_unique<std::vector<float>>(); |
| 528 | for (int64 i = 0; i < cols; ++i) { |
| 529 | float acc = init; |
| 530 | for (int64 j = 0; j < rows; ++j) { |
| 531 | acc = reduce_function(acc, matrix(j, i)); |
| 532 | } |
| 533 | result->push_back(acc); |
| 534 | } |
| 535 | return result; |
| 536 | } |
| 537 | |
| 538 | /*static*/ std::vector<float> ReferenceUtil::Reduce4DTo1D( |
| 539 | const Array4D<float>& array, float init, absl::Span<const int64> dims, |