ankapadding.cl 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright (C) 2011-2014 Karlsruhe Institute of Technology
  3. *
  4. * This file is part of Ufo.
  5. *
  6. * This library is free software: you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation, either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. kernel void pad (read_only image2d_t in_image,
  20. sampler_t sampler,
  21. global float *result,
  22. const uint2 input_shape,
  23. const int2 offset)
  24. {
  25. int2 pixel = (int2) (get_global_id (0), get_global_id (1));
  26. float2 norm_pixel = (float2) (((float) pixel.x - offset.x) / input_shape.x,
  27. ((float) pixel.y - offset.y) / input_shape.y);
  28. result[pixel.y * get_global_size(0) + pixel.x] = read_imagef(in_image, sampler, norm_pixel).x;
  29. }