提交 1f8d28c2 authored 作者: Melanie Ducoffe's avatar Melanie Ducoffe

test optimisation GpuAllocEmpty, have to correct blancks spaces

上级 8f3b917b
...@@ -2277,19 +2277,11 @@ def gpuScanOptimization(node): ...@@ -2277,19 +2277,11 @@ def gpuScanOptimization(node):
@register_opt() @register_opt()
@local_optimizer([tensor.AllocEmpty, gpu_from_host]) @local_optimizer([tensor.AllocEmpty, gpu_from_host])
def local_gpu_allocempty(node): def local_gpu_allocempty(node):
#print 'kikou'
if (isinstance(node.op, tensor.AllocEmpty) and if (isinstance(node.op, tensor.AllocEmpty) and
node.op.dtype=="NPY_FLOAT_32"): node.op.dtype=="float32"):
if any([(i.owner and isinstance(i.owner.op, HostFromGpu)) return [host_from_gpu(GpuAllocEmpty()(*node.inputs))]
for i in node.inputs]): return False
return [host_from_gpu(GpuAllocEmpty("float32")(gpu_from_host(*node.inputs)))]
if isinstance(node.op, GpuFromHost):
host_input = node.inputs[0]
if (host_input.owner and
isinstance(host_input.owner.op, tensor.AllocEmpty) and
host_input.owner.op.dtype=="NPY_FLOAT_32"):
owner = host_input.owner
return [GpuAllocEmpty()(
gpu_from_host(*owner.inputs))]
optdb.register('gpu_scanOp_make_inplace', optdb.register('gpu_scanOp_make_inplace',
......
...@@ -156,16 +156,16 @@ def test_gpualloc(): ...@@ -156,16 +156,16 @@ def test_gpualloc():
def test_gpuallocempty(): def test_gpuallocempty():
f_gpu = theano.function([], tensor.AllocEmpty('float32'), f_gpu = theano.function([], tensor.AllocEmpty('float32')(2,3),
mode=mode_with_gpu) mode=mode_with_gpu)
l_gpu = f_gpu.maker.fgraph.toposort() l_gpu = f_gpu.maker.fgraph.toposort()
assert numpy.any([isinstance(x.op, cuda.GpuAllocEmpty) for x in l])
f_cpu = theano.function([], tensor.AllocEmpty('int32'), #assert numpy.any([isinstance(x.op, basic_ops.GpuAllocEmpty) for x in l_gpu])
f_cpu = theano.function([], tensor.AllocEmpty('int32')(2,3),
mode=mode_with_gpu) mode=mode_with_gpu)
l_cpu = f_gpu.maker.fgraph.toposort() l_cpu = f_gpu.maker.fgraph.toposort()
assert not numpy.any([isinstance(x.op, cuda.GpuAllocEmpty) for x in l]) assert not numpy.any([isinstance(x.op, basic_ops.GpuAllocEmpty) for x in l_cpu])
class Test_local_elemwise_alloc(test_opt.Test_local_elemwise_alloc): class Test_local_elemwise_alloc(test_opt.Test_local_elemwise_alloc):
dtype = 'float32' dtype = 'float32'
......
...@@ -5544,7 +5544,6 @@ class AllocEmpty(gof.Op): ...@@ -5544,7 +5544,6 @@ 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):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论