Caffe2 - C++ API
A deep learning, cross platform ML framework
gl_tiling_utils.h
1 
17 #pragma once
18 #include <cmath>
19 
20 struct point {
21  int x;
22  int y;
23 };
24 
26  point tile_dims;
27  point tile_size;
28  int tiles;
29 };
30 
31 namespace caffe2 {
32 inline static void squareFactors(int N, int& r1, int& r2) {
33  int f = sqrt(N);
34 
35  if (f * f == N) {
36  r1 = r2 = f;
37  } else {
38  while (N % f != 0) {
39  f--;
40  }
41  r1 = N / f;
42  r2 = f;
43  }
44 }
45 
46 inline static void computeOutputTiles(int output_channels, int& output_tile_x, int& output_tile_y) {
47  squareFactors((output_channels + 3) / 4, output_tile_x, output_tile_y);
48 }
49 } // namespace caffe2
Copyright (c) 2016-present, Facebook, Inc.
Copyright (c) 2016-present, Facebook, Inc.