@@ -340,15 +340,15 @@ void ElementwiseDivGrad(const GPUContext &dev_ctx,
340
340
DenseTensor *dy,
341
341
int axis = -1 ) {
342
342
const auto place = dev_ctx.GetPlace ();
343
- if (dx->numel () == 0 ) {
343
+ if (dx != nullptr && dx ->numel () == 0 ) {
344
344
dev_ctx.Alloc <T>(dx);
345
345
}
346
346
347
- if (dy->numel () == 0 ) {
347
+ if (dy != nullptr && dy ->numel () == 0 ) {
348
348
dev_ctx.Alloc <T>(dy);
349
349
}
350
350
351
- bool need_dx = (dx != nullptr ) && (dy ->numel () != 0 );
351
+ bool need_dx = (dx != nullptr ) && (dx ->numel () != 0 );
352
352
bool need_dy = (dy != nullptr ) && (dy->numel () != 0 );
353
353
if (need_dx && need_dy) {
354
354
std::vector<const DenseTensor *> ins = {&dout, &out, &y};
@@ -387,15 +387,15 @@ void ElementwiseMulGrad(const GPUContext &dev_ctx,
387
387
int axis) {
388
388
const auto place = dev_ctx.GetPlace ();
389
389
390
- if (dx->numel () == 0 ) {
390
+ if (dx != nullptr && dx ->numel () == 0 ) {
391
391
dev_ctx.Alloc <T>(dx);
392
392
}
393
393
394
- if (dy->numel () == 0 ) {
394
+ if (dy != nullptr && dy ->numel () == 0 ) {
395
395
dev_ctx.Alloc <T>(dy);
396
396
}
397
397
398
- bool need_dx = (dx != nullptr ) && (dy ->numel () != 0 );
398
+ bool need_dx = (dx != nullptr ) && (dx ->numel () != 0 );
399
399
bool need_dy = (dy != nullptr ) && (dy->numel () != 0 );
400
400
if (need_dy && need_dy) {
401
401
std::vector<const DenseTensor *> ins = {&dout, &y, &x};
0 commit comments