Skip to content

Commit

Permalink
Don't inline on Windows on "[PyTorch] Make tls_local_dispatch_key_set…
Browse files Browse the repository at this point in the history
… inlineable (reapply)"

FLAGS_disable_variable_dispatch had to go, but it looks like the only user was some benchmarks anyway.

Differential Revision: [D25547962](https://our.internmc.facebook.com/intern/diff/D25547962/)

**NOTE FOR REVIEWERS**: This PR has internal Facebook specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D25547962/)!

[ghstack-poisoned]
  • Loading branch information
swolchok committed Dec 16, 2020
2 parents bff6c5a + 8abbcf1 commit 09a59b9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions aten/src/ATen/native/cpu/CatKernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ struct InputMeta {

template <typename scalar_t>
void cat_serial_kernel_impl(Tensor& result, TensorList tensors, int64_t dim) {
TORCH_INTERNAL_ASSERT_DEBUG_ONLY(
dim >= 0 && dim < result.dim(), "dim out of range in cat_serial_kernel_impl");
int64_t outer = result.numel() / (result.sizes()[dim] * result.strides()[dim]);
scalar_t* result_data = result.data_ptr<scalar_t>();
int64_t ninputs = tensors.size();
Expand Down
6 changes: 6 additions & 0 deletions c10/core/impl/LocalDispatchKeySet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ PODLocalDispatchKeySet raw_local_dispatch_key_set;

#endif

#ifdef _MSC_VER
LocalDispatchKeySet tls_local_dispatch_key_set() {
return raw_local_dispatch_key_set;
}
#endif // _MSC_VER

void _force_tls_local_dispatch_key_set(LocalDispatchKeySet key_set) {
raw_local_dispatch_key_set = PODLocalDispatchKeySet {
key_set.included_.raw_repr(),
Expand Down
5 changes: 5 additions & 0 deletions c10/core/impl/LocalDispatchKeySet.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ struct C10_API LocalDispatchKeySet {
DispatchKeySet excluded_;
};

// thread_local variables cannot be C10_API on Windows.
#ifdef _MSC_VER
C10_API LocalDispatchKeySet tls_local_dispatch_key_set();
#else // _MSC_VER
/// In the CAFFE2_FB_LIMITED_MOBILE_CAPABILITY build setting,
/// thread_local is not supported.
#ifndef CAFFE2_FB_LIMITED_MOBILE_CAPABILITY
Expand All @@ -65,6 +69,7 @@ inline C10_API LocalDispatchKeySet tls_local_dispatch_key_set() {
// because they include this header.
return raw_local_dispatch_key_set;
}
#endif // _MSC_VER

// Internal, use ThreadLocalStateGuard
C10_API void _force_tls_local_dispatch_key_set(LocalDispatchKeySet key_set);
Expand Down

0 comments on commit 09a59b9

Please sign in to comment.