From e5f18145430228ebd2a8441abf5be8b1d78f5a7f Mon Sep 17 00:00:00 2001 From: Yanxing Shi <48111042+Yanxing-Shi@users.noreply.github.com> Date: Mon, 8 Nov 2021 10:33:53 +0800 Subject: [PATCH] Initial Commit fix (#36988) --- paddle/fluid/pybind/pybind.cc | 42 +++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/paddle/fluid/pybind/pybind.cc b/paddle/fluid/pybind/pybind.cc index 6c4ba10e90e..c3b25671468 100644 --- a/paddle/fluid/pybind/pybind.cc +++ b/paddle/fluid/pybind/pybind.cc @@ -2393,23 +2393,31 @@ All parameter, weight, gradient are variables in Paddle. py::return_value_policy::copy); py::class_(m, "_gpuDeviceProperties") - .def_readonly("name", &gpuDeviceProp::name) - .def_readonly("major", &gpuDeviceProp::major) - .def_readonly("minor", &gpuDeviceProp::minor) - .def_readonly("is_multi_gpu_board", &gpuDeviceProp::isMultiGpuBoard) - .def_readonly("is_integrated", &gpuDeviceProp::integrated) - .def_readonly("multi_processor_count", - &gpuDeviceProp::multiProcessorCount) - .def_readonly("total_memory", &gpuDeviceProp::totalGlobalMem) - .def("__repr__", [](const gpuDeviceProp &gpu_device_prop) { - std::ostringstream stream; - stream << "_gpuDeviceProperties(name='" << gpu_device_prop.name - << "', major=" << gpu_device_prop.major - << ", minor=" << gpu_device_prop.minor << ", total_memory=" - << gpu_device_prop.totalGlobalMem / (1024 * 1024) - << "MB, multi_processor_count=" - << gpu_device_prop.multiProcessorCount << ")"; - return stream.str(); + .def_property_readonly( + "name", [](const gpuDeviceProp &prop) { return prop.name; }) + .def_property_readonly( + "major", [](const gpuDeviceProp &prop) { return prop.major; }) + .def_property_readonly( + "minor", [](const gpuDeviceProp &prop) { return prop.minor; }) + .def_property_readonly( + "total_memory", + [](const gpuDeviceProp &prop) { return prop.totalGlobalMem; }) + .def_property_readonly( + "multi_processor_count", + [](const gpuDeviceProp &prop) { return prop.multiProcessorCount; }) + .def_property_readonly( + "is_multi_gpu_board", + [](const gpuDeviceProp &prop) { return prop.isMultiGpuBoard; }) + .def_property_readonly( + "is_integrated", + [](const gpuDeviceProp &prop) { return prop.integrated; }) + .def("__repr__", [](const gpuDeviceProp &prop) { + std::stringstream ostr; + ostr << "_gpuDeviceProperties(name='" << prop.name + << "', major=" << prop.major << ", minor=" << prop.minor + << ", total_memory=" << prop.totalGlobalMem / (1024 * 1024) + << "MB, multi_processor_count=" << prop.multiProcessorCount << ")"; + return ostr.str(); }); #if !defined(PADDLE_WITH_HIP) && !defined(_WIN32) -- GitLab