@register_opt()
@local_optimizer([tensor.Join])
def local_gpu_join(node):
 if isinstance(node.op, tensor.Join):
  axis_and_tensors = node.inputs
  matches = [((t.dtype == 'float32') and (((t.owner is not None) and isinstance(t.owner.op, HostFromGpu)) or isinstance(t, gof.Constant))) for t in axis_and_tensors[1:]]
  if all(matches):
   new_tensors = [as_cuda_ndarray_variable(t) for t in axis_and_tensors[1:]]
   new_a_and_t = ([axis_and_tensors[0]] + new_tensors)
   replacement_node = host_from_gpu(gpu_join(*new_a_and_t))
   return [replacement_node]

@ register_opt ( ) @ local_optimizer ( [ tensor . Join ] ) def local_gpu_join ( node ) : if isinstance ( node . op , tensor . Join ) : axis_and_tensors = node . inputs matches = [ ( ( t . dtype == 'float32' ) and ( ( ( t . owner is not None ) and isinstance ( t . owner . op , HostFromGpu ) ) or isinstance ( t , gof . Constant ) ) ) for t in axis_and_tensors [ 1 : ] ] if all ( matches ) : new_tensors = [ as_cuda_ndarray_variable ( t ) for t in axis_and_tensors [ 1 : ] ] new_a_and_t = ( [ axis_and_tensors [ 0 ] ] + new_tensors ) replacement_node = host_from_gpu ( gpu_join ( * new_a_and_t ) ) return [ replacement_node ]
inspired by the opt for convop .