static */
| 662 | } |
| 663 | |
| 664 | /* static */ std::unique_ptr<Array2D<float>> ReferenceUtil::MapWithIndexArray2D( |
| 665 | const Array2D<float>& matrix, |
| 666 | const std::function<float(float, int64, int64)>& map_function) { |
| 667 | int64 rows = matrix.height(); |
| 668 | int64 cols = matrix.width(); |
| 669 | auto result = absl::make_unique<Array2D<float>>(rows, cols); |
| 670 | for (int64 i = 0; i < rows; ++i) { |
| 671 | for (int64 j = 0; j < cols; ++j) { |
| 672 | (*result)(i, j) = map_function(matrix(i, j), i, j); |
| 673 | } |
| 674 | } |
| 675 | return result; |
| 676 | } |
| 677 | |
| 678 | } // namespace xla |