react-native-executorch 0.5.15 → 0.6.0-nightly-897eae9-20251213

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (277) hide show
  1. package/README.md +42 -36
  2. package/android/CMakeLists.txt +13 -25
  3. package/android/build.gradle +2 -3
  4. package/android/libs/classes.jar +0 -0
  5. package/android/src/main/cpp/CMakeLists.txt +2 -1
  6. package/common/rnexecutorch/RnExecutorchInstaller.cpp +18 -0
  7. package/common/rnexecutorch/TokenizerModule.cpp +3 -3
  8. package/common/rnexecutorch/data_processing/Numerical.cpp +31 -23
  9. package/common/rnexecutorch/data_processing/Numerical.h +6 -1
  10. package/common/rnexecutorch/data_processing/dsp.cpp +0 -46
  11. package/common/rnexecutorch/host_objects/JsiConversions.h +16 -0
  12. package/common/rnexecutorch/host_objects/ModelHostObject.h +26 -11
  13. package/common/rnexecutorch/jsi/OwningArrayBuffer.h +19 -2
  14. package/common/rnexecutorch/metaprogramming/TypeConcepts.h +0 -20
  15. package/common/rnexecutorch/models/BaseModel.cpp +12 -11
  16. package/common/rnexecutorch/models/BaseModel.h +18 -10
  17. package/common/rnexecutorch/models/embeddings/BaseEmbeddings.cpp +3 -11
  18. package/common/rnexecutorch/models/embeddings/text/TextEmbeddings.cpp +0 -1
  19. package/common/rnexecutorch/models/image_segmentation/ImageSegmentation.cpp +6 -12
  20. package/common/rnexecutorch/models/llm/LLM.cpp +25 -8
  21. package/common/rnexecutorch/models/llm/LLM.h +4 -4
  22. package/common/rnexecutorch/models/ocr/CTCLabelConverter.h +1 -1
  23. package/common/rnexecutorch/models/ocr/utils/RecognitionHandlerUtils.cpp +7 -4
  24. package/common/rnexecutorch/models/speech_to_text/SpeechToText.cpp +8 -13
  25. package/common/rnexecutorch/models/speech_to_text/SpeechToText.h +1 -3
  26. package/common/rnexecutorch/models/speech_to_text/asr/ASR.cpp +12 -19
  27. package/common/rnexecutorch/models/speech_to_text/asr/ASR.h +4 -5
  28. package/common/rnexecutorch/models/text_to_image/Constants.h +9 -0
  29. package/common/rnexecutorch/models/text_to_image/Decoder.cpp +32 -0
  30. package/common/rnexecutorch/models/text_to_image/Decoder.h +24 -0
  31. package/common/rnexecutorch/models/text_to_image/Encoder.cpp +44 -0
  32. package/common/rnexecutorch/models/text_to_image/Encoder.h +32 -0
  33. package/common/rnexecutorch/models/text_to_image/Scheduler.cpp +152 -0
  34. package/common/rnexecutorch/models/text_to_image/Scheduler.h +41 -0
  35. package/common/rnexecutorch/models/text_to_image/TextToImage.cpp +141 -0
  36. package/common/rnexecutorch/models/text_to_image/TextToImage.h +64 -0
  37. package/common/rnexecutorch/models/text_to_image/UNet.cpp +38 -0
  38. package/common/rnexecutorch/models/text_to_image/UNet.h +28 -0
  39. package/common/rnexecutorch/models/voice_activity_detection/Constants.h +27 -0
  40. package/common/rnexecutorch/models/voice_activity_detection/Types.h +12 -0
  41. package/common/rnexecutorch/models/voice_activity_detection/Utils.cpp +15 -0
  42. package/common/rnexecutorch/models/voice_activity_detection/Utils.h +13 -0
  43. package/common/rnexecutorch/models/voice_activity_detection/VoiceActivityDetection.cpp +160 -0
  44. package/common/rnexecutorch/models/voice_activity_detection/VoiceActivityDetection.h +36 -0
  45. package/common/rnexecutorch/tests/CMakeLists.txt +30 -0
  46. package/common/rnexecutorch/tests/NumericalTest.cpp +110 -0
  47. package/common/rnexecutorch/tests/README.md +30 -13
  48. package/common/rnexecutorch/threads/GlobalThreadPool.h +4 -0
  49. package/common/runner/arange_util.cpp +44 -0
  50. package/common/runner/arange_util.h +37 -0
  51. package/common/runner/constants.h +28 -0
  52. package/common/runner/io_manager.h +240 -0
  53. package/common/runner/irunner.h +87 -16
  54. package/common/runner/kernel_includes.h +23 -0
  55. package/common/runner/runner.cpp +151 -66
  56. package/common/runner/runner.h +39 -22
  57. package/common/runner/sampler.cpp +8 -1
  58. package/common/runner/sampler.h +4 -2
  59. package/common/runner/stats.h +1 -4
  60. package/common/runner/text_decoder_runner.cpp +26 -12
  61. package/common/runner/text_decoder_runner.h +52 -31
  62. package/common/runner/text_prefiller.cpp +46 -12
  63. package/common/runner/text_prefiller.h +38 -4
  64. package/common/runner/text_token_generator.h +51 -26
  65. package/common/runner/util.h +53 -8
  66. package/ios/RnExecutorch.xcodeproj/project.pbxproj +0 -23
  67. package/lib/module/Error.js +1 -0
  68. package/lib/module/Error.js.map +1 -1
  69. package/lib/module/constants/directories.js +1 -1
  70. package/lib/module/constants/directories.js.map +1 -1
  71. package/lib/module/constants/modelUrls.js +32 -1
  72. package/lib/module/constants/modelUrls.js.map +1 -1
  73. package/lib/module/constants/ocr/models.js +7 -7
  74. package/lib/module/constants/ocr/models.js.map +1 -1
  75. package/lib/module/constants/ocr/symbols.js +3 -2
  76. package/lib/module/constants/ocr/symbols.js.map +1 -1
  77. package/lib/module/controllers/LLMController.js +10 -1
  78. package/lib/module/controllers/LLMController.js.map +1 -1
  79. package/lib/module/controllers/OCRController.js +3 -3
  80. package/lib/module/controllers/OCRController.js.map +1 -1
  81. package/lib/module/controllers/VerticalOCRController.js +2 -2
  82. package/lib/module/controllers/VerticalOCRController.js.map +1 -1
  83. package/lib/module/hooks/computer_vision/useOCR.js +3 -3
  84. package/lib/module/hooks/computer_vision/useOCR.js.map +1 -1
  85. package/lib/module/hooks/{useNonStaticModule.js → computer_vision/useTextToImage.js} +21 -16
  86. package/lib/module/hooks/computer_vision/useTextToImage.js.map +1 -0
  87. package/lib/module/hooks/computer_vision/useVerticalOCR.js +3 -3
  88. package/lib/module/hooks/computer_vision/useVerticalOCR.js.map +1 -1
  89. package/lib/module/hooks/natural_language_processing/useLLM.js +3 -3
  90. package/lib/module/hooks/natural_language_processing/useLLM.js.map +1 -1
  91. package/lib/module/hooks/natural_language_processing/useTokenizer.js +5 -5
  92. package/lib/module/hooks/natural_language_processing/useTokenizer.js.map +1 -1
  93. package/lib/module/hooks/natural_language_processing/useVAD.js +13 -0
  94. package/lib/module/hooks/natural_language_processing/useVAD.js.map +1 -0
  95. package/lib/module/index.js +7 -2
  96. package/lib/module/index.js.map +1 -1
  97. package/lib/module/modules/computer_vision/OCRModule.js +2 -2
  98. package/lib/module/modules/computer_vision/OCRModule.js.map +1 -1
  99. package/lib/module/modules/computer_vision/TextToImageModule.js +48 -0
  100. package/lib/module/modules/computer_vision/TextToImageModule.js.map +1 -0
  101. package/lib/module/modules/computer_vision/VerticalOCRModule.js +2 -2
  102. package/lib/module/modules/computer_vision/VerticalOCRModule.js.map +1 -1
  103. package/lib/module/modules/natural_language_processing/SpeechToTextModule.js +7 -4
  104. package/lib/module/modules/natural_language_processing/SpeechToTextModule.js.map +1 -1
  105. package/lib/module/modules/natural_language_processing/VADModule.js +19 -0
  106. package/lib/module/modules/natural_language_processing/VADModule.js.map +1 -0
  107. package/lib/module/types/llm.js.map +1 -1
  108. package/lib/module/types/vad.js +2 -0
  109. package/lib/module/types/vad.js.map +1 -0
  110. package/lib/module/utils/ResourceFetcher.js +2 -1
  111. package/lib/module/utils/ResourceFetcher.js.map +1 -1
  112. package/lib/module/utils/ResourceFetcherUtils.js +6 -6
  113. package/lib/module/utils/ResourceFetcherUtils.js.map +1 -1
  114. package/lib/typescript/Error.d.ts +1 -0
  115. package/lib/typescript/Error.d.ts.map +1 -1
  116. package/lib/typescript/constants/modelUrls.d.ts +23 -0
  117. package/lib/typescript/constants/modelUrls.d.ts.map +1 -1
  118. package/lib/typescript/constants/ocr/symbols.d.ts +1 -1
  119. package/lib/typescript/constants/ocr/symbols.d.ts.map +1 -1
  120. package/lib/typescript/controllers/LLMController.d.ts.map +1 -1
  121. package/lib/typescript/controllers/OCRController.d.ts +1 -1
  122. package/lib/typescript/controllers/OCRController.d.ts.map +1 -1
  123. package/lib/typescript/controllers/VerticalOCRController.d.ts +1 -1
  124. package/lib/typescript/controllers/VerticalOCRController.d.ts.map +1 -1
  125. package/lib/typescript/hooks/computer_vision/useOCR.d.ts +1 -1
  126. package/lib/typescript/hooks/computer_vision/useOCR.d.ts.map +1 -1
  127. package/lib/typescript/hooks/computer_vision/useTextToImage.d.ts +22 -0
  128. package/lib/typescript/hooks/computer_vision/useTextToImage.d.ts.map +1 -0
  129. package/lib/typescript/hooks/computer_vision/useVerticalOCR.d.ts +1 -1
  130. package/lib/typescript/hooks/computer_vision/useVerticalOCR.d.ts.map +1 -1
  131. package/lib/typescript/hooks/natural_language_processing/useLLM.d.ts.map +1 -1
  132. package/lib/typescript/hooks/natural_language_processing/useSpeechToText.d.ts +2 -2
  133. package/lib/typescript/hooks/natural_language_processing/useVAD.d.ts +16 -0
  134. package/lib/typescript/hooks/natural_language_processing/useVAD.d.ts.map +1 -0
  135. package/lib/typescript/index.d.ts +8 -1
  136. package/lib/typescript/index.d.ts.map +1 -1
  137. package/lib/typescript/modules/computer_vision/OCRModule.d.ts +1 -1
  138. package/lib/typescript/modules/computer_vision/OCRModule.d.ts.map +1 -1
  139. package/lib/typescript/modules/computer_vision/TextToImageModule.d.ts +16 -0
  140. package/lib/typescript/modules/computer_vision/TextToImageModule.d.ts.map +1 -0
  141. package/lib/typescript/modules/computer_vision/VerticalOCRModule.d.ts +1 -1
  142. package/lib/typescript/modules/computer_vision/VerticalOCRModule.d.ts.map +1 -1
  143. package/lib/typescript/modules/natural_language_processing/SpeechToTextModule.d.ts +3 -2
  144. package/lib/typescript/modules/natural_language_processing/SpeechToTextModule.d.ts.map +1 -1
  145. package/lib/typescript/modules/natural_language_processing/VADModule.d.ts +10 -0
  146. package/lib/typescript/modules/natural_language_processing/VADModule.d.ts.map +1 -0
  147. package/lib/typescript/types/llm.d.ts +2 -0
  148. package/lib/typescript/types/llm.d.ts.map +1 -1
  149. package/lib/typescript/types/vad.d.ts +5 -0
  150. package/lib/typescript/types/vad.d.ts.map +1 -0
  151. package/lib/typescript/utils/ResourceFetcher.d.ts +29 -0
  152. package/lib/typescript/utils/ResourceFetcher.d.ts.map +1 -1
  153. package/lib/typescript/utils/ResourceFetcherUtils.d.ts +2 -2
  154. package/lib/typescript/utils/ResourceFetcherUtils.d.ts.map +1 -1
  155. package/package.json +11 -8
  156. package/react-native-executorch.podspec +9 -9
  157. package/src/Error.ts +1 -0
  158. package/src/constants/directories.ts +1 -1
  159. package/src/constants/modelUrls.ts +36 -1
  160. package/src/constants/ocr/models.ts +7 -7
  161. package/src/constants/ocr/symbols.ts +3 -2
  162. package/src/controllers/LLMController.ts +12 -1
  163. package/src/controllers/OCRController.ts +3 -3
  164. package/src/controllers/VerticalOCRController.ts +2 -2
  165. package/src/hooks/computer_vision/useOCR.ts +4 -5
  166. package/src/hooks/computer_vision/useTextToImage.ts +92 -0
  167. package/src/hooks/computer_vision/useVerticalOCR.ts +4 -5
  168. package/src/hooks/natural_language_processing/useLLM.ts +3 -4
  169. package/src/hooks/natural_language_processing/useTokenizer.ts +5 -5
  170. package/src/hooks/natural_language_processing/useVAD.ts +15 -0
  171. package/src/index.ts +20 -1
  172. package/src/modules/computer_vision/OCRModule.ts +2 -2
  173. package/src/modules/computer_vision/TextToImageModule.ts +93 -0
  174. package/src/modules/computer_vision/VerticalOCRModule.ts +2 -2
  175. package/src/modules/natural_language_processing/SpeechToTextModule.ts +8 -4
  176. package/src/modules/natural_language_processing/VADModule.ts +27 -0
  177. package/src/types/llm.ts +2 -0
  178. package/src/types/vad.ts +4 -0
  179. package/src/utils/ResourceFetcher.ts +2 -1
  180. package/src/utils/ResourceFetcherUtils.ts +8 -8
  181. package/third-party/android/libs/cpuinfo/arm64-v8a/libcpuinfo.so +0 -0
  182. package/third-party/android/libs/executorch/arm64-v8a/libexecutorch.so +0 -0
  183. package/third-party/android/libs/executorch/x86_64/libexecutorch.so +0 -0
  184. package/third-party/android/libs/pthreadpool/arm64-v8a/libpthreadpool.so +0 -0
  185. package/third-party/include/c10/macros/Export.h +0 -78
  186. package/third-party/include/c10/macros/Macros.h +1 -520
  187. package/third-party/include/c10/util/BFloat16-inl.h +1 -339
  188. package/third-party/include/c10/util/BFloat16.h +1 -122
  189. package/third-party/include/c10/util/Half-inl.h +1 -347
  190. package/third-party/include/c10/util/Half.h +6 -419
  191. package/third-party/include/c10/util/TypeSafeSignMath.h +1 -133
  192. package/third-party/include/c10/util/bit_cast.h +1 -43
  193. package/third-party/include/c10/util/complex.h +1 -568
  194. package/third-party/include/c10/util/floating_point_utils.h +1 -33
  195. package/third-party/include/c10/util/irange.h +1 -1
  196. package/third-party/include/c10/util/llvmMathExtras.h +866 -0
  197. package/third-party/include/c10/util/safe_numerics.h +97 -0
  198. package/third-party/include/executorch/ExecuTorchError.h +6 -7
  199. package/third-party/include/executorch/ExecuTorchLLM/ExecuTorchLLM.h +12 -0
  200. package/third-party/include/executorch/ExecuTorchLLM/ExecuTorchLLMConfig.h +56 -0
  201. package/third-party/include/executorch/ExecuTorchLLM/ExecuTorchLLMError.h +16 -0
  202. package/third-party/include/executorch/ExecuTorchLLM/ExecuTorchLLMMultimodalRunner.h +227 -0
  203. package/third-party/include/executorch/ExecuTorchLLM/ExecuTorchLLMTextRunner.h +97 -0
  204. package/third-party/include/executorch/ExecuTorchLLM/module.modulemap +4 -0
  205. package/third-party/include/executorch/ExecuTorchLog.h +1 -0
  206. package/third-party/include/executorch/ExecuTorchModule.h +177 -4
  207. package/third-party/include/executorch/ExecuTorchTensor.h +3 -4
  208. package/third-party/include/executorch/ExecuTorchValue.h +1 -7
  209. package/third-party/include/executorch/extension/module/module.h +139 -8
  210. package/third-party/include/executorch/extension/tensor/tensor.h +1 -0
  211. package/third-party/include/executorch/extension/tensor/tensor_ptr.h +88 -26
  212. package/third-party/include/executorch/extension/threadpool/threadpool.h +4 -1
  213. package/third-party/include/executorch/runtime/backend/backend_init_context.h +6 -0
  214. package/third-party/include/executorch/runtime/backend/interface.h +1 -1
  215. package/third-party/include/executorch/runtime/core/error.h +76 -49
  216. package/third-party/include/executorch/runtime/core/exec_aten/util/scalar_type_util.h +18 -4
  217. package/third-party/include/executorch/runtime/core/memory_allocator.h +12 -2
  218. package/third-party/include/executorch/runtime/core/named_data_map.h +1 -11
  219. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/macros/Export.h +0 -78
  220. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/macros/Macros.h +1 -520
  221. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-inl.h +1 -339
  222. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/BFloat16.h +1 -122
  223. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/Half-inl.h +1 -347
  224. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/Half.h +6 -419
  225. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/TypeSafeSignMath.h +1 -133
  226. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/bit_cast.h +1 -43
  227. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/complex.h +1 -568
  228. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/floating_point_utils.h +1 -33
  229. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/irange.h +1 -1
  230. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/llvmMathExtras.h +866 -0
  231. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/safe_numerics.h +97 -0
  232. package/third-party/include/executorch/runtime/core/portable_type/c10/torch/headeronly/macros/Export.h +66 -0
  233. package/third-party/include/executorch/runtime/core/portable_type/c10/torch/headeronly/macros/Macros.h +553 -0
  234. package/third-party/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/BFloat16.h +477 -0
  235. package/third-party/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/Half.h +781 -0
  236. package/third-party/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/TypeSafeSignMath.h +141 -0
  237. package/third-party/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/bit_cast.h +49 -0
  238. package/third-party/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/complex.h +593 -0
  239. package/third-party/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/floating_point_utils.h +38 -0
  240. package/third-party/include/executorch/runtime/core/tensor_layout.h +1 -1
  241. package/third-party/include/executorch/runtime/executor/merged_data_map.h +142 -0
  242. package/third-party/include/executorch/runtime/executor/method.h +21 -8
  243. package/third-party/include/executorch/runtime/executor/method_meta.h +20 -2
  244. package/third-party/include/executorch/runtime/executor/program.h +0 -10
  245. package/third-party/include/executorch/runtime/kernel/operator_registry.h +1 -1
  246. package/third-party/include/executorch/runtime/platform/compiler.h +2 -0
  247. package/third-party/include/executorch/schema/extended_header.h +10 -1
  248. package/third-party/include/torch/headeronly/macros/Export.h +66 -0
  249. package/third-party/include/torch/headeronly/macros/Macros.h +553 -0
  250. package/third-party/include/torch/headeronly/util/BFloat16.h +477 -0
  251. package/third-party/include/torch/headeronly/util/Half.h +781 -0
  252. package/third-party/include/torch/headeronly/util/TypeSafeSignMath.h +141 -0
  253. package/third-party/include/torch/headeronly/util/bit_cast.h +49 -0
  254. package/third-party/include/torch/headeronly/util/complex.h +593 -0
  255. package/third-party/include/torch/headeronly/util/floating_point_utils.h +38 -0
  256. package/third-party/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/ExecutorchLib +0 -0
  257. package/third-party/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Info.plist +0 -0
  258. package/third-party/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/ExecutorchLib +0 -0
  259. package/third-party/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Info.plist +0 -0
  260. package/common/rnexecutorch/tests/run_all_tests.sh +0 -14
  261. package/common/rnexecutorch/tests/run_test.sh +0 -18
  262. package/ios/RnExecutorch/utils/Conversions.h +0 -14
  263. package/ios/RnExecutorch/utils/ETError.h +0 -26
  264. package/ios/RnExecutorch/utils/ImageProcessor.h +0 -15
  265. package/ios/RnExecutorch/utils/ImageProcessor.mm +0 -147
  266. package/ios/RnExecutorch/utils/Numerical.h +0 -3
  267. package/ios/RnExecutorch/utils/Numerical.mm +0 -18
  268. package/ios/RnExecutorch/utils/ScalarType.h +0 -14
  269. package/ios/RnExecutorch/utils/ScalarType.mm +0 -21
  270. package/lib/module/hooks/useNonStaticModule.js.map +0 -1
  271. package/lib/typescript/hooks/useNonStaticModule.d.ts +0 -21
  272. package/lib/typescript/hooks/useNonStaticModule.d.ts.map +0 -1
  273. package/src/hooks/useNonStaticModule.ts +0 -74
  274. package/third-party/include/executorch/extension/kernel_util/make_boxed_from_unboxed_functor.h +0 -181
  275. package/third-party/include/executorch/extension/kernel_util/meta_programming.h +0 -108
  276. package/third-party/include/executorch/extension/kernel_util/type_list.h +0 -137
  277. package/third-party/include/executorch/extension/threadpool/threadpool_guard.h +0 -35
