1 #define TORCH_ASSERT_ONLY_METHOD_OPERATORS
2 #include <ATen/core/Tensor.h>
3 #include <ATen/Config.h>
4
5 #ifndef AT_PER_OPERATOR_HEADERS
6 #include <ATen/NativeFunctions.h>
7 #else
8 #include <ATen/ops/copy_native.h>
9 #endif
10
11 #if !AT_MKLDNN_ENABLED()
12
13 namespace at {
14 namespace native {
15
copy_mkldnn_(Tensor & self,const Tensor & src,bool non_blocking)16 Tensor& copy_mkldnn_(Tensor& self, const Tensor& src, bool non_blocking) {
17 TORCH_CHECK(false, "copy_mkldnn_: ATen not compiled with MKLDNN support");
18 }
19
20 } // namespace native
21 } // namespace at
22
23 #else // AT_MKLDNN_ENABLED
24
25 #include <ATen/native/mkldnn/MKLDNNCommon.h>
26
27 namespace at {
28 namespace native {
29
copy_mkldnn_(Tensor & self,const Tensor & src,bool non_blocking)30 Tensor& copy_mkldnn_(Tensor& self, const Tensor& src, bool non_blocking) {
31 TORCH_CHECK(
32 self.sizes() == src.sizes(),
33 "copy_mkldnn_: only support same size tensor.");
34 TORCH_CHECK(
35 self.is_mkldnn() && src.is_mkldnn(),
36 "copy_mkldnn_: between mkldnn layout and dense Tensors is not implemented! Found self type = ",
37 self.toString(),
38 " and src type = ",
39 src.toString());
40 ideep::tensor& x = itensor_from_mkldnn(src);
41 ideep::tensor& y = itensor_from_mkldnn(self);
42 ideep::direct_copy::compute(x, y);
43 return self;
44 }
45
46 } // namespace native
47 } // namespace at
48
49 #endif // AT_MKLDNN_ENABLED
50