Repository: taichi-dev/taichi (language: python)

Issue:
[aot] Kernel launch doesn't check dtype of numpy arrays
```python
import numpy as np
import taichi as ti

ti.init(ti.metal)

@ti.kernel
def arange(x: ti.types.ndarray(ti.i32, ndim=1)):
    for i in x:
        x[i] = i

xx = np.array([1, 2, 3, 4, 5]) # by default it's int64
arange(xx) # Crash!

xx = np.array([1, 2, 3, 4, 5], dtype=np.int32)
arange(xx)
```


Discussion / hints:

Fix patch:
diff --git a/taichi/rhi/metal/metal_device.mm b/taichi/rhi/metal/metal_device.mm
index 904c75d1b2028..7f95042ae0aa9 100644
--- a/taichi/rhi/metal/metal_device.mm
+++ b/taichi/rhi/metal/metal_device.mm
@@ -82,6 +82,11 @@
     // Subgroups are only supported in Metal 2.1 and up.
     options.set_msl_version(2, 1, 0);
   }
+  bool feature_64_bit_integer_math =
+      caps.contains(DeviceCapability::spirv_has_int64);
+  if (feature_64_bit_integer_math) {
+    options.set_msl_version(2, 3, 0);
+  }
 
   compiler.set_msl_options(options);
 


Test patch:
diff --git a/tests/python/test_numpy.py b/tests/python/test_numpy.py
index 63ac8faed0159..87799eb663924 100644
--- a/tests/python/test_numpy.py
+++ b/tests/python/test_numpy.py
@@ -38,6 +38,17 @@ def test_numpy_f64():
     with_data_type(np.float64)
 
 
+@test_utils.test(arch=ti.metal)
+def test_np_i64_metal():
+    @ti.kernel
+    def arange(x: ti.types.ndarray(ti.i64, ndim=1)):
+        for i in x:
+            x[i] = i
+
+    xx = np.array([1, 2, 3, 4, 5])  # by default it's int64
+    arange(xx)
+
+
 @test_utils.test()
 def test_numpy_i32():
     with_data_type(np.int32)