提交 cc184269 authored 作者: Melanie Ducoffe's avatar Melanie Ducoffe

PL m'a aidé snif

上级 155ea053
...@@ -5517,11 +5517,11 @@ class AllocEmpty(gof.Op): ...@@ -5517,11 +5517,11 @@ class AllocEmpty(gof.Op):
fail = sub['fail'] fail = sub['fail']
shps = inputs shps = inputs
nd = len(shps) nd = len(shps)
str = "int dims[%(nd)s];\n" % locals() str = "npy_intp dims[%(nd)s];\n" % locals()
for idx, sh in enumerate(shps): for idx, sh in enumerate(shps):
str += "dims[%(idx)s] =" \ str +="dims[%(idx)s] =" \
"PyInt_AsLong((PyObject*)%(sh)s);\n" % locals() "((npy_intp) PyInt_AsLong((PyObject*)%(sh)s));\n" % locals()
# Validate that the output storage exists # Validate that the output storage exists
str += "if(%(out)s==NULL\n" % locals() str += "if(%(out)s==NULL\n" % locals()
...@@ -5544,13 +5544,15 @@ class AllocEmpty(gof.Op): ...@@ -5544,13 +5544,15 @@ class AllocEmpty(gof.Op):
} }
} }
""" % locals() """ % locals()
print str
return str return str
def infer_shape(self, node, input_shapes): def infer_shape(self, node, input_shapes):
return [node.inputs] return [node.inputs]
def c_code_cache_version(self): def c_code_cache_version(self):
return (1,) return None
#return (1,)
def do_constant_folding(self, node): def do_constant_folding(self, node):
return False return False
...@@ -7541,6 +7541,7 @@ def test_allocempty(): ...@@ -7541,6 +7541,7 @@ def test_allocempty():
f = theano.function([], AllocEmpty("float32")(2, 3)) # change f = theano.function([], AllocEmpty("float32")(2, 3)) # change
assert len(f.maker.fgraph.apply_nodes) == 1 assert len(f.maker.fgraph.apply_nodes) == 1
out = f() out = f()
assert out.shape == (2, 3) assert out.shape == (2, 3)
assert out.dtype == 'float32' assert out.dtype == 'float32'
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论