@register_opt()
@local_optimizer([GpuFromHost, tensor.blas.Dot22])
def local_gpu_dot22(node):
 if isinstance(node.op, GpuFromHost):
  host_input = node.inputs[0]
  if (host_input.owner and isinstance(host_input.owner.op, tensor.blas.Dot22)):
   (x, y) = host_input.owner.inputs
   return [gpu_dot22(as_cuda_ndarray_variable(x), as_cuda_ndarray_variable(y))]
 if isinstance(node.op, tensor.blas.Dot22):
  if any([(i.owner and isinstance(i.owner.op, HostFromGpu)) for i in node.inputs]):
   (x, y) = node.inputs
   return [host_from_gpu(gpu_dot22(as_cuda_ndarray_variable(x), as_cuda_ndarray_variable(y)))]
 return False

@ register_opt ( ) @ local_optimizer ( [ GpuFromHost , tensor . blas . Dot22 ] ) def local_gpu_dot22 ( node ) : if isinstance ( node . op , GpuFromHost ) : host_input = node . inputs [ 0 ] if ( host_input . owner and isinstance ( host_input . owner . op , tensor . blas . Dot22 ) ) : ( x , y ) = host_input . owner . inputs return [ gpu_dot22 ( as_cuda_ndarray_variable ( x ) , as_cuda_ndarray_variable ( y ) ) ] if isinstance ( node . op , tensor . blas . Dot22 ) : if any ( [ ( i . owner and isinstance ( i . owner . op , HostFromGpu ) ) for i in node . inputs ] ) : ( x , y ) = node . inputs return [ host_from_gpu ( gpu_dot22 ( as_cuda_ndarray_variable ( x ) , as_cuda_ndarray_variable ( y ) ) ) ] return False
gpu_from_host -> gpudot dot -> host_from_gpu .