relu.cl 500 字节
Newer Older
D
dolphin8 已提交
1

L
liuruilong 已提交
2
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
D
dolphin8 已提交
3 4

__kernel void relu(__read_only image2d_t input,
L
liuruilong 已提交
5 6
                   __write_only image2d_t output){

D
dolphin8 已提交
7 8
  const int x = get_global_id(0);
  const int y = get_global_id(1);
L
liuruilong 已提交
9

D
dolphin8 已提交
10 11 12
  const sampler_t sampler = CLK_NORMALIZED_COORDS_TRUE |
                            CLK_ADDRESS_CLAMP |
                            CLK_FILTER_NEAREST;
L
liuruilong 已提交
13 14 15 16

  half4 in = read_imageh(input, sampler, (int2)(x, y));
  in = max((half4)(0.0), in);
  write_imageh(output, (int2)(x, y), in);
D
dolphin8 已提交
17
}