Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion aten/src/ATen/native/mkldnn/TensorShape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ Tensor mkldnn_reshape(const Tensor& self, IntArrayRef size) {

Tensor mkldnn_clone(const Tensor& self) {
ideep::tensor& src = itensor_from_mkldnn(self);
ideep::tensor dst{src};
ideep::tensor dst;
ideep::direct_copy::compute<AllocForMKLDNN>(src, dst);
return new_with_itensor_mkldnn(std::move(dst), self.options());
}

Expand Down
7 changes: 7 additions & 0 deletions test/test_mkldnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,13 @@ def test_clone(self):
x.clone(),
x.to_mkldnn().clone().to_dense(),
)
# test whether share same memory
y = x.to_mkldnn()
z = y.clone().add_(y)
self.assertNotEqual(
y.to_dense(),
z.to_dense(),
)

def test_linear(self):
in_features = torch.randint(3, 10, (1,)).item()
Expand Down