fixed bug in ScalarTensorOps C implementation and in elemwise

上级 b05004d3
......@@ -240,9 +240,9 @@ def elemwise_wrap(beforeloop, inloop, afterloop, input_loop_vars, output_loop_va
%(general_decl)s
%(contig_decl)s
npy_intp __SIZE = PyArray_SIZE(%(v1)s);
%(beforeloop)s
bool all_c_contiguous = 1;
bool all_f_contiguous = 1;
%(beforeloop)s
%(contiguity_check)s
if (all_c_contiguous || all_f_contiguous) {
%(contig_loop)s
......
......@@ -221,11 +221,12 @@ class TensorScalarOp(_Elemwise):
return [('x', 1), ('a', 0)], [('z', 1)]
def c_code_init(self):
return """
dtype_%(a)s _%(a)s;
if (PyArray_SIZE(%(a)s) != 1) {
PyErr_SetString(PyExc_ValueError, \"The size of the scalar argument is not 1.\");
%(fail)s
}
dtype_%(a)s _%(a)s = ((dtype_%(a)s*)PyArray_DATA(%(a)s))[0];
_%(a)s = ((dtype_%(a)s*)PyArray_DATA(%(a)s))[0];
"""
def c_code_foreach(self):
return "%%(z)s_i = %s;" % self.c_expr
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论