Convert a numpy array to sparse tensor

Say I have a numpy array like A:

[[1, 0, 0],
 [1, 0, 0],
 [0, 0, 1]]

How can I transfer A as a sparse tensor B?


Thank you for replying. But the sparse tensor is in COO format which means I need to know coordinates and values to create one. But the situation here is that I want to get B from A directly. Is there a way for doing this?

It would work if your PyTorch version >= 1.0.0

Right, I realize this is a stupid question. Thanks.