@register_opt()
@local_optimizer([tensor.SpecifyShape, GpuFromHost])
def local_gpu_specifyShape_0(node):
 if isinstance(node.op, tensor.SpecifyShape):
  input = node.inputs[0]
  if (input.owner and isinstance(input.owner.op, HostFromGpu)):
   return [host_from_gpu(tensor.specify_shape(as_cuda_ndarray_variable(input), *node.inputs[1:]))]
 if isinstance(node.op, GpuFromHost):
  host_input = node.inputs[0]
  if (host_input.owner and isinstance(host_input.owner.op, tensor.SpecifyShape)):
   specifyshape_node = host_input.owner
   return [tensor.specify_shape(as_cuda_ndarray_variable(specifyshape_node.inputs[0]), *specifyshape_node.inputs[1:])]
 return False

@ register_opt ( ) @ local_optimizer ( [ tensor . SpecifyShape , GpuFromHost ] ) def local_gpu_specifyShape_0 ( node ) : if isinstance ( node . op , tensor . SpecifyShape ) : input = node . inputs [ 0 ] if ( input . owner and isinstance ( input . owner . op , HostFromGpu ) ) : return [ host_from_gpu ( tensor . specify_shape ( as_cuda_ndarray_variable ( input ) , * node . inputs [ 1 : ] ) ) ] if isinstance ( node . op , GpuFromHost ) : host_input = node . inputs [ 0 ] if ( host_input . owner and isinstance ( host_input . owner . op , tensor . SpecifyShape ) ) : specifyshape_node = host_input . owner return [ tensor . specify_shape ( as_cuda_ndarray_variable ( specifyshape_node . inputs [ 0 ] ) , * specifyshape_node . inputs [ 1 : ] ) ] return False
specify_shape(host_from_gpu()) -> host_from_gpu gpu_from_host -> specify_shape .