提交 ff7cf542 authored 作者: Olivier Breuleux's avatar Olivier Breuleux

fix in elemwise_cgen

上级 546cf660
...@@ -690,6 +690,9 @@ class CAReduce(Op): ...@@ -690,6 +690,9 @@ class CAReduce(Op):
return input_dtype return input_dtype
def make_node(self, input): def make_node(self, input):
for axis in self.axis:
if axis >= input.type.ndim:
raise TypeError('Not enough dimensions on %s to reduce on axis %s' % (input, axis))
input = as_tensor_variable(input) input = as_tensor_variable(input)
axis = self.axis axis = self.axis
if axis is None: if axis is None:
......
...@@ -29,7 +29,7 @@ def make_checks(loop_orders, dtypes, sub): ...@@ -29,7 +29,7 @@ def make_checks(loop_orders, dtypes, sub):
var = "%%(lv%i)s" % i var = "%%(lv%i)s" % i
nonx = [x for x in loop_order if x != 'x'] nonx = [x for x in loop_order if x != 'x']
if nonx: if nonx:
min_nd = max(nonx) min_nd = max(nonx) + 1
init += """ init += """
if (%(var)s->nd < %(min_nd)s) { if (%(var)s->nd < %(min_nd)s) {
PyErr_SetString(PyExc_ValueError, "Not enough dimensions on input."); PyErr_SetString(PyExc_ValueError, "Not enough dimensions on input.");
......
...@@ -496,13 +496,8 @@ class Canonizer(gof.LocalOptimizer): ...@@ -496,13 +496,8 @@ class Canonizer(gof.LocalOptimizer):
denum = [] denum = []
parent = input.owner parent = input.owner
# We get the (num, denum) pairs for each input
# We get the (num, denum) pairs for each input (input2) *to* input that has the same pairs = [self.get_num_denum(input2) if input2.type.dtype == input.type.dtype else ([input2], []) for input2 in parent.inputs]
# type as this one.
pairs = [self.get_num_denum(input2)
if (getattr(input2.type, 'dtype', None) == input.type.dtype)
else ([input2], [])
for input2 in parent.inputs ]
if parent.op == self.main: if parent.op == self.main:
# If we have main(x, y), numx, denumx, numy and denumy # If we have main(x, y), numx, denumx, numy and denumy
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论