| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Signed-off-by: AnneY <evangeline-lun@foxmail.com>
|
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 140248435632272 140248435636032 |
Sorry, something went wrong.
|
Can u add to test to check that it is actual deep copied and not shallow copy ? |
Sorry, something went wrong.
Signed-off-by: AnneY <evangeline-lun@foxmail.com>
Signed-off-by: AnneY <evangeline-lun@foxmail.com>
|
Can you explain this fix briefly? It is not obvious to me why this is fixing it |
Sorry, something went wrong.
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 type(new_tensor) is <class 'torch.Tensor'> and So according to the error msg, I should implement new_empty() for the subclass, which means the new_tensor should also be a TorchEmbedding. |
Sorry, something went wrong.
@AnneYang720 can u add this to the docstring of new_empty in your PR so that ppl who will read the code will understand the same ? |
Sorry, something went wrong.
Signed-off-by: AnneY <evangeline-lun@foxmail.com>
|
📝 Docs are deployed on https://ft-fix-torchembedding-deepcopy--jina-docs.netlify.app 🎉 |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Goals:
This PR is related to #1131