MCPcopy Create free account
hub / github.com/apache/arrow / ValidateDeviceInfo

Function ValidateDeviceInfo

cpp/src/arrow/c/bridge.cc:727–757  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

725namespace {
726
727Status 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
759Result<std::pair<std::optional<DeviceAllocationType>, int64_t>> ValidateDeviceInfo(
760 const ArrayData& data) {

Callers

nothing calls this directly

Calls 5

device_idMethod · 0.80
InvalidFunction · 0.50
OKFunction · 0.50
device_typeMethod · 0.45
deviceMethod · 0.45

Tested by

no test coverage detected