提交 f227b82b authored 作者: Frederic Bastien's avatar Frederic Bastien

small fix to the not used Mean op. Now perform() work event when axis!=None and…

small fix to the not used Mean op. Now perform() work event when axis!=None and c_code() generate code only when axis==None(only type of code implemented for now.)
上级 9563676f
......@@ -1757,11 +1757,13 @@ class Mean(elemwise.CAReduce):
return 'float64'
def perform(self, node, (input, ), (output, )):
ret = elemwise.CAReduce.perform(self,node,(input,),(output,))
output[0]=numpy.asarray(output[0]/len(input))
output[0]=numpy.mean(input,axis=self.axis)
def c_code(self, node, name, inames, onames, sub):
if self.axis!=None:
return super(Op, self).c_code(node, name, inames, onames, sub)
ret = elemwise.CAReduce.c_code(self, node, name, inames, onames, sub)
#TODO: c_code perform support only axis==None
return ret + """
*((double *)PyArray_DATA(%s)) /= PyArray_SIZE(%s);
"""%(onames[0],inames[0])
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论