Skip to content

Commit a907b6a

Browse files
zou3519pytorchmergebot
authored andcommitted
[compiled_autograd] workaround windows compilation issue (#148454)
torch.compile doesn't work on windows so we can ifdef-away the problem. I do not know what the root cause actually is. Most notably, the pytorch windows build is fine, but some third-party projects that use pytorch headers on windows (e.g. torchaudio) have issues. Test Plan: - wait for CI Pull Request resolved: #148454 Approved by: https://github.com/atalman, https://github.com/xmfan
1 parent e02a2ca commit a907b6a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

torch/csrc/dynamo/compiled_autograd.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,13 @@ struct IValuePacker {
10571057
// That's what the TypePtr is for: it contains the information to do the
10581058
// parsing. See torch::jit::toIValue for more information.
10591059
static at::TypePtr packed_type() {
1060+
#ifdef _WIN32
1061+
// NB: the if-constexpr usage triggers compilation errors on Windows
1062+
// with certain compiler settings
1063+
// (see https://github.com/pytorch/pytorch/pull/144707 for examples).
1064+
// It's not clear what the problem is, so we're going to ignore it for now.
1065+
TORCH_INTERNAL_ASSERT(false, "torch.compile not supported on Windows");
1066+
#else
10601067
if constexpr (::std::is_same_v<T, at::Tensor>) {
10611068
return at::TensorType::get();
10621069
} else if constexpr (::std::is_same_v<T, int64_t>) {
@@ -1095,6 +1102,7 @@ struct IValuePacker {
10951102
TORCH_INTERNAL_ASSERT(false, "IValuePacker not implemented for type");
10961103
return at::NoneType::get();
10971104
}
1105+
#endif
10981106
}
10991107
};
11001108

0 commit comments

Comments
 (0)