Welcome to mirror list, hosted at ThFree Co, Russian Federation.

THCStorage.h « generic « THC « lib - github.com/torch/cutorch.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 194ad62d5a8d51e4b71791d545bdce64143a472e (plain)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef THC_GENERIC_FILE
#define THC_GENERIC_FILE "generic/THCStorage.h"
#else

#define TH_STORAGE_REFCOUNTED 1
#define TH_STORAGE_RESIZABLE  2
#define TH_STORAGE_FREEMEM    4

typedef struct THCStorage
{
    real *data;
    long size;
    int refcount;
    char flag;
    THAllocator *allocator;
    void *allocatorContext;
    struct THCStorage *view;
} THCStorage;


THC_API real* THCStorage_(data)(THCState *state, const THCStorage*);
THC_API long THCStorage_(size)(THCState *state, const THCStorage*);
THC_API int THCStorage_(elementSize)(THCState *state);

/* slow access -- checks everything */
THC_API void THCStorage_(set)(THCState *state, THCStorage*, long, real);
THC_API real THCStorage_(get)(THCState *state, const THCStorage*, long);

THC_API THCStorage* THCStorage_(new)(THCState *state);
THC_API THCStorage* THCStorage_(newWithSize)(THCState *state, long size);
THC_API THCStorage* THCStorage_(newWithSize1)(THCState *state, real);
THC_API THCStorage* THCStorage_(newWithSize2)(THCState *state, real, real);
THC_API THCStorage* THCStorage_(newWithSize3)(THCState *state, real, real, real);
THC_API THCStorage* THCStorage_(newWithSize4)(THCState *state, real, real, real, real);
THC_API THCStorage* THCStorage_(newWithMapping)(THCState *state, const char *filename, long size, int shared);

/* takes ownership of data */
THC_API THCStorage* THCStorage_(newWithData)(THCState *state, real *data, long size);

THC_API THCStorage* THCStorage_(newWithAllocator)(THCState *state, long size,
                                                      THAllocator* allocator,
                                                      void *allocatorContext);
THC_API THCStorage* THCStorage_(newWithDataAndAllocator)(
    THCState *state, real* data, long size, THAllocator* allocator, void *allocatorContext);

THC_API void THCStorage_(setFlag)(THCState *state, THCStorage *storage, const char flag);
THC_API void THCStorage_(clearFlag)(THCState *state, THCStorage *storage, const char flag);
THC_API void THCStorage_(retain)(THCState *state, THCStorage *storage);

THC_API void THCStorage_(free)(THCState *state, THCStorage *storage);
THC_API void THCStorage_(resize)(THCState *state, THCStorage *storage, long size);
THC_API void THCStorage_(fill)(THCState *state, THCStorage *storage, real value);

THC_API int THCStorage_(getDevice)(THCState* state, const THCStorage* storage);

#endif