提交 9dada913 authored 作者: Frederic's avatar Frederic

Use the new numpy c api that require PyArrayObject as input.

上级 e921dc7e
...@@ -1571,7 +1571,7 @@ class AdvancedSubtensor1(Op): ...@@ -1571,7 +1571,7 @@ class AdvancedSubtensor1(Op):
output_name = output_names[0] output_name = output_names[0]
fail = sub['fail'] fail = sub['fail']
return """ return """
PyObject *indices; PyArrayObject *indices;
int i_type = PyArray_TYPE(%(i_name)s); int i_type = PyArray_TYPE(%(i_name)s);
if (i_type != NPY_INTP) { if (i_type != NPY_INTP) {
// Cast %(i_name)s to NPY_INTP (expected by PyArray_TakeFrom), // Cast %(i_name)s to NPY_INTP (expected by PyArray_TakeFrom),
...@@ -1606,13 +1606,13 @@ class AdvancedSubtensor1(Op): ...@@ -1606,13 +1606,13 @@ class AdvancedSubtensor1(Op):
%(fail)s; %(fail)s;
} }
} }
indices = PyArray_Cast(%(i_name)s, NPY_INTP); indices = (PyArrayObject*) PyArray_Cast(%(i_name)s, NPY_INTP);
if (indices == NULL) { if (indices == NULL) {
%(fail)s; %(fail)s;
} }
} }
else { else {
indices = (PyObject *)%(i_name)s; indices = %(i_name)s;
Py_INCREF(indices); Py_INCREF(indices);
} }
if (%(output_name)s != NULL) { if (%(output_name)s != NULL) {
...@@ -1641,7 +1641,7 @@ class AdvancedSubtensor1(Op): ...@@ -1641,7 +1641,7 @@ class AdvancedSubtensor1(Op):
} }
} }
%(output_name)s = (PyArrayObject*)PyArray_TakeFrom( %(output_name)s = (PyArrayObject*)PyArray_TakeFrom(
%(a_name)s, indices, 0, %(output_name)s, NPY_RAISE); %(a_name)s, (PyObject*)indices, 0, %(output_name)s, NPY_RAISE);
Py_DECREF(indices); Py_DECREF(indices);
if (%(output_name)s == NULL) %(fail)s; if (%(output_name)s == NULL) %(fail)s;
""" % locals() """ % locals()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论