MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Reduce3DTo2D

Method Reduce3DTo2D

tensorflow/compiler/xla/reference_util.cc:613–632  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

611}
612
613/* static */ std::unique_ptr<Array2D<float>> ReferenceUtil::Reduce3DTo2D(
614 const Array3D<float>& array, float init, absl::Span<const int64> dims,
615 const std::function<float(float, float)>& reduce_function) {
616 CHECK_EQ(dims.size(), 1);
617 int64 rows = dims[0] == 0 ? array.n2() : array.n1();
618 int64 cols = dims[0] == 2 ? array.n2() : array.n3();
619 auto result = absl::make_unique<Array2D<float>>(rows, cols);
620 result->Fill(init);
621 for (int i0 = 0; i0 < array.n1(); ++i0) {
622 for (int i1 = 0; i1 < array.n2(); ++i1) {
623 for (int i2 = 0; i2 < array.n3(); ++i2) {
624 int64 row = dims[0] == 0 ? i1 : i0;
625 int64 col = dims[0] == 2 ? i1 : i2;
626 (*result)(row, col) =
627 reduce_function((*result)(row, col), array(i0, i1, i2));
628 }
629 }
630 }
631 return result;
632}
633
634/* static */ std::unique_ptr<Array2D<float>> ReferenceUtil::MapArray2D(
635 const Array2D<float>& matrix,

Callers

nothing calls this directly

Calls 5

sizeMethod · 0.45
n2Method · 0.45
n1Method · 0.45
n3Method · 0.45
FillMethod · 0.45

Tested by

no test coverage detected