def gpu_flatten(x, outdim=1):
 x = as_cuda_ndarray_variable(x)
 if (outdim > 1):
  dims = (tuple(x.shape[:(outdim - 1)]) + ((-1),))
 else:
  dims = ((-1),)
 return GpuReshape(outdim)(x, dims)

def gpu_flatten ( x , outdim = 1 ) : x = as_cuda_ndarray_variable ( x ) if ( outdim > 1 ) : dims = ( tuple ( x . shape [ : ( outdim - 1 ) ] ) + ( ( - 1 ) , ) ) else : dims = ( ( - 1 ) , ) return GpuReshape ( outdim ) ( x , dims )
implement flatten on the gpu .