Caffe2 - C++ API
A deep learning, cross platform ML framework
GLImageAllocator.cc
1 
18 #include "GLImageAllocator.h"
19 #include "arm_neon_support.h"
20 
21 template <class T>
23  int num_images, int width, int height, int channels, int tile_x, int tile_y, bool is_output) {
24  GLImageVector<T>* images =
25  new GLImageVector<T>(num_images, width, height, channels, tile_x, tile_y);
26  for (int i = 0; i < num_images; i++) {
27  images->push_back(
28  new GLImage<T>(width, height, channels, tile_x, tile_y, [&](int slice) -> const GLTexture* {
29  bool usePadding = is_output;
30  return new GLPlainTexture(type, nullptr, width * tile_x, height * tile_y, usePadding);
31  }));
32  }
33  return images;
34 }
35 
36 template <class T>
38  int num_images,
39  int width,
40  int height,
41  int channels,
42  int tile_x,
43  int tile_y,
44  std::function<const GLTexture*(const int width, const int height)> textureAllocator) {
45  GLImageVector<T>* images =
46  new GLImageVector<T>(num_images, width, height, channels, tile_x, tile_y);
47  for (int i = 0; i < num_images; i++) {
48  images->push_back(
49  new GLImage<T>(width, height, channels, tile_x, tile_y, [&](int slice) -> const GLTexture* {
50  return textureAllocator(width, height);
51  }));
52  }
53  return images;
54 }
55 
56 template <class T>
58  int num_images,
59  int width,
60  int height,
61  int channels,
62  int tile_x,
63  int tile_y) {
64  GLImageVector<T>* images =
65  new GLImageVector<T>(num_images, width, height, channels, tile_x, tile_y);
66  for (int i = 0; i < num_images; i++) {
67  images->push_back(
68  new GLImage<T>(width, height, channels, tile_x, tile_y, [&](int slice) -> const GLTexture* {
69  return new GLPlainTexture(
70  GLImageAllocator<T>::type, textureID, width * tile_x, height * tile_y);
71  }));
72  }
73  return images;
74 }
75 
76 template <>
78 template <>
79 const GLTexture::Type& GLImageAllocator<uint8_t>::type = GLTexture::UI8;
80 
81 template class GLImageAllocator<float16_t>;
82 template class GLImageAllocator<uint8_t>;
Copyright (c) 2016-present, Facebook, Inc.
static const Type FP16
Copyright (c) 2016-present, Facebook, Inc.
Definition: GLTexture.h:58
Copyright (c) 2016-present, Facebook, Inc.
virtual GLImageVector< T > * newImage(int num_images, int width, int height, int channels, int tile_x, int tile_y, bool is_output)
Copyright (c) 2016-present, Facebook, Inc.
Copyright (c) 2016-present, Facebook, Inc.
Definition: GLImage.h:27
Copyright (c) 2016-present, Facebook, Inc.
Definition: GLTexture.h:22