Skip to content

[Fix] Fix numpy dtype map - #16780

Merged
tqchen merged 1 commit into
apache:mainfrom
MasterJH5574:tvm-dev/2024-03-24-np-dtype
Mar 25, 2024
Merged

tqchen merged 1 commit into
apache:mainfrom
MasterJH5574:tvm-dev/2024-03-24-np-dtype

Conversation

@MasterJH5574

Copy link
Copy Markdown
Contributor

NumPy 2.0 removes the dtype np.float_, which may introduces compatibility issue for TVM.

NumPy 2.0 removes the dtype `np.float_`, which may introduces
compatibility issue for TVM.
@mshr-h

mshr-h commented Mar 25, 2024

Copy link
Copy Markdown
Contributor

I think this is better.

-    if np.__version__.startswith("1."):
-        NUMPY2STR[np.dtype(np.float_)] = "float64"
+    if hasattr(np, "float_"):
+        NUMPY2STR[np.dtype(np.float_)] = "float64"

@mshr-h

mshr-h commented Mar 25, 2024

Copy link
Copy Markdown
Contributor

This is more Pythonic?

-    if np.__version__.startswith("1."):
-        NUMPY2STR[np.dtype(np.float_)] = "float64"
+ try:
+     NUMPY2STR[np.dtype(np.float_)] = "float64"
+ except AttributeError:
+     pass

LBYL

@tqchen
tqchen merged commit b3981d2 into apache:main Mar 25, 2024
@MasterJH5574

Copy link
Copy Markdown
Contributor Author

@mshr-h Thank you for the great suggestion! I agree that the way I was doing might not be the best. Feel free to send the change you propose.

thaisacs pushed a commit to thaisacs/tvm that referenced this pull request Apr 3, 2024
NumPy 2.0 removes the dtype `np.float_`, which may introduces
compatibility issue for TVM.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants