提交 f4779cbb authored 作者: Frederic's avatar Frederic

Don't apply InputToGpuOptimizer to input that are already moved to the gpu.

上级 6872ae43
...@@ -82,17 +82,24 @@ class InputToGpuOptimizer(Optimizer): ...@@ -82,17 +82,24 @@ class InputToGpuOptimizer(Optimizer):
def apply(self, env): def apply(self, env):
for input in env.inputs: for input in env.inputs:
if not isinstance(input.type, CudaNdarrayType): if isinstance(input.type, CudaNdarrayType):
try: return
new_input = host_from_gpu(gpu_from_host(input))
# This happen frequently as we do 2 pass of the gpu optimizations
if new_input.type == input.type: if (len(input.clients) == 1 and
env.replace_validate(input, new_input, input.clients[0][0].op == gpu_from_host):
"InputToGpuOptimizer") return
except TypeError, e:
#as we currently only support float32, this can fail. try:
#Using try except make that we won't need new_input = host_from_gpu(gpu_from_host(input))
pass
if new_input.type == input.type:
env.replace_validate(input, new_input,
"InputToGpuOptimizer")
except TypeError, e:
#as we currently only support float32, this can fail.
#Using try except make that we won't need
pass
# we register it before all other gpu optimizer to be sure that the input # we register it before all other gpu optimizer to be sure that the input
# are on the gpu. # are on the gpu.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论