Skip to content

Commit a62733a

Browse files
larryliu0820facebook-github-bot
authored andcommitted
Move macros out of torch::executor namespace (#2436)
Summary: Pull Request resolved: #2436 So that we can use `EXECUTORCH_LIBRARY` and `WRAP_TO_ATEN` outside of `torch::executor` namespace. Reviewed By: lucylq Differential Revision: D54918164 fbshipit-source-id: 22ccd31daa9daa401c54f0811560095204bd6638
1 parent faaacbf commit a62733a

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

extension/aten_util/make_aten_functor_from_et_functor.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,16 @@ struct wrapper_impl<R (*)(Args...), f, int, N> {
164164
}
165165
};
166166

167+
} // namespace executor
168+
} // namespace torch
169+
167170
// Wrapper macro for out variant function. N is the index of the out tensor.
168171
// We need N to know how to preserve the semantics of modifying out tensor and
169172
// return the reference without allocating a new memory buffer for out tensor.
170173
#define _WRAP_2(func, N) \
171-
wrapper_impl<decltype(&func), func, decltype(N), N>::wrap
172-
#define _WRAP_1(func) wrapper_impl<decltype(&func), func>::wrap
174+
::torch::executor::wrapper_impl<decltype(&func), func, decltype(N), N>::wrap
175+
#define _WRAP_1(func) \
176+
::torch::executor::wrapper_impl<decltype(&func), func>::wrap
173177

174178
#define GET_MACRO(_1, _2, NAME, ...) NAME
175179
#define WRAP_TO_ATEN(...) GET_MACRO(__VA_ARGS__, _WRAP_2, _WRAP_1)(__VA_ARGS__)
176-
177-
} // namespace executor
178-
} // namespace torch

extension/kernel_util/make_boxed_from_unboxed_functor.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,10 @@ static Kernel make_boxed_kernel(const char* name, FuncType) {
138138
return Kernel(name, WrapUnboxedIntoFunctor<FuncType>::call);
139139
}
140140

141-
#define EXECUTORCH_LIBRARY(ns, op_name, func) \
142-
static auto res_##ns = register_kernels( \
143-
make_boxed_kernel(#ns "::" op_name, EXECUTORCH_FN(func)))
144141
} // namespace executor
145142
} // namespace torch
143+
144+
#define EXECUTORCH_LIBRARY(ns, op_name, func) \
145+
static auto res_##ns = ::torch::executor::register_kernels( \
146+
::torch::executor::make_boxed_kernel( \
147+
#ns "::" op_name, EXECUTORCH_FN(func)))

0 commit comments

Comments
 (0)