Repository navigation
fix: enable torchembedding deepcopy - #1143
Conversation
Signed-off-by: AnneY <[email protected]>
|
After the modification import torch
from docarray import BaseDocument
from docarray.typing.tensor.embedding.torch import TorchEmbedding
class Meow(BaseDocument):
embedding : TorchEmbedding
a = Meow(embedding=torch.randn(42))
print(id(a.embedding), id(a.copy(deep=True).embedding))output has no error |
|
Can u add to test to check that it is actual deep copied and not shallow copy ? |
Signed-off-by: AnneY <[email protected]>
|
Can you explain this fix briefly? It is not obvious to me why this is fixing it |
The deepcopy error is thrown from here https://github.com/pytorch/pytorch/blob/master/torch/_tensor.py#L170, and lines above are new_tensor = self.new_empty([])
if type(new_tensor) is not type(self):where So according to the error msg, I should implement |
@AnneYang720 can u add this to the docstring of |
Signed-off-by: AnneY <[email protected]>
|
📝 Docs are deployed on https://ft-fix-torchembedding-deepcopy--jina-docs.netlify.app 🎉 |
Goals:
This PR is related to #1131