File tree 4 files changed +7
-10
lines changed
4 files changed +7
-10
lines changed Original file line number Diff line number Diff line change 1
1
cmake_minimum_required (VERSION 3.12)
2
2
project (torchvision)
3
3
set (CMAKE_CXX_STANDARD 14)
4
- set (TORCHVISION_VERSION 0.7.0 )
4
+ file ( STRINGS version .txt TORCHVISION_VERSION )
5
5
6
6
option (WITH_CUDA "Enable CUDA support" OFF )
7
7
Original file line number Diff line number Diff line change 3
3
#include < torchvision/vision.h>
4
4
#include < torchvision/ops/nms.h>
5
5
6
- #ifdef _WIN32
7
- // Windows only
8
- // This is necessary until operators are automatically registered on include
9
- static auto _nms = &vision::ops::nms;
10
- #endif
11
6
12
7
int main () {
13
8
torch::DeviceType device_type;
Original file line number Diff line number Diff line change 15
15
#else
16
16
#ifdef _MSC_VER
17
17
#define VISION_INLINE_VARIABLE __declspec (selectany)
18
+ #define HINT_MSVC_LINKER_INCLUDE_SYMBOL
18
19
#else
19
20
#define VISION_INLINE_VARIABLE __attribute__ ((weak))
20
21
#endif
Original file line number Diff line number Diff line change @@ -7,9 +7,10 @@ namespace vision {
7
7
VISION_API int64_t cuda_version ();
8
8
9
9
namespace detail {
10
- // Dummy variable to reference a symbol from vision.cpp.
11
- // This ensures that the torchvision library and the ops registration
12
- // initializers are not pruned.
13
- VISION_INLINE_VARIABLE int64_t _cuda_version = cuda_version();
10
+ extern " C" VISION_INLINE_VARIABLE auto _register_ops = &cuda_version;
11
+ #ifdef HINT_MSVC_LINKER_INCLUDE_SYMBOL
12
+ #pragma comment(linker, "/include:_register_ops")
13
+ #endif
14
+
14
15
} // namespace detail
15
16
} // namespace vision
You can’t perform that action at this time.
0 commit comments