Skip to content

Commit 9dc6c53

Browse files
swolchokSacha Refshauge
authored and
Sacha Refshauge
committed
[PyTorch] Don't inline Dispatcher::call on mobile (pytorch#53197)
Summary: Pull Request resolved: pytorch#53197 This probably causes a code size blowup and we care more about the size savings than the incremental perf on mobile. ghstack-source-id: 122977713 Test Plan: buildsizebot some mobile apps Reviewed By: dhruvbird Differential Revision: D26731181 fbshipit-source-id: 78a926278a85028af09bfa0731d4d59a55ee3746
1 parent 484834b commit 9dc6c53

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

aten/src/ATen/core/dispatch/Dispatcher.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414

1515
#include <ATen/core/grad_mode.h>
1616

17+
#if C10_MOBILE
18+
#define C10_DISPATCHER_INLINE_UNLESS_MOBILE inline
19+
#else
20+
#define C10_DISPATCHER_INLINE_UNLESS_MOBILE C10_ALWAYS_INLINE
21+
#endif
1722
namespace c10 {
1823

1924
class TORCH_API OperatorHandle;
@@ -422,7 +427,7 @@ inline Return Dispatcher::callWithDispatchKeySlowPath(const TypedOperatorHandle<
422427
}
423428

424429
template<class Return, class... Args>
425-
C10_ALWAYS_INLINE Return Dispatcher::call(const TypedOperatorHandle<Return(Args...)>& op, Args... args) const {
430+
C10_DISPATCHER_INLINE_UNLESS_MOBILE Return Dispatcher::call(const TypedOperatorHandle<Return(Args...)>& op, Args... args) const {
426431
detail::unused_arg_(args...); // workaround for a false-positive warning about unused parameters in gcc 5
427432
auto dispatchKeySet = op.operatorDef_->op.dispatchKeyExtractor()
428433
.template getDispatchKeySetUnboxed<Args...>(

0 commit comments

Comments
 (0)