1
+ #include " ../precomp.hpp"
1
2
#if defined(ENABLE_TORCH_IMPORTER) && ENABLE_TORCH_IMPORTER
2
3
#include < opencv2/core.hpp>
3
4
@@ -14,7 +15,9 @@ extern "C"
14
15
{
15
16
16
17
#ifndef TH_HAVE_THREAD
17
- #define __thread
18
+ #define TH_THREAD
19
+ #else
20
+ #define TH_THREAD __thread
18
21
#endif
19
22
20
23
/* Torch Error Handling */
@@ -23,8 +26,8 @@ static void defaultTorchErrorHandlerFunction(const char *msg, void*)
23
26
CV_Error (cv::Error::StsError, cv::String (" Torch Error: " ) + msg);
24
27
}
25
28
26
- static __thread void (*torchErrorHandlerFunction)(const char *msg, void *data) = defaultTorchErrorHandlerFunction;
27
- static __thread void *torchErrorHandlerData;
29
+ static TH_THREAD void (*torchErrorHandlerFunction)(const char *msg, void *data) = defaultTorchErrorHandlerFunction;
30
+ static TH_THREAD void *torchErrorHandlerData;
28
31
29
32
void _THError (const char *file, const int line, const char *fmt, ...)
30
33
{
@@ -71,8 +74,8 @@ static void defaultTorchArgErrorHandlerFunction(int argNumber, const char *msg,
71
74
CV_Error (cv::Error::StsError, cv::format (" Invalid argument %d" , argNumber));
72
75
}
73
76
74
- static __thread void (*torchArgErrorHandlerFunction)(int argNumber, const char *msg, void *data) = defaultTorchArgErrorHandlerFunction;
75
- static __thread void *torchArgErrorHandlerData;
77
+ static TH_THREAD void (*torchArgErrorHandlerFunction)(int argNumber, const char *msg, void *data) = defaultTorchArgErrorHandlerFunction;
78
+ static TH_THREAD void *torchArgErrorHandlerData;
76
79
77
80
void _THArgCheck (const char *file, int line, int condition, int argNumber, const char *fmt, ...)
78
81
{
@@ -103,10 +106,10 @@ void THSetArgErrorHandler( void (*torchArgErrorHandlerFunction_)(int argNumber,
103
106
torchArgErrorHandlerData = data;
104
107
}
105
108
106
- static __thread void (*torchGCFunction)(void *data) = NULL;
107
- static __thread void *torchGCData;
108
- static __thread long torchHeapSize = 0 ;
109
- static __thread long torchHeapSizeSoftMax = 300000000 ; // 300MB, adjusted upward dynamically
109
+ static TH_THREAD void (*torchGCFunction)(void *data) = NULL;
110
+ static TH_THREAD void *torchGCData;
111
+ static TH_THREAD long torchHeapSize = 0 ;
112
+ static TH_THREAD long torchHeapSizeSoftMax = 300000000 ; // 300MB, adjusted upward dynamically
110
113
111
114
/* Optional hook for integrating with a garbage-collected frontend.
112
115
*
@@ -242,15 +245,5 @@ void THFree(void *ptr)
242
245
free (ptr);
243
246
}
244
247
245
- double THLog1p (const double x)
246
- {
247
- #if (defined(_MSC_VER) || defined(__MINGW32__))
248
- volatile double y = 1 + x;
249
- return log (y) - ((y-1 )-x)/y ; /* cancels errors with IEEE arithmetic */
250
- #else
251
- return log1p (x);
252
- #endif
253
- }
254
-
255
248
}
256
249
#endif
0 commit comments