-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Closed
Labels
module: mkldnnRelated to Intel IDEEP or oneDNN (a.k.a. mkldnn) integrationRelated to Intel IDEEP or oneDNN (a.k.a. mkldnn) integrationtriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Description
🐛 Bug
There has a bug when clone a MKLDNN tensor, it seems that this clone share the same memory which is different with CPU tensor's clone .
To Reproduce
Using latest pytorch:
Steps to reproduce the behavior:
import torch
a = torch.randn(2, 3).to_mkldnn()
c = torch.randn(2, 3).to_mkldnn()
b = torch.clone(a)
b.add_(c)
print(a)
print(b)
you can see that tensor a is also changed after change tensor b.
I found the code mkldnn_clone seems wrong, the return tensor share the same memory with input tensor. it shoud write as :
Tensor mkldnn_clone(const Tensor& self) {
ideep::tensor& src = itensor_from_mkldnn(self);
ideep::tensor dst;
ideep::direct_copy::compute<AllocForMKLDNN>(src, dst);
return new_with_itensor_mkldnn(std::move(dst), self.options());
}
Thanks!
Metadata
Metadata
Assignees
Labels
module: mkldnnRelated to Intel IDEEP or oneDNN (a.k.a. mkldnn) integrationRelated to Intel IDEEP or oneDNN (a.k.a. mkldnn) integrationtriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module