From 55cdda69e6a3cfc88bef0eb7319cfe304bb3cad9 Mon Sep 17 00:00:00 2001 From: Berk Geveci Date: Sat, 5 Dec 2026 09:08:09 -0800 Subject: [PATCH] test_array_views: compare Level Zero's ctypes pointers by value _same_view compared each buffer attribute with == or is. Level Zero's _device_ptr is a ctypes.c_void_p, which compares by identity, so two views of the same memory failed test_many_views_at_once_are_the_views_one_at_a_time on level_zero (all five kinds) although their addresses were equal. --- packages/tack-core/tests/test_array_views.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/tack-core/tests/test_array_views.py b/packages/tack-core/tests/test_array_views.py index 2b6083cb8..c89aa4bcb 100644 --- a/packages/tack-core/tests/test_array_views.py +++ b/packages/tack-core/tests/test_array_views.py @@ -11,6 +11,7 @@ DLPack; and to writing only its own rows. """ +import ctypes import gc import numpy as np @@ -146,6 +147,8 @@ def _same_view(a, b): assert x.__array_interface__ == y.__array_interface__, k elif hasattr(x, "ptr"): # Warp's array over the view's memory assert (x.ptr, x.shape, x.dtype) == (y.ptr, y.shape, y.dtype), k + elif isinstance(x, ctypes.c_void_p): # Level Zero's pointer: ctypes compares by identity + assert type(y) is ctypes.c_void_p and x.value == y.value, k elif k != "_view": # Metal's NumPy view of its memory assert x == y or x is y, k