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

Method Broadcast1DTo4D

tensorflow/compiler/xla/reference_util.cc:581–611  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

579}
580
581/* static */ std::unique_ptr<Array4D<float>> ReferenceUtil::Broadcast1DTo4D(
582 const std::vector<float>& array, const std::vector<int64>& bounds,
583 int64 broadcast_from_dim) {
584 auto result = absl::make_unique<Array4D<float>>(bounds[0], bounds[1],
585 bounds[2], bounds[3]);
586 for (int64 i = 0; i < result->n1(); ++i) {
587 for (int64 j = 0; j < result->n2(); ++j) {
588 for (int64 k = 0; k < result->n3(); ++k) {
589 for (int64 l = 0; l < result->n4(); ++l) {
590 switch (broadcast_from_dim) {
591 case 0:
592 (*result)(i, j, k, l) = array[i];
593 break;
594 case 1:
595 (*result)(i, j, k, l) = array[j];
596 break;
597 case 2:
598 (*result)(i, j, k, l) = array[k];
599 break;
600 case 3:
601 (*result)(i, j, k, l) = array[l];
602 break;
603 default:
604 break;
605 }
606 }
607 }
608 }
609 }
610 return result;
611}
612
613/* static */ std::unique_ptr<Array2D<float>> ReferenceUtil::Reduce3DTo2D(
614 const Array3D<float>& array, float init, absl::Span<const int64> dims,

Callers

nothing calls this directly

Calls 4

n4Method · 0.80
n1Method · 0.45
n2Method · 0.45
n3Method · 0.45

Tested by

no test coverage detected