提交 48894fae authored 作者: Brendan Murphy's avatar Brendan Murphy 提交者: Ricardo Vieira

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.
上级 756be77e
......@@ -2520,8 +2520,7 @@ class AdvancedIncSubtensor1(COp):
return code
def c_code(self, node, name, input_names, output_names, sub):
numpy_ver = [int(n) for n in np.__version__.split(".")[:2]]
if bool(numpy_ver < [1, 8]):
if numpy_version < "1.8.0" or using_numpy_2:
raise NotImplementedError
x, y, idx = input_names
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论