提交 1bf7ea39 authored 作者: Frédéric Bastien's avatar Frédéric Bastien

Merge pull request #2972 from t13m/opt_as_cuda_ndarray_variable

Remove useless gpu_from_host(host_from_gpu(x)) op.
...@@ -34,6 +34,14 @@ _logger = logging.getLogger(_logger_name) ...@@ -34,6 +34,14 @@ _logger = logging.getLogger(_logger_name)
def as_cuda_ndarray_variable(x): def as_cuda_ndarray_variable(x):
if x.owner:
if isinstance(x.owner.op, HostFromGpu):
return x.owner.inputs[0]
elif \
isinstance(x.owner.op, GpuFromHost) and \
x.owner.inputs[0].owner and \
isinstance(x.owner.inputs[0].owner.op, HostFromGpu):
return x.owner.inputs[0].owner.inputs[0]
if hasattr(x, '_as_CudaNdarrayVariable'): if hasattr(x, '_as_CudaNdarrayVariable'):
return x._as_CudaNdarrayVariable() return x._as_CudaNdarrayVariable()
tensor_x = tensor.as_tensor_variable(x) tensor_x = tensor.as_tensor_variable(x)
......
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论