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

Method ToDeviceMemoryTree

tensorflow/compiler/xrt/xrt_state.cc:641–662  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

639}
640
641xla::StatusOr<xla::ShapeTree<xla::MaybeOwningDeviceMemory>>
642XRTTupleAllocation::ToDeviceMemoryTree(
643 const std::function<bool(const xla::ShapeIndex&)>& release_checker) {
644 xla::ShapeTree<xla::MaybeOwningDeviceMemory> shaped_tree(on_device_shape());
645 for (const auto& index_buffer : buffers_) {
646 if (index_buffer.second == nullptr ||
647 index_buffer.second->allocation().is_null()) {
648 return errors::InvalidArgument("Literal buffer at index ",
649 index_buffer.first.ToString(),
650 " has been released");
651 }
652 if (!release_checker(index_buffer.first)) {
653 *shaped_tree.mutable_element(index_buffer.first) =
654 index_buffer.second->allocation();
655 } else {
656 // We keep the ownership of the device memory here.
657 *shaped_tree.mutable_element(index_buffer.first) = se::OwningDeviceMemory(
658 index_buffer.second->allocation(), device_ordinal_, allocator_);
659 }
660 }
661 return std::move(shaped_tree);
662}
663
664} // namespace tensorflow

Callers

nothing calls this directly

Calls 5

InvalidArgumentFunction · 0.85
is_nullMethod · 0.45
allocationMethod · 0.45
ToStringMethod · 0.45
mutable_elementMethod · 0.45

Tested by

no test coverage detected