Skip to content

Commit

Permalink
return if input numel is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
v0dro committed Jan 7, 2021
1 parent 4ef5707 commit 76aa2ab
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions aten/src/ATen/native/LossMultiMargin.cpp
Expand Up @@ -212,6 +212,10 @@ void multi_margin_loss_backward_out_cpu_template(
grad_input.resize_as_(input);
TORCH_CHECK(grad_input.is_contiguous(), "grad_input must be contiguous");

if (input.numel() == 0) {
return;
}

auto input_contiguous = input.contiguous();
auto target_contiguous = target.contiguous();
auto weight_contiguous = weight.contiguous();
Expand Down

0 comments on commit 76aa2ab

Please sign in to comment.