code: def convolve(data, h, res_g=None, sub_blocks=None):
      
  
      if not len(data.shape) in [1, 2, 3]:
          raise ValueError("dim = %s not supported" % (len(data.shape)))
  
      if len(data.shape) != len(h.shape):
          raise ValueError("dimemnsion of data (%s) and h (%s) are different" % (len(data.shape), len(h.shape)))
  
      if isinstance(data, OCLArray) and isinstance(h, OCLArray):
          return _convolve_buf(data, h, res_g)
      elif isinstance(data, np.ndarray) and isinstance(h, np.ndarray):
          if sub_blocks == (1,) * len(data.shape) or sub_blocks is None:
              return _convolve_np(data, h)
          else:
              # cut the image into tile and operate on every of them
              N_sub = [int(np.ceil(1. * n / s)) for n, s in zip(data.shape, sub_blocks)]
              Npads = [int(s / 2) for s in h.shape]
              res = np.empty(data.shape, np.float32)
              for data_tile, data_s_src, data_s_dest \
                      in tile_iterator(data, blocksize=N_sub,
                                       padsize=Npads,
                                       mode="constant"):
                  res_tile = _convolve_np(data_tile.copy(),
                                          h)
                  res[data_s_src] = res_tile[data_s_dest]
              return res
      else:
          raise TypeError("unknown types (%s, %s)" % (type(data), type(h)))
docs: convolves 1d-3d data with kernel h 
  
      data and h can either be numpy arrays or gpu buffer objects (OCLArray, 
      which must be float32 then)
  
      boundary conditions are clamping to zero at edge.