Skip to content

Commit 3565b9b

Browse files
Use Python implementation for AdvancedInSubtensor1
MapIter was removed from the public numpy C-API in version 2.0, so we raise a not implemented error to default to the python code for the AdvancedInSubtensor1. The python version, defined in `AdvancedInSubtensor1.perform` calls `np.add.at`, which uses `MapIter` behind the scenes. There is active development on Numpy to improve the efficiency of `np.add.at`. To skip the C implementation and use the Python implementation, we raise a NotImplementedError for this op's c code if numpy>=2.0.
1 parent 165e7e4 commit 3565b9b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

pytensor/tensor/subtensor.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2522,6 +2522,9 @@ def c_code(self, node, name, input_names, output_names, sub):
25222522
numpy_ver = [int(n) for n in np.__version__.split(".")[:2]]
25232523
if bool(numpy_ver < [1, 8]):
25242524
raise NotImplementedError
2525+
if bool(numpy_ver >= [2, 0]):
2526+
raise NotImplementedError
2527+
25252528
x, y, idx = input_names
25262529
out = output_names[0]
25272530
copy_of_x = self.copy_of_x(x)

0 commit comments

Comments
 (0)