File tree Expand file tree Collapse file tree 4 files changed +7
-10
lines changed Expand file tree Collapse file tree 4 files changed +7
-10
lines changed Original file line number Diff line number Diff line change 11cmake_minimum_required (VERSION 3.12)
22project (torchvision)
33set (CMAKE_CXX_STANDARD 14)
4- set (TORCHVISION_VERSION 0.7.0 )
4+ file ( STRINGS version .txt TORCHVISION_VERSION )
55
66option (WITH_CUDA "Enable CUDA support" OFF )
77
Original file line number Diff line number Diff line change 33#include < torchvision/vision.h>
44#include < torchvision/ops/nms.h>
55
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
116
127int main () {
138 torch::DeviceType device_type;
Original file line number Diff line number Diff line change 1515#else
1616#ifdef _MSC_VER
1717#define VISION_INLINE_VARIABLE __declspec (selectany)
18+ #define HINT_MSVC_LINKER_INCLUDE_SYMBOL
1819#else
1920#define VISION_INLINE_VARIABLE __attribute__ ((weak))
2021#endif
Original file line number Diff line number Diff line change @@ -7,9 +7,10 @@ namespace vision {
77VISION_API int64_t cuda_version ();
88
99namespace 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+
1415} // namespace detail
1516} // namespace vision
You can’t perform that action at this time.
0 commit comments