[ghstack-poisoned]
This commit is contained in:
Yu, Guangye
2025-11-10 19:12:58 +00:00
parent 711d82c24b
commit 0f132dedaf

View File

@ -296,13 +296,12 @@ static void registerXpuDeviceProperties(PyObject* module) {
};
#endif
auto m = py::handle(module).cast<py::module>();
// Wrapper class for XPU UUID
struct XPUuuid {
XPUuuid(const std::array<unsigned char, 16>& uuid) : bytes(uuid) {}
const std::array<unsigned char, 16> bytes;
const std::array<unsigned char, 16>& bytes{};
};
auto m = py::handle(module).cast<py::module>();
py::class_<XPUuuid>(m, "_XPUuuid")
.def_property_readonly(
@ -347,10 +346,7 @@ static void registerXpuDeviceProperties(PyObject* module) {
.def_property_readonly("type", get_device_type)
.def_property_readonly(
"uuid",
[](const DeviceProp& prop) -> XPUuuid {
XPUuuid uuid(prop.uuid);
return uuid;
})
[](const DeviceProp& prop) -> XPUuuid { return XPUuuid(prop.uuid); })
.def(
"__repr__",
[&get_device_type, &gpu_subslice_count](const DeviceProp& prop) {
@ -358,10 +354,9 @@ static void registerXpuDeviceProperties(PyObject* module) {
stream << "_XpuDeviceProperties(name='" << prop.name
<< "', platform_name='" << prop.platform_name << "', type='"
<< get_device_type(prop) << "', device_id=0x" << std::hex
<< std::uppercase << prop.device_id << std::dec
<< ", uuid="
// << uuid_to_string(
// reinterpret_cast<const char*>(prop.uuid.data()))
<< std::uppercase << prop.device_id << std::dec << ", uuid="
<< uuid_to_string(
reinterpret_cast<const char*>(prop.uuid.data()))
<< ", driver_version='" << prop.driver_version
<< "', total_memory="
<< prop.global_mem_size / (1024ull * 1024) << "MB"