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

PL m'a aidé snif

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