Repository: pytorch
Issue: Occured error in loss.backward() when using sparse=True in Embedding layer
Labels: module: sparse,triaged,module: embedding

When I user embedding as a sparseTensor in AllReduce training mode, the gradient is calculated as sparseTensor, which is not supported.
```
        self.word_emb = Embedding(num_embeddings=config.params['vocabulary_size'],
                                  embedding_dim=config.params['emb_dim'],
                                  sparse=True)
```
Error
```File ".anaconda3/envs/ptx/lib/python3.7/site-packages/ptx/fit.py", line 1448, in _train_epoch
    loss.backward()
  File ".anaconda3/envs/ptx/lib/python3.7/site-packages/torch/tensor.py", line 185, in backward
    torch.autograd.backward(self, gradient, retain_graph, create_graph)
  File ".anaconda3/envs/ptx/lib/python3.7/site-packages/torch/autograd/__init__.py", line 127, in backward
    allow_unreachable=True)  # allow_unreachable flag
RuntimeError: Expected torch.cuda.FloatTensor, got torch.cuda.sparse.FloatTensor
Exception raised from operator() at /pytorch/torch/csrc/distributed/c10d/reducer.cpp:293 (most recent call first):
frame #0: c10::Error::Error(c10::SourceLocation, std::string) + 0x42 (0x7fedf71a31e2 in .anaconda3/envs/ptx/lib/python3.7/site-packages/torch/lib/libc10.so)
frame #1: <unknown function> + 0xa8d1b8 (0x7fedf80991b8 in .anaconda3/envs/ptx/lib/python3.7/site-packages/torch/lib/libtorch_python.so)
frame #2: c10d::Reducer::mark_variable_ready_dense(c10d::Reducer::VariableIndex) + 0x74 (0x7fedf8095ea4 in .anaconda3/envs/ptx/lib/python3.7/site-packages/torch/lib/libtorch_python.so)
frame #3: c10d::Reducer::mark_variable_ready(c10d::Reducer::VariableIndex) + 0x111 (0x7fedf809a4b1 in .anaconda3/envs/ptx/lib/python3.7/site-packages/torch/lib/libtorch_python.so)
frame #4: c10d::Reducer::autograd_hook(c10d::Reducer::VariableIndex) + 0xef (0x7fedf809cf7f in .anaconda3/envs/ptx/lib/python3.7/site-packages/torch/lib/libtorch_python.so)
frame #5: <unknown function> + 0xa910e6 (0x7fedf809d0e6 in .anaconda3/envs/ptx/lib/python3.7/site-packages/torch/lib/libtorch_python.so)
frame #6: <unknown function> + 0xa95bb6 (0x7fedf80a1bb6 in .anaconda3/envs/ptx/lib/python3.7/site-packages/torch/lib/libtorch_python.so)
frame #7: torch::autograd::Engine::evaluate_function(std::shared_ptr<torch::autograd::GraphTask>&, torch::autograd::Node*, torch::autograd::InputBuffer&, std::shared_ptr<torch::autograd::ReadyQueue> const&) + 0x4dd (0x7fedc89554dd in.anaconda3/envs/ptx/lib/python3.7/site-packages/torch/lib/libtorch_cpu.so)
frame #8: torch::autograd::Engine::thread_main(std::shared_ptr<torch::autograd::GraphTask> const&) + 0x451 (0x7fedc8956fa1 in .anaconda3/envs/ptx/lib/python3.7/site-packages/torch/lib/libtorch_cpu.so)
frame #9: torch::autograd::Engine::thread_init(int, std::shared_ptr<torch::autograd::ReadyQueue> const&, bool) + 0x89 (0x7fedc894f119 in .anaconda3/envs/ptx/lib/python3.7/site-packages/torch/lib/libtorch_cpu.so)
frame #10: torch::autograd::python::PythonEngine::thread_init(int, std::shared_ptr<torch::autograd::ReadyQueue> const&, b
ool) + 0x4a (0x7f1d0ea59c8a in .anaconda3/envs/ptx/lib/python3.7/site-packages/torch/lib/libtorch_pyt
hon.so)
frame #11: <unknown function> + 0xb9e6f (0x7f1d7adf2e6f in /usr/lib/x86_64-linux-gnu/libstdc++.so.6)
frame #12: <unknown function> + 0x74a4 (0x7f1d7f7374a4 in /lib/x86_64-linux-gnu/libpthread.so.0)
frame #13: clone + 0x3f (0x7f1d7f479d0f in /lib/x86_64-linux-gnu/libc.so.6)```

cc @aocsa @nikitaved @pearu @mruberry