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

Method Add

tensorflow/compiler/xla/service/heap_simulator.cc:604–633  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

602using Chunk = HeapSimulator::Chunk;
603
604void BufferIntervalTree::Add(int64 start, int64 end, const Chunk& chunk) {
605 node_storage_.emplace_back(BufferIntervalTreeNode{
606 start, end, end, chunk,
607 /*left=*/nullptr, /*right=*/nullptr, /*parent=*/nullptr});
608 if (root_ == nullptr) {
609 root_ = &node_storage_.back();
610 // This is root.
611 return;
612 }
613
614 BufferIntervalTreeNode* parent = root_;
615 while (true) {
616 parent->subtree_end = std::max(parent->subtree_end, end);
617 if (parent->start > start) {
618 if (parent->left == nullptr) {
619 parent->left = &node_storage_.back();
620 node_storage_.back().parent = parent;
621 return;
622 }
623 parent = parent->left;
624 } else {
625 if (parent->right == nullptr) {
626 parent->right = &node_storage_.back();
627 node_storage_.back().parent = parent;
628 return;
629 }
630 parent = parent->right;
631 }
632 }
633}
634
635bool BufferIntervalTree::Remove(int64 start, int64 end, const Chunk& chunk) {
636 BufferIntervalTreeNode* to_delete = root_;

Calls 3

maxFunction · 0.50
emplace_backMethod · 0.45
backMethod · 0.45