@@ -155,10 +155,14 @@ void THCudaTensor_addcmul(THCState *state, THCudaTensor *self_, THCudaTensor *t,
155
155
THCudaTensor_resizeAs (state, self_, t);
156
156
THCudaTensor_copy (state, self_, t);
157
157
}
158
- THCudaTensor_resizeAs (state, self_, src1);
158
+ else
159
+ {
160
+ THArgCheck (THCudaTensor_nElement (state, self_) == THCudaTensor_nElement (state, src1),
161
+ 1 , " sizes do not match" );
162
+ }
159
163
160
- THArgCheck (THCudaTensor_nElement (state, src1) ==
161
- THCudaTensor_nElement (state, src2), 3 , " sizes do not match" );
164
+ THArgCheck (THCudaTensor_nElement (state, src1) == THCudaTensor_nElement (state, src2),
165
+ 3 , " sizes do not match" );
162
166
163
167
if (!THCudaTensor_pointwiseApply3 (state, self_, src1, src2, TensorAddCMulOp (value))) {
164
168
THArgCheck (false , 2 , CUTORCH_DIM_WARNING);
@@ -186,9 +190,13 @@ void THCudaTensor_addcdiv(THCState *state, THCudaTensor *self_, THCudaTensor *t,
186
190
THCudaTensor_resizeAs (state, self_, t);
187
191
THCudaTensor_copy (state, self_, t);
188
192
}
189
-
190
- THCudaTensor_resizeAs (state, self_, src1);
191
- THArgCheck (THCudaTensor_nElement (state, src1) == THCudaTensor_nElement (state, src2), 3 , " sizes do not match" );
193
+ else
194
+ {
195
+ THArgCheck (THCudaTensor_nElement (state, self_) == THCudaTensor_nElement (state, src1),
196
+ 1 , " sizes do not match" );
197
+ }
198
+ THArgCheck (THCudaTensor_nElement (state, src1) == THCudaTensor_nElement (state, src2),
199
+ 3 , " sizes do not match" );
192
200
193
201
if (!THCudaTensor_pointwiseApply3 (state, self_, src1, src2, TensorAddCDivOp (value))) {
194
202
THArgCheck (false , 2 , CUTORCH_DIM_WARNING);
0 commit comments