areusch commented on a change in pull request #7867:
URL: https://github.com/apache/tvm/pull/7867#discussion_r616170835



##########
File path: src/runtime/opencl/opencl_device_api.cc
##########
@@ -72,20 +75,26 @@ void OpenCLWorkspace::GetAttr(Device dev, DeviceAttrKind 
kind, TVMRetValue* rv)
       *rv = static_cast<int64_t>(value);
       break;
     }
-    case kComputeVersion:
-      return;
-    case kDeviceName: {
-      char value[128] = {0};
-      OPENCL_CALL(
-          clGetDeviceInfo(devices[index], CL_DEVICE_NAME, sizeof(value) - 1, 
value, nullptr));
-      *rv = std::string(value);
+    case kComputeVersion: {
+      std::string ret = GetDeviceInfo(devices[index], CL_DEVICE_VERSION);
+      // String returned is "OpenCL $MAJOR.$MINOR $VENDOR_INFO".  To
+      // match other implementations, we want to return "$MAJOR.$MINOR"
+      const size_t version_start = 7;

Review comment:
       why is it 7?

##########
File path: src/runtime/opencl/opencl_device_api.cc
##########
@@ -72,20 +75,26 @@ void OpenCLWorkspace::GetAttr(Device dev, DeviceAttrKind 
kind, TVMRetValue* rv)
       *rv = static_cast<int64_t>(value);
       break;
     }
-    case kComputeVersion:
-      return;
-    case kDeviceName: {
-      char value[128] = {0};
-      OPENCL_CALL(
-          clGetDeviceInfo(devices[index], CL_DEVICE_NAME, sizeof(value) - 1, 
value, nullptr));
-      *rv = std::string(value);
+    case kComputeVersion: {
+      std::string ret = GetDeviceInfo(devices[index], CL_DEVICE_VERSION);
+      // String returned is "OpenCL $MAJOR.$MINOR $VENDOR_INFO".  To
+      // match other implementations, we want to return "$MAJOR.$MINOR"

Review comment:
       hmm, this seems a bit like a breaking change. should we just document 
that the version string always starts with "major.minor" and may be 
backend-specific?

##########
File path: python/tvm/_ffi/runtime_ctypes.py
##########
@@ -262,6 +264,35 @@ def max_thread_dimensions(self):
         """
         return json.loads(self._GetDeviceAttr(self.device_type, 
self.device_id, 8))
 
+    @property
+    def api_version(self):
+        """Returns version number of the SDK used to compile TVM.
+
+        For example, CUDA_VERSION for cuda or VK_HEADER_VERSION for
+        Vulkan.
+
+        Returns
+        -------
+        version : int
+            The version of the SDK
+
+        """
+        return self._GetDeviceAttr(self.device_type, self.device_id, 12)
+
+    @property
+    def driver_version(self):
+        """Returns version number of the driver
+
+        Returns driver vendor's internal version number.
+        (e.g. "450.408.256" for nvidia-driver-450)
+
+        Returns
+        -------
+        version : str

Review comment:
       could you be more explicit in the docstring? imo, "Implemented for 
opencl and vulkan" would read to a Python developer as "raises 
NotImplementedError when not opencl or vulkan"




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to