Caffe2 - C++ API
A deep learning, cross platform ML framework
THStorage.h
1 #ifndef TH_GENERIC_FILE
2 #define TH_GENERIC_FILE "TH/generic/THStorage.h"
3 #else
4 
5 #include <c10/core/Allocator.h>
6 #include <c10/core/StorageImpl.h>
7 
8 /* on pourrait avoir un liste chainee
9  qui initialise math, lab structures (or more).
10  mouais -- complique.
11 
12  Pb: THMapStorage is kind of a class
13  THLab_()... comment je m'en sors?
14 
15  en template, faudrait que je les instancie toutes!!! oh boy!
16  Et comment je sais que c'est pour Cuda? Le type float est le meme dans les <>
17 
18  au bout du compte, ca serait sur des pointeurs float/double... etc... = facile.
19  primitives??
20  */
21 
22 // Struct definition is moved to THStorage.hpp (so this file stays C compatible)
23 
24 #define THStorage at::StorageImpl
25 
26 // These used to be distinct types; for some measure of backwards compatibility and documentation
27 // alias these to the single THStorage type.
28 #define THFloatStorage THStorage
29 #define THDoubleStorage THStorage
30 #define THHalfStorage THStorage
31 #define THByteStorage THStorage
32 #define THCharStorage THStorage
33 #define THShortStorage THStorage
34 #define THIntStorage THStorage
35 #define THLongStorage THStorage
36 #define THBoolStorage THStorage
37 
38 TH_API scalar_t* THStorage_(data)(const THStorage*);
39 TH_API ptrdiff_t THStorage_(size)(const THStorage*);
40 TH_API size_t THStorage_(elementSize)(void);
41 
42 /* slow access -- checks everything */
43 TH_API void THStorage_(set)(THStorage*, ptrdiff_t, scalar_t);
44 TH_API scalar_t THStorage_(get)(const THStorage*, ptrdiff_t);
45 
46 TH_API THStorage* THStorage_(new)(void);
47 TH_API THStorage* THStorage_(newWithSize)(ptrdiff_t size);
48 TH_API THStorage* THStorage_(newWithSize1)(scalar_t);
49 TH_API THStorage* THStorage_(newWithSize2)(scalar_t, scalar_t);
50 TH_API THStorage* THStorage_(newWithSize3)(scalar_t, scalar_t, scalar_t);
51 TH_API THStorage* THStorage_(newWithSize4)(scalar_t, scalar_t, scalar_t, scalar_t);
52 TH_API THStorage* THStorage_(newWithMapping)(const char *filename, ptrdiff_t size, int flags);
53 
54 TH_API THStorage* THStorage_(newWithAllocator)(ptrdiff_t size,
55  c10::Allocator* allocator);
56 TH_API THStorage* THStorage_(newWithDataAndAllocator)(
57  at::DataPtr&& data, ptrdiff_t size, at::Allocator* allocator);
58 
59 /* should not differ with API */
60 TH_API void THStorage_(setFlag)(THStorage *storage, const char flag);
61 TH_API void THStorage_(clearFlag)(THStorage *storage, const char flag);
62 TH_API void THStorage_(retain)(THStorage *storage);
63 TH_API void THStorage_(swap)(THStorage *storage1, THStorage *storage2);
64 
65 /* might differ with other API (like CUDA) */
66 TH_API void THStorage_(free)(THStorage *storage);
67 TH_API void THStorage_(resize)(THStorage *storage, ptrdiff_t size);
68 TH_API void THStorage_(fill)(THStorage *storage, scalar_t value);
69 
70 #endif