forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.cpp
146 lines (110 loc) · 5.24 KB
/
init.cpp
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#include <TH/TH.h>
#include <THNN/THNN.h>
#include <TH/THTensor.hpp>
#include <cmath>
#define torch_(NAME) TH_CONCAT_3(torch_, Real, NAME)
#define nn_(NAME) TH_CONCAT_3(nn_, Real, NAME)
#define THNN_CHECK_SHAPE(I1, I2) \
if (I1 != NULL && I2 != NULL && !THTensor_(isSameSizeAs)(I1, I2)) \
{ \
THDescBuff s1 = THTensor_(sizeDesc)(I1); \
THDescBuff s2 = THTensor_(sizeDesc)(I2); \
THError(#I1 " and " #I2 " shapes do not match: " \
#I1 " %s, " #I2 " %s", s1.str, s2.str); \
}
#define THNN_CHECK_SHAPE_INDICES(I1, I2) \
if (I1 != NULL && I2 != NULL && !I1->sizes().equals(I2->sizes())) \
{ \
THDescBuff s1 = THTensor_(sizeDesc)(I1); \
THDescBuff s2 = THLongTensor_sizeDesc(I2); \
THError(#I1 " and " #I2 " shapes do not match: " \
#I1 " %s, " #I2 " %s", s1.str, s2.str); \
}
#define THNN_CHECK_NELEMENT(I1, I2) \
if (I1 != NULL && I2 != NULL ) { \
ptrdiff_t n1 = THTensor_(nElement)(I1); \
ptrdiff_t n2 = THTensor_(nElement)(I2); \
if (n1 != n2) \
{ \
THDescBuff s1 = THTensor_(sizeDesc)(I1); \
THDescBuff s2 = THTensor_(sizeDesc)(I2); \
THError(#I1 " and " #I2 " have different number of elements: " \
#I1 "%s has %ld elements, while " \
#I2 "%s has %ld elements", s1.str, n1, s2.str, n2); \
} \
}
#define THNN_CHECK_DIM_SIZE(T, DIM, DIM_SIZE, SIZE) \
if (THTensor_(nDimensionLegacyNoScalars)(T) != DIM || \
THTensor_sizeLegacyNoScalars(T, DIM_SIZE) != SIZE) { \
THDescBuff s1 = THTensor_(sizeDesc)(T); \
THError("Need " #T " of dimension %d and " #T ".size[%d] == %d" \
" but got " #T " to be of shape: %s", DIM, DIM_SIZE, SIZE, s1.str); \
}
#define THNN_CHECK_DIM_SIZE_INDICES(T, DIM, DIM_SIZE, SIZE) \
if (THIndexTensor_(nDimensionLegacyNoScalars)(T) != DIM || \
THTensor_sizeLegacyNoScalars(T, DIM_SIZE) != SIZE) { \
THDescBuff s1 = THIndexTensor_(sizeDesc)(T); \
THError("Need " #T " of dimension %d and " #T ".size[%d] == %d" \
" but got " #T " to be of shape: %s", DIM, DIM_SIZE, SIZE, s1.str); \
}
#define THNN_ARGCHECK(COND, ARG, T, FORMAT) \
if (!(COND)) { \
THDescBuff s1 = THTensor_(sizeDesc)(T); \
THArgCheck(COND, ARG, FORMAT, s1.str); \
}
#include <THNN/generic/AbsCriterion.c>
#include <TH/THGenerateFloatTypes.h>
#include <THNN/generic/BCECriterion.c>
#include <TH/THGenerateFloatTypes.h>
#include <THNN/generic/ClassNLLCriterion.c>
#include <TH/THGenerateFloatTypes.h>
#include <THNN/generic/ClassNLLCriterion.c>
#include <TH/THGenerateBFloat16Type.h>
#include <THNN/generic/ELU.c>
#include <TH/THGenerateFloatTypes.h>
#include <THNN/generic/HardTanh.c>
#include <TH/THGenerateFloatTypes.h>
#include <THNN/generic/GatedLinearUnit.c>
#include <TH/THGenerateFloatTypes.h>
#include <THNN/generic/LeakyReLU.c>
#include <TH/THGenerateFloatTypes.h>
#include <THNN/generic/LogSigmoid.c>
#include <TH/THGenerateFloatTypes.h>
#include <THNN/generic/MSECriterion.c>
#include <TH/THGenerateFloatTypes.h>
#include <THNN/generic/SoftMarginCriterion.c>
#include <TH/THGenerateFloatTypes.h>
#include <THNN/generic/MultiLabelMarginCriterion.c>
#include <TH/THGenerateFloatTypes.h>
#include <THNN/generic/MultiMarginCriterion.c>
#include <TH/THGenerateFloatTypes.h>
#include <THNN/generic/RReLU.c>
#include <TH/THGenerateFloatTypes.h>
#include <THNN/generic/Sigmoid.c>
#include <TH/THGenerateFloatTypes.h>
#include <THNN/generic/SmoothL1Criterion.c>
#include <TH/THGenerateFloatTypes.h>
#include <THNN/generic/SoftPlus.c>
#include <TH/THGenerateFloatTypes.h>
#include <THNN/generic/SoftShrink.c>
#include <TH/THGenerateFloatTypes.h>
#include <THNN/generic/IndexLinear.c>
#include <TH/THGenerateFloatTypes.h>
#include <THNN/generic/Tanh.c>
#include <TH/THGenerateFloatTypes.h>
#include <THNN/generic/FeatureLPPooling.c>
#include <TH/THGenerateFloatTypes.h>
#include <THNN/generic/unfold.c>
#include <TH/THGenerateLongType.h>
#include <THNN/generic/unfold.c>
#include <TH/THGenerateFloatTypes.h>
#include <THNN/generic/SpatialConvolutionMM.c>
#include <TH/THGenerateLongType.h>
#include <THNN/generic/SpatialConvolutionMM.c>
#include <TH/THGenerateFloatTypes.h>
#include <THNN/generic/VolumetricConvolutionMM.c>
#include <TH/THGenerateLongType.h>
#include <THNN/generic/VolumetricConvolutionMM.c>
#include <TH/THGenerateFloatTypes.h>
#include <THNN/generic/SpatialClassNLLCriterion.c>
#include <TH/THGenerateFloatTypes.h>