| 725 | namespace { |
| 726 | |
| 727 | Status ValidateDeviceInfo(const ArrayData& data, |
| 728 | std::optional<DeviceAllocationType>* device_type, |
| 729 | int64_t* device_id) { |
| 730 | for (const auto& buf : data.buffers) { |
| 731 | if (!buf) { |
| 732 | continue; |
| 733 | } |
| 734 | |
| 735 | if (*device_type == std::nullopt) { |
| 736 | *device_type = buf->device_type(); |
| 737 | *device_id = buf->device()->device_id(); |
| 738 | continue; |
| 739 | } |
| 740 | |
| 741 | if (buf->device_type() != *device_type) { |
| 742 | return Status::Invalid( |
| 743 | "Exporting device array with buffers on more than one device."); |
| 744 | } |
| 745 | |
| 746 | if (buf->device()->device_id() != *device_id) { |
| 747 | return Status::Invalid( |
| 748 | "Exporting device array with buffers on multiple device ids."); |
| 749 | } |
| 750 | } |
| 751 | |
| 752 | for (const auto& child : data.child_data) { |
| 753 | RETURN_NOT_OK(ValidateDeviceInfo(*child, device_type, device_id)); |
| 754 | } |
| 755 | |
| 756 | return Status::OK(); |
| 757 | } |
| 758 | |
| 759 | Result<std::pair<std::optional<DeviceAllocationType>, int64_t>> ValidateDeviceInfo( |
| 760 | const ArrayData& data) { |
nothing calls this directly
no test coverage detected