Caffe2 - C++ API
A deep learning, cross platform ML framework
Related Pages
Modules
Data Structures
Files
C++ API
Python API
GitHub
File List
Globals
aten
src
THNN
init.cpp
1
#include <TH/TH.h>
2
#include <THNN/THNN.h>
3
4
#include <TH/THTensor.hpp>
5
#include <cmath>
6
7
#define torch_(NAME) TH_CONCAT_3(torch_, Real, NAME)
8
#define nn_(NAME) TH_CONCAT_3(nn_, Real, NAME)
9
10
#define THNN_CHECK_SHAPE(I1, I2) \
11
if (I1 != NULL && I2 != NULL && !THTensor_(isSameSizeAs)(I1, I2)) \
12
{ \
13
THDescBuff s1 = THTensor_(sizeDesc)(I1); \
14
THDescBuff s2 = THTensor_(sizeDesc)(I2); \
15
THError(#I1 " and " #I2 " shapes do not match: " \
16
#I1 " %s, " #I2 " %s", s1.str, s2.str); \
17
}
18
19
#define THNN_CHECK_SHAPE_INDICES(I1, I2) \
20
if (I1 != NULL && I2 != NULL && !I1->sizes().equals(I2->sizes())) \
21
{ \
22
THDescBuff s1 = THTensor_(sizeDesc)(I1); \
23
THDescBuff s2 = THLongTensor_sizeDesc(I2); \
24
THError(#I1 " and " #I2 " shapes do not match: " \
25
#I1 " %s, " #I2 " %s", s1.str, s2.str); \
26
}
27
28
#define THNN_CHECK_NELEMENT(I1, I2) \
29
if (I1 != NULL && I2 != NULL ) { \
30
ptrdiff_t n1 = THTensor_(nElement)(I1); \
31
ptrdiff_t n2 = THTensor_(nElement)(I2); \
32
if (n1 != n2) \
33
{ \
34
THDescBuff s1 = THTensor_(sizeDesc)(I1); \
35
THDescBuff s2 = THTensor_(sizeDesc)(I2); \
36
THError(#I1 " and " #I2 " have different number of elements: " \
37
#I1 "%s has %ld elements, while " \
38
#I2 "%s has %ld elements", s1.str, n1, s2.str, n2); \
39
} \
40
}
41
42
#define THNN_CHECK_DIM_SIZE(T, DIM, DIM_SIZE, SIZE) \
43
if (THTensor_(nDimensionLegacyNoScalars)(T) != DIM || \
44
THTensor_sizeLegacyNoScalars(T, DIM_SIZE) != SIZE) { \
45
THDescBuff s1 = THTensor_(sizeDesc)(T); \
46
THError("Need " #T " of dimension %d and " #T ".size[%d] == %d" \
47
" but got " #T " to be of shape: %s", DIM, DIM_SIZE, SIZE, s1.str); \
48
}
49
50
#define THNN_CHECK_DIM_SIZE_INDICES(T, DIM, DIM_SIZE, SIZE) \
51
if (THIndexTensor_(nDimensionLegacyNoScalars)(T) != DIM || \
52
THTensor_sizeLegacyNoScalars(T, DIM_SIZE) != SIZE) { \
53
THDescBuff s1 = THIndexTensor_(sizeDesc)(T); \
54
THError("Need " #T " of dimension %d and " #T ".size[%d] == %d" \
55
" but got " #T " to be of shape: %s", DIM, DIM_SIZE, SIZE, s1.str); \
56
}
57
58
#define THNN_ARGCHECK(COND, ARG, T, FORMAT) \
59
if (!(COND)) { \
60
THDescBuff s1 = THTensor_(sizeDesc)(T); \
61
THArgCheck(COND, ARG, FORMAT, s1.str); \
62
}
63
64
#include <THNN/generic/AbsCriterion.c>
65
#include <TH/THGenerateFloatTypes.h>
66
67
#include <THNN/generic/BCECriterion.c>
68
#include <TH/THGenerateFloatTypes.h>
69
70
#include <THNN/generic/ClassNLLCriterion.c>
71
#include <TH/THGenerateFloatTypes.h>
72
73
#include <THNN/generic/Col2Im.c>
74
#include <TH/THGenerateFloatTypes.h>
75
76
#include <THNN/generic/ELU.c>
77
#include <TH/THGenerateFloatTypes.h>
78
79
#include <THNN/generic/HardTanh.c>
80
#include <TH/THGenerateFloatTypes.h>
81
82
#include <THNN/generic/Im2Col.c>
83
#include <TH/THGenerateFloatTypes.h>
84
85
#include <THNN/generic/GatedLinearUnit.c>
86
#include <TH/THGenerateFloatTypes.h>
87
88
#include <THNN/generic/LeakyReLU.c>
89
#include <TH/THGenerateFloatTypes.h>
90
91
#include <THNN/generic/LogSigmoid.c>
92
#include <TH/THGenerateFloatTypes.h>
93
94
#include <THNN/generic/MSECriterion.c>
95
#include <TH/THGenerateFloatTypes.h>
96
97
#include <THNN/generic/SoftMarginCriterion.c>
98
#include <TH/THGenerateFloatTypes.h>
99
100
#include <THNN/generic/MultiLabelMarginCriterion.c>
101
#include <TH/THGenerateFloatTypes.h>
102
103
#include <THNN/generic/MultiMarginCriterion.c>
104
#include <TH/THGenerateFloatTypes.h>
105
106
#include <THNN/generic/RReLU.c>
107
#include <TH/THGenerateFloatTypes.h>
108
109
#include <THNN/generic/Sigmoid.c>
110
#include <TH/THGenerateFloatTypes.h>
111
112
#include <THNN/generic/SmoothL1Criterion.c>
113
#include <TH/THGenerateFloatTypes.h>
114
115
#include <THNN/generic/SoftPlus.c>
116
#include <TH/THGenerateFloatTypes.h>
117
118
#include <THNN/generic/SoftShrink.c>
119
#include <TH/THGenerateFloatTypes.h>
120
121
#include <THNN/generic/IndexLinear.c>
122
#include <TH/THGenerateFloatTypes.h>
123
124
#include <THNN/generic/Tanh.c>
125
#include <TH/THGenerateFloatTypes.h>
126
127
#include <THNN/generic/TemporalRowConvolution.c>
128
#include <TH/THGenerateFloatTypes.h>
129
130
#include <THNN/generic/TemporalUpSamplingNearest.c>
131
#include <TH/THGenerateFloatTypes.h>
132
133
#include <THNN/generic/TemporalUpSamplingLinear.c>
134
#include <TH/THGenerateFloatTypes.h>
135
136
#include <THNN/generic/FeatureLPPooling.c>
137
#include <TH/THGenerateFloatTypes.h>
138
139
#include <THNN/generic/unfold.c>
140
#include <TH/THGenerateFloatTypes.h>
141
142
#include <THNN/generic/SpatialConvolutionMM.c>
143
#include <TH/THGenerateFloatTypes.h>
144
145
#include <THNN/generic/SpatialFullDilatedConvolution.c>
146
#include <TH/THGenerateFloatTypes.h>
147
148
#include <THNN/generic/SpatialDilatedConvolution.c>
149
#include <TH/THGenerateFloatTypes.h>
150
151
#include <THNN/generic/SpatialAdaptiveMaxPooling.c>
152
#include <TH/THGenerateFloatTypes.h>
153
154
#include <THNN/generic/SpatialAveragePooling.c>
155
#include <TH/THGenerateFloatTypes.h>
156
157
#include <THNN/generic/SpatialDilatedMaxPooling.c>
158
#include <TH/THGenerateFloatTypes.h>
159
160
#include <THNN/generic/SpatialMaxUnpooling.c>
161
#include <TH/THGenerateFloatTypes.h>
162
163
#include <THNN/generic/SpatialUpSamplingNearest.c>
164
#include <TH/THGenerateFloatTypes.h>
165
166
#include <THNN/generic/SpatialUpSamplingBilinear.c>
167
#include <TH/THGenerateFloatTypes.h>
168
169
#include <THNN/generic/VolumetricAveragePooling.c>
170
#include <TH/THGenerateFloatTypes.h>
171
172
#include <THNN/generic/SpatialUpSamplingBicubic.c>
173
#include <TH/THGenerateFloatTypes.h>
174
175
#include <THNN/generic/VolumetricConvolutionMM.c>
176
#include <TH/THGenerateFloatTypes.h>
177
178
#include <THNN/generic/VolumetricFullDilatedConvolution.c>
179
#include <TH/THGenerateFloatTypes.h>
180
181
#include <THNN/generic/VolumetricDilatedConvolution.c>
182
#include <TH/THGenerateFloatTypes.h>
183
184
#include <THNN/generic/VolumetricAdaptiveMaxPooling.c>
185
#include <TH/THGenerateFloatTypes.h>
186
187
#include <THNN/generic/VolumetricAdaptiveAveragePooling.c>
188
#include <TH/THGenerateFloatTypes.h>
189
190
#include <THNN/generic/VolumetricDilatedMaxPooling.c>
191
#include <TH/THGenerateFloatTypes.h>
192
193
#include <THNN/generic/VolumetricMaxUnpooling.c>
194
#include <TH/THGenerateFloatTypes.h>
195
196
#include <THNN/generic/VolumetricUpSamplingNearest.c>
197
#include <TH/THGenerateFloatTypes.h>
198
199
#include <THNN/generic/VolumetricUpSamplingTrilinear.c>
200
#include <TH/THGenerateFloatTypes.h>
201
202
#include <THNN/generic/SpatialClassNLLCriterion.c>
203
#include <TH/THGenerateFloatTypes.h>
Generated on Thu Mar 21 2019 13:06:10 for Caffe2 - C++ API by
1.8.11