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



##########
File path: python/tvm/testing.py
##########
@@ -1160,6 +1162,43 @@ def wraps(func):
     return wraps(func)
 
 
+class _DeepCopyAllowedClasses(dict):
+    def __init__(self, *allowed_class_list):

Review comment:
       is there a reason to accept `allowed_class_list` as *args?

##########
File path: python/tvm/testing.py
##########
@@ -1160,6 +1162,43 @@ def wraps(func):
     return wraps(func)
 
 
+class _DeepCopyAllowedClasses(dict):
+    def __init__(self, *allowed_class_list):
+        self.allowed_class_list = allowed_class_list
+        super().__init__()
+
+    def get(self, key, *args, **kwargs):

Review comment:
       could you document this function and how you expect it to be used by 
`deepcopy`?

##########
File path: python/tvm/testing.py
##########
@@ -1160,6 +1162,43 @@ def wraps(func):
     return wraps(func)
 
 
+class _DeepCopyAllowedClasses(dict):
+    def __init__(self, *allowed_class_list):
+        self.allowed_class_list = allowed_class_list
+        super().__init__()
+
+    def get(self, key, *args, **kwargs):
+        obj = ctypes.cast(key, ctypes.py_object).value
+        cls = type(obj)
+        if (
+            cls in copy._deepcopy_dispatch
+            or issubclass(cls, type)
+            or getattr(obj, "__deepcopy__", None)
+            or copyreg.dispatch_table.get(cls)
+            or cls.__reduce__ is not object.__reduce__
+            or cls.__reduce_ex__ is not object.__reduce_ex__
+            or cls in self.allowed_class_list
+        ):
+            return super().get(key, *args, **kwargs)
+
+        rfc_url = (
+            
"https://github.com/apache/tvm-rfcs/blob/main/rfcs/0007-parametrized-unit-tests.md";
+        )
+        raise TypeError(
+            (
+                "Cannot copy fixture of type {}.  TVM fixture caching "

Review comment:
       want to use f-string?




-- 
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.

To unsubscribe, e-mail: [email protected]

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


Reply via email to