@@ -0,0 +1,553 @@
1
+ #define C10_USING_CUSTOM_GENERATED_MACROS
2
+ #ifndef C10_MACROS_MACROS_H_
3
+ #define C10_MACROS_MACROS_H_
4
+ #include <cassert>
5
+
6
+ /* Main entry for torch/headeronly/macros (used to be c10/macros).
7
+ *
8
+ * In your code, include torch/headeronly/macros/Macros.h directly, instead of
9
+ * individual files in this folder.
10
+ */
11
+
12
+ // For build systems that do not directly depend on CMake and directly build
13
+ // from the source directory (such as Buck), one may not have a cmake_macros.h
14
+ // file at all. In this case, the build system is responsible for providing
15
+ // correct macro definitions corresponding to the cmake_macros.h.in file.
16
+ //
17
+ // In such scenarios, one should define the macro
18
+ // C10_USING_CUSTOM_GENERATED_MACROS
19
+ // to inform this header that it does not need to include the cmake_macros.h
20
+ // file.
21
+
22
+ #ifndef C10_USING_CUSTOM_GENERATED_MACROS
23
+ #include <torch/headeronly/macros/cmake_macros.h>
24
+ #endif // C10_USING_CUSTOM_GENERATED_MACROS
25
+
26
+ #include <torch/headeronly/macros/Export.h>
27
+
28
+ #if defined(__clang__)
29
+ #define __ubsan_ignore_float_divide_by_zero__ \
30
+ __attribute__((no_sanitize("float-divide-by-zero")))
31
+ #define __ubsan_ignore_undefined__ __attribute__((no_sanitize("undefined")))
32
+ #define __ubsan_ignore_signed_int_overflow__ \
33
+ __attribute__((no_sanitize("signed-integer-overflow")))
34
+ #define __ubsan_ignore_pointer_overflow__ \
35
+ __attribute__((no_sanitize("pointer-overflow")))
36
+ #define __ubsan_ignore_function__ __attribute__((no_sanitize("function")))
37
+ #define __ubsan_ignore_float_cast_overflow__ \
38
+ __attribute__((no_sanitize("float-cast-overflow")))
39
+ #else
40
+ #define __ubsan_ignore_float_divide_by_zero__
41
+ #define __ubsan_ignore_undefined__
42
+ #define __ubsan_ignore_signed_int_overflow__
43
+ #define __ubsan_ignore_pointer_overflow__
44
+ #define __ubsan_ignore_function__
45
+ #define __ubsan_ignore_float_cast_overflow__
46
+ #endif
47
+
48
+ // Detect address sanitizer as some stuff doesn't work with it
49
+ #undef C10_ASAN_ENABLED
50
+
51
+ // for clang
52
+ #if defined(__has_feature)
53
+ #if ((__has_feature(address_sanitizer)))
54
+ #define C10_ASAN_ENABLED 1
55
+ #endif
56
+ #endif
57
+
58
+ // for gcc
59
+ #if defined(__SANITIZE_ADDRESS__)
60
+ #if __SANITIZE_ADDRESS__
61
+ #if !defined(C10_ASAN_ENABLED)
62
+ #define C10_ASAN_ENABLED 1
63
+ #endif
64
+ #endif
65
+ #endif
66
+
67
+ #if !defined(C10_ASAN_ENABLED)
68
+ #define C10_ASAN_ENABLED 0
69
+ #endif
70
+
71
+ // Detect undefined-behavior sanitizer (UBSAN)
72
+ #undef C10_UBSAN_ENABLED
73
+
74
+ // for clang or gcc >= 14
75
+ // NB: gcc 14 adds support for Clang's __has_feature
76
+ // https://gcc.gnu.org/gcc-14/changes.html
77
+ // gcc < 14 doesn't have a macro for UBSAN
78
+ // (e.g. __SANITIZE_UNDEFINED__ does not exist in gcc)
79
+ // https://github.com/google/sanitizers/issues/765
80
+ #if defined(__has_feature)
81
+ #if ((__has_feature(undefined_behavior_sanitizer)))
82
+ #define C10_UBSAN_ENABLED 1
83
+ #endif
84
+ #endif
85
+
86
+ #if !defined(C10_UBSAN_ENABLED)
87
+ #define C10_UBSAN_ENABLED 0
88
+ #endif
89
+
90
+ // Disable the copy and assignment operator for a class. Note that this will
91
+ // disable the usage of the class in std containers.
92
+ #define C10_DISABLE_COPY_AND_ASSIGN(classname) \
93
+ classname(const classname &) = delete; \
94
+ classname &operator=(const classname &) = delete
95
+
96
+ #define C10_CONCATENATE_IMPL(s1, s2) s1##s2
97
+ #define C10_CONCATENATE(s1, s2) C10_CONCATENATE_IMPL(s1, s2)
98
+
99
+ #define C10_MACRO_EXPAND(args) args
100
+
101
+ #define C10_STRINGIZE_IMPL(x) #x
102
+ #define C10_STRINGIZE(x) C10_STRINGIZE_IMPL(x)
103
+
104
+ /**
105
+ * C10_ANONYMOUS_VARIABLE(str) introduces a new identifier which starts with
106
+ * str and ends with a unique number.
107
+ */
108
+ #ifdef __COUNTER__
109
+ #define C10_UID __COUNTER__
110
+ #define C10_ANONYMOUS_VARIABLE(str) C10_CONCATENATE(str, __COUNTER__)
111
+ #else
112
+ #define C10_UID __LINE__
113
+ #define C10_ANONYMOUS_VARIABLE(str) C10_CONCATENATE(str, __LINE__)
114
+ #endif
115
+
116
+ #ifdef __has_cpp_attribute
117
+ #define C10_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
118
+ #else
119
+ #define C10_HAS_CPP_ATTRIBUTE(x) (0)
120
+ #endif
121
+
122
+ #ifndef FBCODE_CAFFE2
123
+ /// DEPRECATED: Warn if a type or return value is discarded.
124
+ #define C10_NODISCARD [[nodiscard]]
125
+
126
+ /// DEPRECATED: Suppress an unused variable.
127
+ #define C10_UNUSED [[maybe_unused]]
128
+ #endif
129
+
130
+ #if !defined(__has_attribute)
131
+ #define __has_attribute(x) 0
132
+ #endif
133
+
134
+ // Direct port of LLVM_ATTRIBUTE_USED.
135
+ #if __has_attribute(used)
136
+ #define C10_USED __attribute__((__used__))
137
+ #else
138
+ #define C10_USED
139
+ #endif
140
+
141
+ #define C10_RESTRICT __restrict
142
+
143
+ // Simply define the namespace, in case a dependent library want to refer to
144
+ // the c10 namespace but not any nontrivial files.
145
+ namespace c10 {}
146
+ namespace c10::cuda {}
147
+ namespace c10::hip {}
148
+ namespace c10::xpu {}
149
+
150
+ // Since C10 is the core library for caffe2 (and aten), we will simply reroute
151
+ // all abstractions defined in c10 to be available in caffe2 as well.
152
+ // This is only for backwards compatibility. Please use the symbols from the
153
+ // c10 namespace where possible.
154
+ namespace caffe2 {
155
+ using namespace c10;
156
+ }
157
+ namespace at {
158
+ using namespace c10;
159
+ }
160
+ namespace at::cuda {
161
+ using namespace c10::cuda;
162
+ } // namespace at::cuda
163
+
164
+ // WARNING!!! THIS IS A GIANT HACK!!!
165
+ // This line means you cannot simultaneously include c10/hip
166
+ // and c10/cuda and then use them from the at::cuda namespace.
167
+ // This is true in practice, because HIPIFY works inplace on
168
+ // files in ATen/cuda, so it assumes that c10::hip is available
169
+ // from at::cuda. This namespace makes that happen. When
170
+ // HIPIFY is no longer out-of-place, we can switch the cuda
171
+ // here to hip and everyone is happy.
172
+ namespace at::cuda {
173
+ using namespace c10::hip;
174
+ } // namespace at::cuda
175
+
176
+ namespace at::xpu {
177
+ using namespace c10::xpu;
178
+ } // namespace at::xpu
179
+
180
+ // C10_LIKELY/C10_UNLIKELY
181
+ //
182
+ // These macros provide parentheses, so you can use these macros as:
183
+ //
184
+ // if C10_LIKELY(some_expr) {
185
+ // ...
186
+ // }
187
+ //
188
+ // NB: static_cast to boolean is mandatory in C++, because __builtin_expect
189
+ // takes a long argument, which means you may trigger the wrong conversion
190
+ // without it.
191
+ //
192
+ #if defined(__GNUC__) || defined(__ICL) || defined(__clang__)
193
+ #define C10_LIKELY(expr) (__builtin_expect(static_cast<bool>(expr), 1))
194
+ #define C10_UNLIKELY(expr) (__builtin_expect(static_cast<bool>(expr), 0))
195
+ #else
196
+ #define C10_LIKELY(expr) (expr)
197
+ #define C10_UNLIKELY(expr) (expr)
198
+ #endif
199
+
200
+ /// C10_NOINLINE - Functions whose declaration is annotated with this will not
201
+ /// be inlined.
202
+ #ifdef __GNUC__
203
+ #define C10_NOINLINE __attribute__((noinline))
204
+ #elif _MSC_VER
205
+ #define C10_NOINLINE __declspec(noinline)
206
+ #else
207
+ #define C10_NOINLINE
208
+ #endif
209
+
210
+ #if defined(_MSC_VER)
211
+ #define C10_ALWAYS_INLINE __forceinline
212
+ #elif __has_attribute(always_inline) || defined(__GNUC__)
213
+ #define C10_ALWAYS_INLINE __attribute__((__always_inline__)) inline
214
+ #else
215
+ #define C10_ALWAYS_INLINE inline
216
+ #endif
217
+
218
+ // Unlike C10_ALWAYS_INLINE, C10_ALWAYS_INLINE_ATTRIBUTE can be used
219
+ // on a lambda.
220
+ #if defined(_MSC_VER)
221
+ // MSVC 14.39 is reasonably recent and doesn't like
222
+ // [[msvc::forceinline]] on a lambda, so don't try to use it.
223
+ #define C10_ALWAYS_INLINE_ATTRIBUTE
224
+ #elif __has_attribute(always_inline) || defined(__GNUC__)
225
+ #define C10_ALWAYS_INLINE_ATTRIBUTE __attribute__((__always_inline__))
226
+ #else
227
+ #define C10_ALWAYS_INLINE_ATTRIBUTE
228
+ #endif
229
+
230
+ #if defined(_MSC_VER)
231
+ #define C10_ATTR_VISIBILITY_HIDDEN
232
+ #elif defined(__GNUC__)
233
+ #define C10_ATTR_VISIBILITY_HIDDEN __attribute__((__visibility__("hidden")))
234
+ #else
235
+ #define C10_ATTR_VISIBILITY_HIDDEN
236
+ #endif
237
+
238
+ #define C10_ERASE C10_ALWAYS_INLINE C10_ATTR_VISIBILITY_HIDDEN
239
+
240
+ #include <cstdint>
241
+
242
+ #ifdef __HIPCC__
243
+ // Unlike CUDA, HIP requires a HIP header to be included for __host__ to work.
244
+ // We do this #include here so that C10_HOST_DEVICE and friends will Just Work.
245
+ // See https://github.com/ROCm/hip/issues/441
246
+ #include <hip/hip_runtime.h>
247
+ #endif
248
+
249
+ #if defined(__CUDACC__) || defined(__HIPCC__)
250
+ // Designates functions callable from the host (CPU) and the device (GPU)
251
+ #define C10_HOST_DEVICE __host__ __device__
252
+ #define C10_DEVICE __device__
253
+ #define C10_HOST __host__
254
+ // constants from
255
+ // (https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#features-and-technical-specifications)
256
+ // The maximum number of threads per multiprocessor is 1024 for Turing
257
+ // architecture (7.5), 1536 for Geforce Ampere (8.6)/Jetson Orin (8.7), and
258
+ // 2048 for all other architectures. You'll get warnings if you exceed these
259
+ // constants. Hence, the following macros adjust the input values from the user
260
+ // to resolve potential warnings.
261
+ #if __CUDA_ARCH__ == 750
262
+ constexpr uint32_t CUDA_MAX_THREADS_PER_SM = 1024;
263
+ #elif __CUDA_ARCH__ == 860 || __CUDA_ARCH__ == 870 || __CUDA_ARCH__ == 890 || \
264
+ __CUDA_ARCH__ == 1200
265
+ constexpr uint32_t CUDA_MAX_THREADS_PER_SM = 1536;
266
+ #else
267
+ constexpr uint32_t CUDA_MAX_THREADS_PER_SM = 2048;
268
+ #endif
269
+ // CUDA_MAX_THREADS_PER_BLOCK is same for all architectures currently
270
+ constexpr uint32_t CUDA_MAX_THREADS_PER_BLOCK = 1024;
271
+ // CUDA_THREADS_PER_BLOCK_FALLBACK is the "canonical fallback" choice of block
272
+ // size. 256 is a good number for this fallback and should give good occupancy
273
+ // and versatility across all architectures.
274
+ constexpr uint32_t CUDA_THREADS_PER_BLOCK_FALLBACK = 256;
275
+ // NOTE: if you are thinking of constexpr-ify the inputs to launch bounds, it
276
+ // turns out that although __launch_bounds__ can take constexpr, it
277
+ // can't take a constexpr that has anything to do with templates.
278
+ // Currently we use launch_bounds that depend on template arguments in
279
+ // Loops.cuh, Reduce.cuh and LossCTC.cuh. Hence, C10_MAX_THREADS_PER_BLOCK
280
+ // and C10_MIN_BLOCKS_PER_SM are kept as macros.
281
+ // Suppose you were planning to write __launch_bounds__(a, b), based on your
282
+ // performance tuning on a modern GPU. Instead, you should write
283
+ // __launch_bounds__(C10_MAX_THREADS_PER_BLOCK(a), C10_MIN_BLOCKS_PER_SM(a, b)),
284
+ // which will also properly respect limits on old architectures.
285
+ #define C10_MAX_THREADS_PER_BLOCK(val) \
286
+ (((val) <= CUDA_MAX_THREADS_PER_BLOCK) ? (val) \
287
+ : CUDA_THREADS_PER_BLOCK_FALLBACK)
288
+ #define C10_MIN_BLOCKS_PER_SM(threads_per_block, blocks_per_sm) \
289
+ ((((threads_per_block) * (blocks_per_sm) <= CUDA_MAX_THREADS_PER_SM) \
290
+ ? (blocks_per_sm) \
291
+ : ((CUDA_MAX_THREADS_PER_SM + (threads_per_block) - 1) / \
292
+ (threads_per_block))))
293
+ // C10_LAUNCH_BOUNDS is analogous to __launch_bounds__
294
+ #define C10_LAUNCH_BOUNDS_0 \
295
+ __launch_bounds__(256, \
296
+ 4) // default launch bounds that should give good occupancy
297
+ // and versatility across all architectures.
298
+ #define C10_LAUNCH_BOUNDS_1(max_threads_per_block) \
299
+ __launch_bounds__((C10_MAX_THREADS_PER_BLOCK((max_threads_per_block))))
300
+ #define C10_LAUNCH_BOUNDS_2(max_threads_per_block, min_blocks_per_sm) \
301
+ __launch_bounds__( \
302
+ (C10_MAX_THREADS_PER_BLOCK((max_threads_per_block))), \
303
+ (C10_MIN_BLOCKS_PER_SM((max_threads_per_block), (min_blocks_per_sm))))
304
+ #else
305
+ #define C10_HOST_DEVICE
306
+ #define C10_HOST
307
+ #define C10_DEVICE
308
+ #endif
309
+
310
+ #if defined(USE_ROCM)
311
+ #define C10_HIP_HOST_DEVICE __host__ __device__
312
+ #else
313
+ #define C10_HIP_HOST_DEVICE
314
+ #endif
315
+
316
+ #if defined(USE_ROCM)
317
+ // C10_WARP_SIZE is only allowed for device code.
318
+ // Host code _must_ use at::cuda::warp_size()
319
+ // HIP header used to define warpSize as a constexpr that was either 32 or 64
320
+ // depending on the target device, and then always set it to 64 for host code.
321
+ // Host pass of HIP compiler needs C10_WARP_SIZE defined to _something_ so we
322
+ // set it to something unreasonable to trigger obvious host code errors.
323
+
324
+ namespace at::cuda {
325
+ TORCH_CUDA_CPP_API int warp_size();
326
+ }
327
+ #ifdef __HIPCC__
328
+ static inline int __host__ C10_WARP_SIZE_INTERNAL() {
329
+ return at::cuda::warp_size();
330
+ }
331
+
332
+ static inline constexpr int __device__ C10_WARP_SIZE_INTERNAL() {
333
+ #if defined(__GFX9__)
334
+ return 64;
335
+ #else // __GFX9__
336
+ return 32;
337
+ #endif // __GFX9__
338
+ }
339
+ #else // __HIPCC__
340
+ static inline int C10_WARP_SIZE_INTERNAL() { return at::cuda::warp_size(); }
341
+ #endif // __HIPCC__
342
+
343
+ #define C10_WARP_SIZE (C10_WARP_SIZE_INTERNAL())
344
+ #define C10_WARP_SIZE_STATIC 64
345
+
346
+ #else // defined(USE_ROCM)
347
+ #define C10_WARP_SIZE 32
348
+ #endif
349
+
350
+ #if defined(_MSC_VER) && _MSC_VER <= 1900
351
+ #define __func__ __FUNCTION__
352
+ #endif
353
+
354
+ // CUDA_KERNEL_ASSERT checks the assertion
355
+ // even when NDEBUG is defined. This is useful for important assertions in CUDA
356
+ // code that would otherwise be suppressed when building Release.
357
+ #if defined(__ANDROID__) || defined(__APPLE__) || defined(__FreeBSD__)
358
+ // Those platforms do not support assert()
359
+ #define CUDA_KERNEL_ASSERT(cond)
360
+ #define CUDA_KERNEL_ASSERT_MSG(cond, msg)
361
+ #define SYCL_KERNEL_ASSERT(cond)
362
+ #elif defined(_MSC_VER)
363
+ #if defined(NDEBUG)
364
+ extern "C" {
365
+ C10_IMPORT
366
+ #if defined(__SYCL_DEVICE_ONLY__)
367
+ extern SYCL_EXTERNAL void _wassert(const wchar_t *wexpr, const wchar_t *wfile,
368
+ unsigned line);
369
+ #else
370
+ #if defined(__CUDA_ARCH__)
371
+ __host__ __device__
372
+ #endif // __CUDA_ARCH__
373
+ void _wassert(wchar_t const *_Message, wchar_t const *_File,
374
+ unsigned _Line);
375
+ #endif // __SYCL_DEVICE_ONLY__
376
+ }
377
+ #endif // NDEBUG
378
+ #define CUDA_KERNEL_ASSERT(cond) \
379
+ if (C10_UNLIKELY(!(cond))) { \
380
+ (void)(_wassert(_CRT_WIDE(#cond), _CRT_WIDE(__FILE__), \
381
+ static_cast<unsigned>(__LINE__)), \
382
+ 0); \
383
+ }
384
+ // TODO: This doesn't assert the message because I (chilli) couldn't figure out
385
+ // a nice way to convert a char* to a wchar_t*
386
+ #define CUDA_KERNEL_ASSERT_MSG(cond, msg) \
387
+ if (C10_UNLIKELY(!(cond))) { \
388
+ (void)(_wassert(_CRT_WIDE(#cond), _CRT_WIDE(__FILE__), \
389
+ static_cast<unsigned>(__LINE__)), \
390
+ 0); \
391
+ }
392
+ #define SYCL_KERNEL_ASSERT(cond) \
393
+ if (C10_UNLIKELY(!(cond))) { \
394
+ (void)(_wassert(_CRT_WIDE(#cond), _CRT_WIDE(__FILE__), \
395
+ static_cast<unsigned>(__LINE__)), \
396
+ 0); \
397
+ }
398
+ #else // __APPLE__, _MSC_VER
399
+ #if defined(NDEBUG)
400
+ extern "C" {
401
+ #if defined(__SYCL_DEVICE_ONLY__)
402
+ extern SYCL_EXTERNAL void __assert_fail(const char *expr, const char *file,
403
+ unsigned int line, const char *func);
404
+ #elif (defined(__EMSCRIPTEN__))
405
+ // As defined in assert.h in the Emscripten stdlib
406
+ _Noreturn void __assert_fail(const char *expr, const char *file, int line,
407
+ const char *func);
408
+ #else // __SYCL_DEVICE_ONLY__
409
+ #if (defined(__CUDA_ARCH__) && !(defined(__clang__) && defined(__CUDA__)))
410
+ // CUDA supports __assert_fail function which are common for both device
411
+ // and host side code.
412
+ __host__ __device__
413
+ #endif
414
+
415
+ // This forward declaration matching the declaration of __assert_fail
416
+ // exactly how it is in glibc in case parts of the program are compiled with
417
+ // different NDEBUG settings. Otherwise we might get 'ambiguous declaration'
418
+ // error. Note: On ROCm - this declaration serves for host side compilation.
419
+ void __assert_fail(const char *assertion, const char *file,
420
+ unsigned int line, const char *function) noexcept
421
+ __attribute__((__noreturn__));
422
+
423
+ #endif // __SYCL_DEVICE_ONLY__
424
+ }
425
+ #endif // NDEBUG
426
+ // ROCm disables kernel assert by default for performance considerations.
427
+ // Though ROCm supports __assert_fail, it uses kernel printf which has
428
+ // a non-negligible performance impact even if the assert condition is
429
+ // never triggered. We choose to use abort() instead which will still
430
+ // terminate the application but without a more useful error message.
431
+ #if !defined(C10_USE_ROCM_KERNEL_ASSERT) and defined(USE_ROCM)
432
+ #define CUDA_KERNEL_ASSERT(cond) \
433
+ if C10_UNLIKELY (!(cond)) { \
434
+ abort(); \
435
+ }
436
+ #define CUDA_KERNEL_ASSERT_MSG(cond, msg) \
437
+ if C10_UNLIKELY (!(cond)) { \
438
+ abort(); \
439
+ }
440
+ #define SYCL_KERNEL_ASSERT(cond) \
441
+ if C10_UNLIKELY (!(cond)) { \
442
+ abort(); \
443
+ }
444
+ #else
445
+ #define CUDA_KERNEL_ASSERT(cond) \
446
+ if (C10_UNLIKELY(!(cond))) { \
447
+ __assert_fail(#cond, __FILE__, static_cast<unsigned int>(__LINE__), \
448
+ __func__); \
449
+ }
450
+ #define CUDA_KERNEL_ASSERT_MSG(cond, msg) \
451
+ if (C10_UNLIKELY(!(cond))) { \
452
+ __assert_fail(msg, __FILE__, static_cast<unsigned int>(__LINE__), \
453
+ __func__); \
454
+ }
455
+ #define SYCL_KERNEL_ASSERT(cond) \
456
+ if (C10_UNLIKELY(!(cond))) { \
457
+ __assert_fail(#cond, __FILE__, static_cast<unsigned int>(__LINE__), \
458
+ __func__); \
459
+ }
460
+ #endif // C10_USE_ROCM_KERNEL_ASSERT and USE_ROCM
461
+ #endif // __APPLE__
462
+
463
+ #ifdef __APPLE__
464
+ #include <TargetConditionals.h>
465
+ #endif
466
+
467
+ #if defined(__ANDROID__)
468
+ #define C10_ANDROID 1
469
+ #define C10_MOBILE 1
470
+ #elif (defined(__APPLE__) && \
471
+ (TARGET_IPHONE_SIMULATOR || TARGET_OS_SIMULATOR || TARGET_OS_IPHONE))
472
+ #define C10_IOS 1
473
+ #define C10_MOBILE 1
474
+ #endif // ANDROID / IOS
475
+
476
+ #if defined(C10_MOBILE) && C10_MOBILE
477
+ #define C10_ALWAYS_INLINE_UNLESS_MOBILE inline
478
+ #else
479
+ #define C10_ALWAYS_INLINE_UNLESS_MOBILE C10_ALWAYS_INLINE
480
+ #endif
481
+
482
+ #if !defined(FBCODE_CAFFE2) && !defined(C10_NODEPRECATED)
483
+ #define CONSTEXPR_EXCEPT_WIN_CUDA constexpr
484
+ #define C10_HOST_CONSTEXPR_EXCEPT_WIN_CUDA constexpr
485
+
486
+ #define STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(field, val) \
487
+ static constexpr const char field[] = val;
488
+ #define STATIC_CONST_STR_OUT_OF_LINE_FOR_WIN_CUDA(cls, field, val)
489
+ #endif // !defined(FBCODE_CAFFE2) && !defined(C10_NODEPRECATED)
490
+
491
+ #ifndef HAS_DEMANGLE
492
+ #if defined(__ANDROID__) || defined(_WIN32) || defined(__EMSCRIPTEN__)
493
+ #define HAS_DEMANGLE 0
494
+ #elif defined(__APPLE__) && \
495
+ (TARGET_IPHONE_SIMULATOR || TARGET_OS_SIMULATOR || TARGET_OS_IPHONE)
496
+ #define HAS_DEMANGLE 0
497
+ #else
498
+ #define HAS_DEMANGLE 1
499
+ #endif
500
+ #endif // HAS_DEMANGLE
501
+
502
+ #define _C10_PRAGMA__(string) _Pragma(#string)
503
+ #define _C10_PRAGMA_(string) _C10_PRAGMA__(string)
504
+
505
+ #ifdef __clang__
506
+ #define C10_CLANG_DIAGNOSTIC_PUSH() _Pragma("clang diagnostic push")
507
+ #define C10_CLANG_DIAGNOSTIC_POP() _Pragma("clang diagnostic pop")
508
+ #define C10_CLANG_DIAGNOSTIC_IGNORE(flag) \
509
+ _C10_PRAGMA_(clang diagnostic ignored flag)
510
+ #define C10_CLANG_HAS_WARNING(flag) __has_warning(flag)
511
+ #else
512
+ #define C10_CLANG_DIAGNOSTIC_PUSH()
513
+ #define C10_CLANG_DIAGNOSTIC_POP()
514
+ #define C10_CLANG_DIAGNOSTIC_IGNORE(flag)
515
+ #define C10_CLANG_HAS_WARNING(flag) 0
516
+ #endif
517
+
518
+ #ifdef __clang__
519
+
520
+ #define C10_DIAGNOSTIC_PUSH_AND_IGNORED_IF_DEFINED(warning) \
521
+ _C10_PRAGMA_(clang diagnostic push) \
522
+ _C10_PRAGMA_(clang diagnostic ignored "-Wunknown-warning-option") \
523
+ _C10_PRAGMA_(clang diagnostic ignored warning)
524
+
525
+ #define C10_DIAGNOSTIC_POP() _C10_PRAGMA_(clang diagnostic pop)
526
+
527
+ #elif __GNUC__
528
+
529
+ #define C10_DIAGNOSTIC_PUSH_AND_IGNORED_IF_DEFINED(warning) \
530
+ _C10_PRAGMA_(GCC diagnostic push) \
531
+ _C10_PRAGMA_(GCC diagnostic ignored "-Wpragmas") \
532
+ _C10_PRAGMA_(GCC diagnostic ignored warning)
533
+
534
+ #define C10_DIAGNOSTIC_POP() _C10_PRAGMA_(GCC diagnostic pop)
535
+
536
+ #else
537
+
538
+ #define C10_DIAGNOSTIC_PUSH_AND_IGNORED_IF_DEFINED(warning)
539
+ #define C10_DIAGNOSTIC_POP()
540
+
541
+ #endif
542
+
543
+ // This macro is used to find older C++ compilers
544
+ // that don't support move optimization for return values.
545
+
546
+ #if (defined(__GNUC__) && __GNUC__ < 13) || \
547
+ (defined(__clang_major__) && __clang_major__ < 13)
548
+ #define C10_RETURN_MOVE_IF_OLD_COMPILER 1
549
+ #else
550
+ #define C10_RETURN_MOVE_IF_OLD_COMPILER 0
551
+ #endif
552
+
553
+ #endif // C10_MACROS_MACROS_H_