File: slice.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 (26 lines) | stat: -rw-r--r-- 1,123 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
25
26
#ifndef __OPENCL_VERSION__
#include "header.cl"
#endif

__kernel void TEMPLATE(slice,Dtype)(const int_tp nthreads,
                                    __global const Dtype* in_data,
                                    const int forward, const int_tp num_slices,
                                    const int_tp slice_size,
                                    const int_tp bottom_slice_axis,
                                    const int_tp top_slice_axis,
                                    const int_tp offset_slice_axis,
                                    __global Dtype* out_data) {
  for (int_tp index = get_global_id(0); index < nthreads;
      index += get_global_size(0)) {
    const int_tp total_slice_size = slice_size * top_slice_axis;
    const int_tp slice_num = index / total_slice_size;
    const int_tp slice_index = index % total_slice_size;
    const int_tp bottom_index = slice_index
        + (slice_num * bottom_slice_axis + offset_slice_axis) * slice_size;
    if (forward == 1) {
      out_data[index] = in_data[bottom_index];
    } else {
      out_data[bottom_index] = in_data[index];
    }
  }
}