提交 de522246 authored 作者: lamblin's avatar lamblin

Merge pull request #652 from nouiz/small

Small
...@@ -256,10 +256,8 @@ def Rop(f, wrt, eval_points): ...@@ -256,10 +256,8 @@ def Rop(f, wrt, eval_points):
eval_point = as_tensor_variable(eval_point) eval_point = as_tensor_variable(eval_point)
try: try:
wrt_dim = len(wrt_elem.type.broadcastable)
eval_dim = len(eval_point.type.broadcastable)
if wrt_dim != eval_dim: if wrt_elem.type.ndim != eval_point.type.ndim:
raise ValueError('Element ' + raise ValueError('Element ' +
str(i) + str(i) +
' of wrt/eval_point have mismatched ' + ' of wrt/eval_point have mismatched ' +
...@@ -267,9 +265,9 @@ def Rop(f, wrt, eval_points): ...@@ -267,9 +265,9 @@ def Rop(f, wrt, eval_points):
str(wrt_dim) + str(wrt_dim) +
' versus ' + ' versus ' +
str(eval_dim)) str(eval_dim))
except: except AttributeError:
# wrt_elem and eval_point can be non-tensor variable which do # wrt_elem and eval_point don't always have ndim like random type
# not have broadcastable flags # Tensor, Sparse and CudaNdArray have the ndim attribute
pass pass
seen_nodes = {} seen_nodes = {}
......
...@@ -113,6 +113,9 @@ class MulSDCSC(gof.Op): ...@@ -113,6 +113,9 @@ class MulSDCSC(gof.Op):
return gof.Apply(self, [a_data, a_indices, a_indptr, b], return gof.Apply(self, [a_data, a_indices, a_indptr, b],
[tensor.tensor(b.dtype, (False,))]) [tensor.tensor(b.dtype, (False,))])
def c_code_cache_version(self):
return (1,)
#def perform(self, node, (a_data, a_indices, a_indptr, b), (out,)): #def perform(self, node, (a_data, a_indices, a_indptr, b), (out,)):
# return NotImplementedError() # return NotImplementedError()
def c_code(self, node, name, (_data, _indices, _indptr, _b,), def c_code(self, node, name, (_data, _indices, _indptr, _b,),
...@@ -203,6 +206,9 @@ class MulSDCSR(gof.Op): ...@@ -203,6 +206,9 @@ class MulSDCSR(gof.Op):
return gof.Apply(self, [a_data, a_indices, a_indptr, b], return gof.Apply(self, [a_data, a_indices, a_indptr, b],
[tensor.tensor(b.dtype, (False,))]) [tensor.tensor(b.dtype, (False,))])
def c_code_cache_version(self):
return (1,)
#def perform(self, node, (a_data, a_indices, a_indptr, b), (out,)): #def perform(self, node, (a_data, a_indices, a_indptr, b), (out,)):
# return NotImplemented() # return NotImplemented()
def c_code(self, node, name, (_data, _indices, _indptr, _b,), def c_code(self, node, name, (_data, _indices, _indptr, _b,),
...@@ -499,6 +505,9 @@ class MulSVCSR(gof.Op): ...@@ -499,6 +505,9 @@ class MulSVCSR(gof.Op):
return gof.Apply(self, [a_data, a_indices, a_indptr, b], return gof.Apply(self, [a_data, a_indices, a_indptr, b],
[tensor.tensor(b.dtype, (False,))]) [tensor.tensor(b.dtype, (False,))])
def c_code_cache_version(self):
return (1,)
def c_code(self, node, name, inputs, outputs, sub): def c_code(self, node, name, inputs, outputs, sub):
_data, _indices, _indptr, _b, = inputs _data, _indices, _indptr, _b, = inputs
_zout, = outputs _zout, = outputs
...@@ -660,6 +669,9 @@ class StrucutedAddSVCSR(gof.Op): ...@@ -660,6 +669,9 @@ class StrucutedAddSVCSR(gof.Op):
return gof.Apply(self, [a_data, a_indices, a_indptr, b], return gof.Apply(self, [a_data, a_indices, a_indptr, b],
[tensor.tensor(b.dtype, (False,))]) [tensor.tensor(b.dtype, (False,))])
def c_code_cache_version(self):
return (1,)
def c_code(self, node, name, inputs, outputs, sub): def c_code(self, node, name, inputs, outputs, sub):
_data, _indices, _indptr, _b, = inputs _data, _indices, _indptr, _b, = inputs
_zout, = outputs _zout, = outputs
......
...@@ -1748,7 +1748,7 @@ class Prod(CAReduceDtype): ...@@ -1748,7 +1748,7 @@ class Prod(CAReduceDtype):
return "Prod{%s}" % ", ".join(map(str, self.axis)) return "Prod{%s}" % ", ".join(map(str, self.axis))
def c_code_cache_version(self): def c_code_cache_version(self):
return () return (1,)
class MulWithoutZeros(scalar.BinaryScalarOp): class MulWithoutZeros(scalar.BinaryScalarOp):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论