Empty tensor returned by masked_select causes error in backward

Empty tensor returned by masked_select or some other advanced indexing methods will cause error in backward. Any method to make empty tensor differentiable or check an empty tensor? Thanks!

This seems like a bug, we’ll be fixing this.

You can track fix here: https://github.com/pytorch/pytorch/issues/2920

so, we looked into this further, this isn’t really a bug. masked_select will return a empty FloatTensor to you, but you cant really use that further in any autograd operations can you…
And if you call backward() on the empty tensor directly, it’ll give an appropriate error message.

Reviving this thread:

If an empty tensor is returned, shouldn’t the gradient be zero for all children?