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

Method CopySubtreeFrom

tensorflow/compiler/xla/shape_tree.h:646–668  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

644
645template <typename T>
646void ShapeTree<T>::CopySubtreeFrom(const ShapeTree<T>& other,
647 const ShapeIndex& source_base_index,
648 const ShapeIndex& target_base_index) {
649 CHECK(ShapeUtil::Compatible(
650 ShapeUtil::GetSubshape(shape(), target_base_index),
651 ShapeUtil::GetSubshape(other.shape(), source_base_index)));
652 ForEachMutableElement([this, &other, &source_base_index, &target_base_index](
653 const ShapeIndex& index, T* data) {
654 // Copy the data element only if index is in the
655 // subtree rooted at target_base_index.
656 for (int i = 0; i < target_base_index.size(); ++i) {
657 if (i >= index.size() || index[i] != target_base_index[i]) {
658 return;
659 }
660 }
661 // Construct source element index to copy from.
662 ShapeIndex source_index = source_base_index;
663 for (int i = target_base_index.size(); i < index.size(); ++i) {
664 source_index.push_back(index[i]);
665 }
666 *data = other.element(source_index);
667 });
668}
669
670template <typename T>
671StatusOr<ShapeTree<T>> ShapeTree<T>::SubShapeTree(

Callers 6

MakeSubBufferMethod · 0.80
MakeTupleMethod · 0.80
PopulateOutputsMethod · 0.80
SubShapeTreeMethod · 0.80
TEST_FFunction · 0.80

Calls 5

CompatibleClass · 0.85
shapeFunction · 0.50
shapeMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by 1

TEST_FFunction · 0.64