1 | // required for old g++ to compile PRId64 macros, see |
2 | // https://github.com/pytorch/pytorch/issues/3571 |
3 | // for context |
4 | #ifndef __STDC_FORMAT_MACROS |
5 | #define __STDC_FORMAT_MACROS |
6 | #endif |
7 | |
8 | // an external backend might generate file within its code tree |
9 | // and check all the source files within the tree with clang-format. |
10 | // so, disable it since the backend might have a different config. |
11 | // clang-format off |
12 | |
13 | // NOTE: This condition is true for all PyTorch internal libraries, it |
14 | // just excludes external projects such as torch_xla which |
15 | // re-use some of the PyTorch codegen machinery. |
16 | #if defined(CAFFE2_BUILD_MAIN_LIB) || \ |
17 | defined(TORCH_CUDA_BUILD_MAIN_LIB) || \ |
18 | defined(TORCH_HIP_BUILD_MAIN_LIB) || \ |
19 | defined(TORCH_CUDA_CU_BUILD_MAIN_LIB) || \ |
20 | defined(TORCH_CUDA_CPP_BUILD_MAIN_LIB) |
21 | #define TORCH_ASSERT_ONLY_METHOD_OPERATORS |
22 | #endif |
23 | |
24 | // @generated by torchgen/gen.py from RegisterDispatchKey.cpp |
25 | |
26 | #include <c10/core/TensorImpl.h> |
27 | #include <c10/core/Allocator.h> |
28 | #include <ATen/DeviceGuard.h> |
29 | #include <ATen/NamedTensorUtils.h> |
30 | #include <ATen/Utils.h> |
31 | #include <ATen/WrapDimUtils.h> |
32 | #include <ATen/Dispatch.h> |
33 | #include <c10/util/ExclusivelyOwned.h> |
34 | #include <c10/util/Half.h> |
35 | #include <c10/core/UndefinedTensorImpl.h> |
36 | #include <c10/util/Optional.h> |
37 | #include <ATen/Tensor.h> |
38 | #include <ATen/native/Resize.h> |
39 | |
40 | #include <cstddef> |
41 | #include <functional> |
42 | #include <memory> |
43 | #include <utility> |
44 | |
45 | #include <ATen/Config.h> |
46 | #include <ATen/core/op_registration/adaption.h> |
47 | #include <torch/library.h> |
48 | |
49 | |
50 | #include <ATen/ops/as_strided_native.h> |
51 | #include <ATen/ops/empty.h> |
52 | #include <ATen/ops/empty_strided.h> |
53 | #include <ATen/ops/_copy_from_and_resize.h> |
54 | #include <ATen/ops/_copy_from.h> |
55 | #include <ATen/ops/reshape_as_compositeimplicitautogradnestedtensor_dispatch.h> |
56 | #include <ATen/ops/reshape_as_native.h> |
57 | #include <ATen/ops/reshape_compositeimplicitautogradnestedtensor_dispatch.h> |
58 | #include <ATen/ops/reshape_native.h> |
59 | #include <ATen/ops/unbind_compositeimplicitautogradnestedtensor_dispatch.h> |
60 | #include <ATen/ops/unbind_native.h> |
61 | |
62 | // See template file RegisterDispatchDefinitions.ini |
63 | namespace at { |
64 | // NB: TORCH_LIBRARY_IMPL must be in an anonymous namespace to avoid |
65 | // ambiguity with conflicting identifiers that may have been defined in |
66 | // at namespace already. |
67 | namespace { |
68 | namespace { |
69 | at::Tensor wrapper_CompositeImplicitAutogradNestedTensor__reshape(const at::Tensor & self, c10::SymIntArrayRef shape) { |
70 | // No device check |
71 | // DeviceGuard omitted |
72 | return at::native::reshape_nested(self, C10_AS_INTARRAYREF_SLOW(shape)); |
73 | } |
74 | } // anonymous namespace |
75 | namespace { |
76 | at::Tensor wrapper_CompositeImplicitAutogradNestedTensor__reshape_as(const at::Tensor & self, const at::Tensor & other) { |
77 | // No device check |
78 | // DeviceGuard omitted |
79 | return at::native::reshape_as_nested(self, other); |
80 | } |
81 | } // anonymous namespace |
82 | namespace { |
83 | ::std::vector<at::Tensor> wrapper_CompositeImplicitAutogradNestedTensor_int_unbind(const at::Tensor & self, int64_t dim) { |
84 | // No device check |
85 | // DeviceGuard omitted |
86 | return at::native::NestedTensor_unbind(self, dim); |
87 | } |
88 | } // anonymous namespace |
89 | TORCH_LIBRARY_IMPL(aten, CompositeImplicitAutogradNestedTensor, m) { |
90 | m.impl("reshape" , |
91 | TORCH_FN(wrapper_CompositeImplicitAutogradNestedTensor__reshape)); |
92 | m.impl("reshape_as" , |
93 | TORCH_FN(wrapper_CompositeImplicitAutogradNestedTensor__reshape_as)); |
94 | m.impl("unbind.int" , |
95 | TORCH_FN(wrapper_CompositeImplicitAutogradNestedTensor_int_unbind)); |
96 | }; |
97 | } // anonymous namespace |
98 | namespace compositeimplicitautogradnestedtensor { |
99 | at::Tensor reshape(const at::Tensor & self, at::IntArrayRef shape) { |
100 | return wrapper_CompositeImplicitAutogradNestedTensor__reshape(self, c10::fromIntArrayRefSlow(shape)); |
101 | } |
102 | at::Tensor reshape_symint(const at::Tensor & self, c10::SymIntArrayRef shape) { |
103 | return wrapper_CompositeImplicitAutogradNestedTensor__reshape(self, shape); |
104 | } |
105 | at::Tensor reshape_as(const at::Tensor & self, const at::Tensor & other) { |
106 | return wrapper_CompositeImplicitAutogradNestedTensor__reshape_as(self, other); |
107 | } |
108 | ::std::vector<at::Tensor> unbind(const at::Tensor & self, int64_t dim) { |
109 | return wrapper_CompositeImplicitAutogradNestedTensor_int_unbind(self, dim); |
110 | } |
111 | } // namespace compositeimplicitautogradnestedtensor |
112 | } // namespace at |
113 | |