提交 0da30159 authored 作者: sentient07's avatar sentient07

Added few more __props__, added __str__ method to Sum class, cleanup

上级 b7622fd6
...@@ -852,7 +852,6 @@ class ScalarOp(Op): ...@@ -852,7 +852,6 @@ class ScalarOp(Op):
nin = -1 nin = -1
nout = 1 nout = 1
__props__ = ("output_types_preference", "name") __props__ = ("output_types_preference", "name")
def __init__(self, output_types_preference=None, name=None): def __init__(self, output_types_preference=None, name=None):
...@@ -1185,6 +1184,7 @@ isinf = IsInf() ...@@ -1185,6 +1184,7 @@ isinf = IsInf()
class InRange(LogicalComparison): class InRange(LogicalComparison):
nin = 3 nin = 3
__props__ = ("openlow", "openhi")
def __init__(self, openlow, openhi): def __init__(self, openlow, openhi):
self.openlow = openlow self.openlow = openlow
...@@ -2036,6 +2036,8 @@ identity = Identity(same_out, name='identity') ...@@ -2036,6 +2036,8 @@ identity = Identity(same_out, name='identity')
# CASTING OPERATIONS # CASTING OPERATIONS
class Cast(UnaryScalarOp): class Cast(UnaryScalarOp):
__props__ = ("o_type", "name")
def __init__(self, o_type, name=None): def __init__(self, o_type, name=None):
if not isinstance(o_type, Scalar): if not isinstance(o_type, Scalar):
raise TypeError(o_type) raise TypeError(o_type)
...@@ -3461,7 +3463,7 @@ class Composite(ScalarOp): ...@@ -3461,7 +3463,7 @@ class Composite(ScalarOp):
Composite depends on all the Ops in its graph having C code. Composite depends on all the Ops in its graph having C code.
""" """
init_param = ('inputs', 'outputs') __props__ = ('inputs', 'outputs')
def __str__(self): def __str__(self):
if self.name is None: if self.name is None:
...@@ -3475,7 +3477,7 @@ class Composite(ScalarOp): ...@@ -3475,7 +3477,7 @@ class Composite(ScalarOp):
This fct allow fix patch this. This fct allow fix patch this.
""" """
d = dict([(k, getattr(self, k)) for k in self.init_param]) d = dict([(k, getattr(self, k)) for k in self.__props__])
out = self.__class__(**d) out = self.__class__(**d)
if name: if name:
out.name = name out.name = name
......
...@@ -476,7 +476,6 @@ second dimension ...@@ -476,7 +476,6 @@ second dimension
| Elemwise(log)(rand(3, 4, 5)) | Elemwise(log)(rand(3, 4, 5))
""" """
__props__ = ("scalar_op", "inplace_pattern", "name", "nfunc_spec", "openmp")
def __init__(self, scalar_op, inplace_pattern=None, name=None, def __init__(self, scalar_op, inplace_pattern=None, name=None,
nfunc_spec=None, openmp=None): nfunc_spec=None, openmp=None):
...@@ -1993,6 +1992,18 @@ class Sum(CAReduceDtype): ...@@ -1993,6 +1992,18 @@ class Sum(CAReduceDtype):
CAReduceDtype.__init__(self, scalar.add, axis=axis, CAReduceDtype.__init__(self, scalar.add, axis=axis,
dtype=dtype, acc_dtype=acc_dtype) dtype=dtype, acc_dtype=acc_dtype)
def __str__(self):
name = self.__class__.__name__
axis = ""
if self.axis is not None:
axis = ", ".join(str(x) for x in self.axis)
axis = "axis=[%s], " % axis
return "%s{%sacc_dtype=%s}" % (
name,
axis,
str(self.acc_dtype)
)
def grad(self, inp, grads): def grad(self, inp, grads):
x, = inp x, = inp
......
...@@ -2246,8 +2246,6 @@ AllocDimshuffleGradTester2 = makeBroadcastTester( ...@@ -2246,8 +2246,6 @@ AllocDimshuffleGradTester2 = makeBroadcastTester(
class ApplyDefaultTestOp(theano.Op): class ApplyDefaultTestOp(theano.Op):
__props__ = ("id")
def __init__(self, id): def __init__(self, id):
self.default_output = id self.default_output = id
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论