提交 4b0f029a authored 作者: Olivier Breuleux's avatar Olivier Breuleux

merge

上级 d82e9fd4
......@@ -188,9 +188,9 @@ class T_pow(unittest.TestCase):
verify_grad(self, DivElemwise, [numpy.random.rand(3,4), numpy.random.rand(3,4)+0.1])
verify_grad(self, PowElemwise, [numpy.random.rand(3,4), numpy.random.rand(3,4)])
def test_scalar_l(self):
verify_grad(self, PowScalarL, [numpy.random.rand(3), 3.0])
verify_grad(self, PowScalarL, [numpy.random.rand(3), numpy.asarray(3.0)])
def test_scalar_r(self):
verify_grad(self, PowScalarR, [numpy.random.rand(3), 3.0])
verify_grad(self, PowScalarR, [numpy.random.rand(3), numpy.asarray(3.0)])
class _testCase_matinv:#(unittest.TestCase):
......
......@@ -119,6 +119,8 @@ class _Op(Op):
nin = -1
nout = 1
_destroy_map = {}
def __init__(self, *inputs):
def as_tensor(obj):
......@@ -148,17 +150,28 @@ class _Op(Op):
def propagate_dtype(self, *i_dtypes):
def upcast(dtype, *dtypes):
z = numpy.zeros((), dtype = dtype)
#print '----', self.__class__
#print type(z), dtype
for dtype in dtypes:
z = z + numpy.zeros((), dtype = dtype)
#print type(z), type(dtype), dtype
return str(z.dtype)
for dtype in i_dtypes:
if dtype is None:
raise TypeError("Expected a Tensor.")
rval = upcast(*i_dtypes)
return rval
upcasted = upcast(*i_dtypes)
return upcasted
# try:
# dmap = self.destroy_map()
# except AttributeError:
# dmap = {}
# rval = []
# for i in xrange(self.nout):
# if i in dmap:
# destroyed = dmap[output]
# if len(destroyed) != 1:
# raise TypeError("Cannot infer dtype of output %s because it destroys more than one input." % output)
# rval.append(destroyed[0])
# else:
# rval.append(upcasted)
# return rval
def impl(self, *inputs):
raise AbstractFunctionError()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论