File: dropout.cl

package info (click to toggle)
tiny-dnn 1.0.0a3%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,760 kB
  • sloc: cpp: 16,471; ansic: 11,829; lisp: 3,682; python: 3,422; makefile: 206
file content (24 lines) | stat: -rw-r--r-- 1,019 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#ifndef __OPENCL_VERSION__
#include "header.cl"
#endif

__kernel void TEMPLATE(dropout_forward,Dtype)(const int_tp n,
                                              __global const Dtype* in,
                                              __global const uint_tp* mask,
                                              const uint_tp threshold,
                                              const Dtype scale,
                                              __global Dtype* out) {
  for (int_tp index = get_global_id(0); index < n; index += get_global_size(0)) {
    out[index] = in[index] * ((mask[index] > threshold)?1.0:0.0) * scale;
  }
}

__kernel void TEMPLATE(dropout_backward,Dtype)(
    const int_tp n, __global const Dtype* in_diff,
    __global const uint_tp* mask, const uint_tp threshold,
    const Dtype scale,
    __global Dtype* out_diff) {
  for (int_tp index = get_global_id(0); index < n; index += get_global_size(0)) {
    out_diff[index] = in_diff[index] * ((mask[index] > threshold)?1.0:0.0) * scale;
  }
}