react-native-executorch 0.4.7 → 0.5.0

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 (1013) hide show
  1. package/android/CMakeLists.txt +17 -0
  2. package/android/build.gradle +76 -13
  3. package/android/libs/classes.jar +0 -0
  4. package/android/src/main/cpp/CMakeLists.txt +73 -0
  5. package/android/src/main/cpp/ETInstallerModule.cpp +76 -0
  6. package/android/src/main/cpp/ETInstallerModule.h +43 -0
  7. package/android/src/main/java/com/swmansion/rnexecutorch/ETInstaller.kt +66 -0
  8. package/android/src/main/java/com/swmansion/rnexecutorch/LLM.kt +3 -3
  9. package/android/src/main/java/com/swmansion/rnexecutorch/RnExecutorchPackage.kt +7 -113
  10. package/common/ada/ada.cpp +17406 -0
  11. package/common/ada/ada.h +10274 -0
  12. package/common/pfft/pfft.c +2205 -0
  13. package/common/pfft/pfft.h +185 -0
  14. package/common/rnexecutorch/Log.h +489 -0
  15. package/common/rnexecutorch/RnExecutorchInstaller.cpp +78 -0
  16. package/common/rnexecutorch/RnExecutorchInstaller.h +112 -0
  17. package/common/rnexecutorch/TokenizerModule.cpp +52 -0
  18. package/common/rnexecutorch/TokenizerModule.h +26 -0
  19. package/common/rnexecutorch/data_processing/FFT.cpp +21 -0
  20. package/common/rnexecutorch/data_processing/FFT.h +23 -0
  21. package/common/rnexecutorch/data_processing/FileUtils.h +30 -0
  22. package/common/rnexecutorch/data_processing/ImageProcessing.cpp +240 -0
  23. package/common/rnexecutorch/data_processing/ImageProcessing.h +55 -0
  24. package/common/rnexecutorch/data_processing/Numerical.cpp +82 -0
  25. package/common/rnexecutorch/data_processing/Numerical.h +23 -0
  26. package/common/rnexecutorch/data_processing/base64.cpp +110 -0
  27. package/common/rnexecutorch/data_processing/base64.h +46 -0
  28. package/common/rnexecutorch/data_processing/dsp.cpp +65 -0
  29. package/common/rnexecutorch/data_processing/dsp.h +12 -0
  30. package/common/rnexecutorch/host_objects/JSTensorViewIn.h +12 -0
  31. package/common/rnexecutorch/host_objects/JSTensorViewOut.h +22 -0
  32. package/common/rnexecutorch/host_objects/JsiConversions.h +410 -0
  33. package/common/rnexecutorch/host_objects/ModelHostObject.h +239 -0
  34. package/common/rnexecutorch/jsi/JsiHostObject.cpp +108 -0
  35. package/common/rnexecutorch/jsi/JsiHostObject.h +87 -0
  36. package/common/rnexecutorch/jsi/OwningArrayBuffer.h +40 -0
  37. package/common/rnexecutorch/jsi/Promise.cpp +20 -0
  38. package/common/rnexecutorch/jsi/Promise.h +69 -0
  39. package/common/rnexecutorch/jsi/RuntimeAwareCache.h +58 -0
  40. package/common/rnexecutorch/jsi/RuntimeLifecycleMonitor.cpp +53 -0
  41. package/common/rnexecutorch/jsi/RuntimeLifecycleMonitor.h +35 -0
  42. package/common/rnexecutorch/metaprogramming/ConstructorHelpers.h +131 -0
  43. package/common/rnexecutorch/metaprogramming/FunctionHelpers.h +50 -0
  44. package/common/rnexecutorch/metaprogramming/TypeConcepts.h +37 -0
  45. package/common/rnexecutorch/models/BaseModel.cpp +181 -0
  46. package/common/rnexecutorch/models/BaseModel.h +47 -0
  47. package/common/rnexecutorch/models/EncoderDecoderBase.cpp +21 -0
  48. package/common/rnexecutorch/models/EncoderDecoderBase.h +31 -0
  49. package/common/rnexecutorch/models/classification/Classification.cpp +72 -0
  50. package/common/rnexecutorch/models/classification/Classification.h +26 -0
  51. package/{ios/RnExecutorch/models/classification/Constants.mm → common/rnexecutorch/models/classification/Constants.h} +7 -2
  52. package/common/rnexecutorch/models/embeddings/BaseEmbeddings.cpp +27 -0
  53. package/common/rnexecutorch/models/embeddings/BaseEmbeddings.h +17 -0
  54. package/common/rnexecutorch/models/embeddings/image/ImageEmbeddings.cpp +45 -0
  55. package/common/rnexecutorch/models/embeddings/image/ImageEmbeddings.h +23 -0
  56. package/common/rnexecutorch/models/embeddings/text/TextEmbeddings.cpp +61 -0
  57. package/common/rnexecutorch/models/embeddings/text/TextEmbeddings.h +26 -0
  58. package/{ios/RnExecutorch/models/image_segmentation/Constants.mm → common/rnexecutorch/models/image_segmentation/Constants.h} +7 -2
  59. package/common/rnexecutorch/models/image_segmentation/ImageSegmentation.cpp +173 -0
  60. package/common/rnexecutorch/models/image_segmentation/ImageSegmentation.h +43 -0
  61. package/{ios/RnExecutorch/utils/Constants.mm → common/rnexecutorch/models/object_detection/Constants.h} +9 -2
  62. package/common/rnexecutorch/models/object_detection/ObjectDetection.cpp +82 -0
  63. package/common/rnexecutorch/models/object_detection/ObjectDetection.h +31 -0
  64. package/{ios/RnExecutorch/utils/ObjectDetectionUtils.mm → common/rnexecutorch/models/object_detection/Utils.cpp} +10 -30
  65. package/common/rnexecutorch/models/object_detection/Utils.h +17 -0
  66. package/common/rnexecutorch/models/ocr/CTCLabelConverter.cpp +88 -0
  67. package/common/rnexecutorch/models/ocr/CTCLabelConverter.h +29 -0
  68. package/common/rnexecutorch/models/ocr/Constants.h +34 -0
  69. package/common/rnexecutorch/models/ocr/Detector.cpp +102 -0
  70. package/common/rnexecutorch/models/ocr/Detector.h +30 -0
  71. package/common/rnexecutorch/models/ocr/DetectorUtils.cpp +703 -0
  72. package/common/rnexecutorch/models/ocr/DetectorUtils.h +80 -0
  73. package/common/rnexecutorch/models/ocr/OCR.cpp +52 -0
  74. package/common/rnexecutorch/models/ocr/OCR.h +36 -0
  75. package/common/rnexecutorch/models/ocr/RecognitionHandler.cpp +107 -0
  76. package/common/rnexecutorch/models/ocr/RecognitionHandler.h +40 -0
  77. package/common/rnexecutorch/models/ocr/RecognitionHandlerUtils.cpp +153 -0
  78. package/common/rnexecutorch/models/ocr/RecognitionHandlerUtils.h +72 -0
  79. package/common/rnexecutorch/models/ocr/Recognizer.cpp +80 -0
  80. package/common/rnexecutorch/models/ocr/Recognizer.h +36 -0
  81. package/common/rnexecutorch/models/ocr/RecognizerUtils.cpp +202 -0
  82. package/common/rnexecutorch/models/ocr/RecognizerUtils.h +70 -0
  83. package/common/rnexecutorch/models/ocr/Types.h +37 -0
  84. package/common/rnexecutorch/models/speech_to_text/SpeechToText.cpp +64 -0
  85. package/common/rnexecutorch/models/speech_to_text/SpeechToText.h +31 -0
  86. package/common/rnexecutorch/models/speech_to_text/SpeechToTextStrategy.h +27 -0
  87. package/common/rnexecutorch/models/speech_to_text/WhisperStrategy.cpp +50 -0
  88. package/common/rnexecutorch/models/speech_to_text/WhisperStrategy.h +25 -0
  89. package/common/rnexecutorch/models/style_transfer/StyleTransfer.cpp +55 -0
  90. package/common/rnexecutorch/models/style_transfer/StyleTransfer.h +29 -0
  91. package/common/rnexecutorch/models/vertical_ocr/VerticalDetector.cpp +92 -0
  92. package/common/rnexecutorch/models/vertical_ocr/VerticalDetector.h +49 -0
  93. package/common/rnexecutorch/models/vertical_ocr/VerticalOCR.cpp +180 -0
  94. package/common/rnexecutorch/models/vertical_ocr/VerticalOCR.h +78 -0
  95. package/common/rnexecutorch/tests/LogTest.cpp +530 -0
  96. package/common/rnexecutorch/tests/README.md +20 -0
  97. package/common/rnexecutorch/tests/run_all_tests.sh +14 -0
  98. package/common/rnexecutorch/tests/run_test.sh +18 -0
  99. package/ios/ExecutorchLib.xcframework/Info.plist +4 -4
  100. package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/ExecutorchLib +0 -0
  101. package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Info.plist +0 -0
  102. package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/ExecutorchLib +0 -0
  103. package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Info.plist +0 -0
  104. package/ios/RnExecutorch/ETInstaller.h +8 -0
  105. package/ios/RnExecutorch/ETInstaller.mm +56 -0
  106. package/ios/RnExecutorch/utils/Conversions.h +8 -9
  107. package/ios/RnExecutorch/utils/Numerical.h +2 -0
  108. package/ios/RnExecutorch.xcodeproj/project.pbxproj +73 -0
  109. package/lib/module/Error.js +8 -6
  110. package/lib/module/Error.js.map +1 -1
  111. package/lib/module/common/Logger.js +23 -0
  112. package/lib/module/common/Logger.js.map +1 -0
  113. package/lib/module/constants/llmDefaults.js +8 -0
  114. package/lib/module/constants/llmDefaults.js.map +1 -1
  115. package/lib/module/constants/modelUrls.js +328 -84
  116. package/lib/module/constants/modelUrls.js.map +1 -1
  117. package/lib/module/constants/ocr/models.js +181 -286
  118. package/lib/module/constants/ocr/models.js.map +1 -1
  119. package/lib/module/constants/ocr/symbols.js +63 -63
  120. package/lib/module/controllers/LLMController.js +17 -11
  121. package/lib/module/controllers/LLMController.js.map +1 -1
  122. package/lib/module/controllers/OCRController.js +16 -9
  123. package/lib/module/controllers/OCRController.js.map +1 -1
  124. package/lib/module/controllers/VerticalOCRController.js +16 -9
  125. package/lib/module/controllers/VerticalOCRController.js.map +1 -1
  126. package/lib/module/hooks/computer_vision/useClassification.js +5 -5
  127. package/lib/module/hooks/computer_vision/useClassification.js.map +1 -1
  128. package/lib/module/hooks/computer_vision/useImageEmbeddings.js +13 -0
  129. package/lib/module/hooks/computer_vision/useImageEmbeddings.js.map +1 -0
  130. package/lib/module/hooks/computer_vision/useImageSegmentation.js +4 -4
  131. package/lib/module/hooks/computer_vision/useImageSegmentation.js.map +1 -1
  132. package/lib/module/hooks/computer_vision/useOCR.js +14 -15
  133. package/lib/module/hooks/computer_vision/useOCR.js.map +1 -1
  134. package/lib/module/hooks/computer_vision/useObjectDetection.js +5 -5
  135. package/lib/module/hooks/computer_vision/useObjectDetection.js.map +1 -1
  136. package/lib/module/hooks/computer_vision/useStyleTransfer.js +5 -5
  137. package/lib/module/hooks/computer_vision/useStyleTransfer.js.map +1 -1
  138. package/lib/module/hooks/computer_vision/useVerticalOCR.js +16 -17
  139. package/lib/module/hooks/computer_vision/useVerticalOCR.js.map +1 -1
  140. package/lib/module/hooks/general/useExecutorchModule.js +5 -3
  141. package/lib/module/hooks/general/useExecutorchModule.js.map +1 -1
  142. package/lib/module/hooks/natural_language_processing/useLLM.js +22 -25
  143. package/lib/module/hooks/natural_language_processing/useLLM.js.map +1 -1
  144. package/lib/module/hooks/natural_language_processing/useSpeechToText.js +72 -33
  145. package/lib/module/hooks/natural_language_processing/useSpeechToText.js.map +1 -1
  146. package/lib/module/hooks/natural_language_processing/useTextEmbeddings.js +4 -5
  147. package/lib/module/hooks/natural_language_processing/useTextEmbeddings.js.map +1 -1
  148. package/lib/module/hooks/natural_language_processing/useTokenizer.js +20 -19
  149. package/lib/module/hooks/natural_language_processing/useTokenizer.js.map +1 -1
  150. package/lib/module/hooks/useNonStaticModule.js +52 -0
  151. package/lib/module/hooks/useNonStaticModule.js.map +1 -0
  152. package/lib/module/index.js +15 -4
  153. package/lib/module/index.js.map +1 -1
  154. package/lib/module/modules/BaseModule.js +6 -3
  155. package/lib/module/modules/BaseModule.js.map +1 -1
  156. package/lib/module/modules/BaseNonStaticModule.js +17 -0
  157. package/lib/module/modules/BaseNonStaticModule.js.map +1 -0
  158. package/lib/module/modules/computer_vision/ClassificationModule.js +13 -8
  159. package/lib/module/modules/computer_vision/ClassificationModule.js.map +1 -1
  160. package/lib/module/modules/computer_vision/ImageEmbeddingsModule.js +19 -0
  161. package/lib/module/modules/computer_vision/ImageEmbeddingsModule.js.map +1 -0
  162. package/lib/module/modules/computer_vision/ImageSegmentationModule.js +21 -19
  163. package/lib/module/modules/computer_vision/ImageSegmentationModule.js.map +1 -1
  164. package/lib/module/modules/computer_vision/OCRModule.js +13 -10
  165. package/lib/module/modules/computer_vision/OCRModule.js.map +1 -1
  166. package/lib/module/modules/computer_vision/ObjectDetectionModule.js +13 -8
  167. package/lib/module/modules/computer_vision/ObjectDetectionModule.js.map +1 -1
  168. package/lib/module/modules/computer_vision/StyleTransferModule.js +13 -8
  169. package/lib/module/modules/computer_vision/StyleTransferModule.js.map +1 -1
  170. package/lib/module/modules/computer_vision/VerticalOCRModule.js +15 -10
  171. package/lib/module/modules/computer_vision/VerticalOCRModule.js.map +1 -1
  172. package/lib/module/modules/general/ExecutorchModule.js +10 -36
  173. package/lib/module/modules/general/ExecutorchModule.js.map +1 -1
  174. package/lib/module/modules/natural_language_processing/LLMModule.js +18 -22
  175. package/lib/module/modules/natural_language_processing/LLMModule.js.map +1 -1
  176. package/lib/module/modules/natural_language_processing/SpeechToTextModule.js +79 -27
  177. package/lib/module/modules/natural_language_processing/SpeechToTextModule.js.map +1 -1
  178. package/lib/module/modules/natural_language_processing/TextEmbeddingsModule.js +15 -8
  179. package/lib/module/modules/natural_language_processing/TextEmbeddingsModule.js.map +1 -1
  180. package/lib/module/modules/natural_language_processing/TokenizerModule.js +20 -14
  181. package/lib/module/modules/natural_language_processing/TokenizerModule.js.map +1 -1
  182. package/lib/module/native/NativeETInstaller.js +5 -0
  183. package/lib/module/native/NativeETInstaller.js.map +1 -0
  184. package/lib/module/native/RnExecutorchModules.js +2 -11
  185. package/lib/module/native/RnExecutorchModules.js.map +1 -1
  186. package/lib/module/types/common.js +25 -8
  187. package/lib/module/types/common.js.map +1 -1
  188. package/lib/module/types/stt.js +1 -79
  189. package/lib/module/types/stt.js.map +1 -1
  190. package/lib/module/utils/ResourceFetcher.js +276 -114
  191. package/lib/module/utils/ResourceFetcher.js.map +1 -1
  192. package/lib/module/utils/ResourceFetcherUtils.js +155 -0
  193. package/lib/module/utils/ResourceFetcherUtils.js.map +1 -0
  194. package/lib/module/utils/SpeechToTextModule/ASR.js +191 -0
  195. package/lib/module/utils/SpeechToTextModule/ASR.js.map +1 -0
  196. package/lib/module/utils/SpeechToTextModule/OnlineProcessor.js +73 -0
  197. package/lib/module/utils/SpeechToTextModule/OnlineProcessor.js.map +1 -0
  198. package/lib/module/utils/SpeechToTextModule/hypothesisBuffer.js +56 -0
  199. package/lib/module/utils/SpeechToTextModule/hypothesisBuffer.js.map +1 -0
  200. package/lib/module/utils/llm.js +41 -1
  201. package/lib/module/utils/llm.js.map +1 -1
  202. package/lib/typescript/Error.d.ts +2 -0
  203. package/lib/typescript/Error.d.ts.map +1 -1
  204. package/lib/typescript/common/Logger.d.ts +9 -0
  205. package/lib/typescript/common/Logger.d.ts.map +1 -0
  206. package/lib/typescript/constants/llmDefaults.d.ts +1 -0
  207. package/lib/typescript/constants/llmDefaults.d.ts.map +1 -1
  208. package/lib/typescript/constants/modelUrls.d.ts +240 -79
  209. package/lib/typescript/constants/modelUrls.d.ts.map +1 -1
  210. package/lib/typescript/constants/ocr/models.d.ts +882 -284
  211. package/lib/typescript/constants/ocr/models.d.ts.map +1 -1
  212. package/lib/typescript/controllers/LLMController.d.ts +3 -4
  213. package/lib/typescript/controllers/LLMController.d.ts.map +1 -1
  214. package/lib/typescript/controllers/OCRController.d.ts +5 -6
  215. package/lib/typescript/controllers/OCRController.d.ts.map +1 -1
  216. package/lib/typescript/controllers/VerticalOCRController.d.ts +5 -6
  217. package/lib/typescript/controllers/VerticalOCRController.d.ts.map +1 -1
  218. package/lib/typescript/hooks/computer_vision/useClassification.d.ts +8 -6
  219. package/lib/typescript/hooks/computer_vision/useClassification.d.ts.map +1 -1
  220. package/lib/typescript/hooks/computer_vision/useImageEmbeddings.d.ts +16 -0
  221. package/lib/typescript/hooks/computer_vision/useImageEmbeddings.d.ts.map +1 -0
  222. package/lib/typescript/hooks/computer_vision/useImageSegmentation.d.ts +5 -3
  223. package/lib/typescript/hooks/computer_vision/useImageSegmentation.d.ts.map +1 -1
  224. package/lib/typescript/hooks/computer_vision/useOCR.d.ts +4 -4
  225. package/lib/typescript/hooks/computer_vision/useOCR.d.ts.map +1 -1
  226. package/lib/typescript/hooks/computer_vision/useObjectDetection.d.ts +5 -3
  227. package/lib/typescript/hooks/computer_vision/useObjectDetection.d.ts.map +1 -1
  228. package/lib/typescript/hooks/computer_vision/useStyleTransfer.d.ts +5 -3
  229. package/lib/typescript/hooks/computer_vision/useStyleTransfer.d.ts.map +1 -1
  230. package/lib/typescript/hooks/computer_vision/useVerticalOCR.d.ts +3 -5
  231. package/lib/typescript/hooks/computer_vision/useVerticalOCR.d.ts.map +1 -1
  232. package/lib/typescript/hooks/general/useExecutorchModule.d.ts +1 -1
  233. package/lib/typescript/hooks/natural_language_processing/useLLM.d.ts +6 -4
  234. package/lib/typescript/hooks/natural_language_processing/useLLM.d.ts.map +1 -1
  235. package/lib/typescript/hooks/natural_language_processing/useSpeechToText.d.ts +15 -22
  236. package/lib/typescript/hooks/natural_language_processing/useSpeechToText.d.ts.map +1 -1
  237. package/lib/typescript/hooks/natural_language_processing/useTextEmbeddings.d.ts +9 -5
  238. package/lib/typescript/hooks/natural_language_processing/useTextEmbeddings.d.ts.map +1 -1
  239. package/lib/typescript/hooks/natural_language_processing/useTokenizer.d.ts +6 -4
  240. package/lib/typescript/hooks/natural_language_processing/useTokenizer.d.ts.map +1 -1
  241. package/lib/typescript/hooks/useNonStaticModule.d.ts +21 -0
  242. package/lib/typescript/hooks/useNonStaticModule.d.ts.map +1 -0
  243. package/lib/typescript/index.d.ts +17 -4
  244. package/lib/typescript/index.d.ts.map +1 -1
  245. package/lib/typescript/modules/BaseModule.d.ts +1 -1
  246. package/lib/typescript/modules/BaseModule.d.ts.map +1 -1
  247. package/lib/typescript/modules/BaseNonStaticModule.d.ts +10 -0
  248. package/lib/typescript/modules/BaseNonStaticModule.d.ts.map +1 -0
  249. package/lib/typescript/modules/computer_vision/ClassificationModule.d.ts +6 -6
  250. package/lib/typescript/modules/computer_vision/ClassificationModule.d.ts.map +1 -1
  251. package/lib/typescript/modules/computer_vision/ImageEmbeddingsModule.d.ts +9 -0
  252. package/lib/typescript/modules/computer_vision/ImageEmbeddingsModule.d.ts.map +1 -0
  253. package/lib/typescript/modules/computer_vision/ImageSegmentationModule.d.ts +8 -28
  254. package/lib/typescript/modules/computer_vision/ImageSegmentationModule.d.ts.map +1 -1
  255. package/lib/typescript/modules/computer_vision/OCRModule.d.ts +8 -7
  256. package/lib/typescript/modules/computer_vision/OCRModule.d.ts.map +1 -1
  257. package/lib/typescript/modules/computer_vision/ObjectDetectionModule.d.ts +7 -5
  258. package/lib/typescript/modules/computer_vision/ObjectDetectionModule.d.ts.map +1 -1
  259. package/lib/typescript/modules/computer_vision/StyleTransferModule.d.ts +6 -5
  260. package/lib/typescript/modules/computer_vision/StyleTransferModule.d.ts.map +1 -1
  261. package/lib/typescript/modules/computer_vision/VerticalOCRModule.d.ts +7 -8
  262. package/lib/typescript/modules/computer_vision/VerticalOCRModule.d.ts.map +1 -1
  263. package/lib/typescript/modules/general/ExecutorchModule.d.ts +5 -8
  264. package/lib/typescript/modules/general/ExecutorchModule.d.ts.map +1 -1
  265. package/lib/typescript/modules/natural_language_processing/LLMModule.d.ts +16 -16
  266. package/lib/typescript/modules/natural_language_processing/LLMModule.d.ts.map +1 -1
  267. package/lib/typescript/modules/natural_language_processing/SpeechToTextModule.d.ts +20 -13
  268. package/lib/typescript/modules/natural_language_processing/SpeechToTextModule.d.ts.map +1 -1
  269. package/lib/typescript/modules/natural_language_processing/TextEmbeddingsModule.d.ts +7 -5
  270. package/lib/typescript/modules/natural_language_processing/TextEmbeddingsModule.d.ts.map +1 -1
  271. package/lib/typescript/modules/natural_language_processing/TokenizerModule.d.ts +10 -9
  272. package/lib/typescript/modules/natural_language_processing/TokenizerModule.d.ts.map +1 -1
  273. package/lib/typescript/native/{NativeStyleTransfer.d.ts → NativeETInstaller.d.ts} +2 -3
  274. package/lib/typescript/native/NativeETInstaller.d.ts.map +1 -0
  275. package/lib/typescript/native/RnExecutorchModules.d.ts +3 -21
  276. package/lib/typescript/native/RnExecutorchModules.d.ts.map +1 -1
  277. package/lib/typescript/types/common.d.ts +30 -2
  278. package/lib/typescript/types/common.d.ts.map +1 -1
  279. package/lib/typescript/types/stt.d.ts +18 -88
  280. package/lib/typescript/types/stt.d.ts.map +1 -1
  281. package/lib/typescript/utils/ResourceFetcher.d.ts +18 -10
  282. package/lib/typescript/utils/ResourceFetcher.d.ts.map +1 -1
  283. package/lib/typescript/utils/ResourceFetcherUtils.d.ts +55 -0
  284. package/lib/typescript/utils/ResourceFetcherUtils.d.ts.map +1 -0
  285. package/lib/typescript/utils/SpeechToTextModule/ASR.d.ts +27 -0
  286. package/lib/typescript/utils/SpeechToTextModule/ASR.d.ts.map +1 -0
  287. package/lib/typescript/utils/SpeechToTextModule/OnlineProcessor.d.ts +23 -0
  288. package/lib/typescript/utils/SpeechToTextModule/OnlineProcessor.d.ts.map +1 -0
  289. package/lib/typescript/utils/SpeechToTextModule/hypothesisBuffer.d.ts +13 -0
  290. package/lib/typescript/utils/SpeechToTextModule/hypothesisBuffer.d.ts.map +1 -0
  291. package/lib/typescript/utils/llm.d.ts +4 -0
  292. package/lib/typescript/utils/llm.d.ts.map +1 -1
  293. package/package.json +23 -65
  294. package/react-native-executorch.podspec +75 -3
  295. package/src/Error.ts +8 -10
  296. package/src/common/Logger.ts +25 -0
  297. package/src/constants/llmDefaults.ts +11 -0
  298. package/src/constants/modelUrls.ts +401 -168
  299. package/src/constants/ocr/models.ts +826 -395
  300. package/src/constants/ocr/symbols.ts +63 -63
  301. package/src/controllers/LLMController.ts +28 -18
  302. package/src/controllers/OCRController.ts +24 -15
  303. package/src/controllers/VerticalOCRController.ts +24 -14
  304. package/src/hooks/computer_vision/useClassification.ts +10 -11
  305. package/src/hooks/computer_vision/useImageEmbeddings.ts +15 -0
  306. package/src/hooks/computer_vision/useImageSegmentation.ts +5 -8
  307. package/src/hooks/computer_vision/useOCR.ts +29 -21
  308. package/src/hooks/computer_vision/useObjectDetection.ts +6 -9
  309. package/src/hooks/computer_vision/useStyleTransfer.ts +6 -6
  310. package/src/hooks/computer_vision/useVerticalOCR.ts +30 -27
  311. package/src/hooks/general/useExecutorchModule.ts +3 -3
  312. package/src/hooks/natural_language_processing/useLLM.ts +38 -28
  313. package/src/hooks/natural_language_processing/useSpeechToText.ts +91 -88
  314. package/src/hooks/natural_language_processing/useTextEmbeddings.ts +11 -11
  315. package/src/hooks/natural_language_processing/useTokenizer.ts +22 -22
  316. package/src/hooks/useNonStaticModule.ts +74 -0
  317. package/src/index.ts +100 -0
  318. package/src/modules/BaseModule.ts +9 -3
  319. package/src/modules/BaseNonStaticModule.ts +26 -0
  320. package/src/modules/computer_vision/ClassificationModule.ts +20 -11
  321. package/src/modules/computer_vision/ImageEmbeddingsModule.ts +26 -0
  322. package/src/modules/computer_vision/ImageSegmentationModule.ts +35 -27
  323. package/src/modules/computer_vision/OCRModule.ts +23 -15
  324. package/src/modules/computer_vision/ObjectDetectionModule.ts +24 -11
  325. package/src/modules/computer_vision/StyleTransferModule.ts +20 -11
  326. package/src/modules/computer_vision/VerticalOCRModule.ts +25 -21
  327. package/src/modules/general/ExecutorchModule.ts +18 -48
  328. package/src/modules/natural_language_processing/LLMModule.ts +27 -30
  329. package/src/modules/natural_language_processing/SpeechToTextModule.ts +85 -68
  330. package/src/modules/natural_language_processing/TextEmbeddingsModule.ts +27 -12
  331. package/src/modules/natural_language_processing/TokenizerModule.ts +27 -17
  332. package/src/native/NativeETInstaller.ts +8 -0
  333. package/src/native/RnExecutorchModules.ts +4 -46
  334. package/src/types/common.ts +40 -12
  335. package/src/types/stt.ts +98 -89
  336. package/src/utils/ResourceFetcher.ts +338 -119
  337. package/src/utils/ResourceFetcherUtils.ts +186 -0
  338. package/src/utils/SpeechToTextModule/ASR.ts +303 -0
  339. package/src/utils/SpeechToTextModule/OnlineProcessor.ts +87 -0
  340. package/src/utils/SpeechToTextModule/hypothesisBuffer.ts +79 -0
  341. package/src/utils/llm.ts +65 -1
  342. package/third-party/android/libs/executorch/arm64-v8a/libexecutorch.so +0 -0
  343. package/third-party/android/libs/executorch/x86_64/libexecutorch.so +0 -0
  344. package/third-party/android/libs/opencv/arm64-v8a/libopencv_core.a +0 -0
  345. package/third-party/android/libs/opencv/arm64-v8a/libopencv_features2d.a +0 -0
  346. package/third-party/android/libs/opencv/arm64-v8a/libopencv_highgui.a +0 -0
  347. package/third-party/android/libs/opencv/arm64-v8a/libopencv_imgproc.a +0 -0
  348. package/third-party/android/libs/opencv/arm64-v8a/libopencv_photo.a +0 -0
  349. package/third-party/android/libs/opencv/arm64-v8a/libopencv_video.a +0 -0
  350. package/third-party/android/libs/opencv/x86_64/libopencv_core.a +0 -0
  351. package/third-party/android/libs/opencv/x86_64/libopencv_features2d.a +0 -0
  352. package/third-party/android/libs/opencv/x86_64/libopencv_highgui.a +0 -0
  353. package/third-party/android/libs/opencv/x86_64/libopencv_imgproc.a +0 -0
  354. package/third-party/android/libs/opencv/x86_64/libopencv_photo.a +0 -0
  355. package/third-party/android/libs/opencv/x86_64/libopencv_video.a +0 -0
  356. package/third-party/android/libs/opencv-third-party/arm64-v8a/libkleidicv.a +0 -0
  357. package/third-party/android/libs/opencv-third-party/arm64-v8a/libkleidicv_hal.a +0 -0
  358. package/third-party/android/libs/opencv-third-party/arm64-v8a/libkleidicv_thread.a +0 -0
  359. package/third-party/include/c10/macros/Export.h +163 -0
  360. package/third-party/include/c10/macros/Macros.h +497 -0
  361. package/third-party/include/c10/util/BFloat16-inl.h +342 -0
  362. package/third-party/include/c10/util/BFloat16-math.h +266 -0
  363. package/third-party/include/c10/util/BFloat16.h +125 -0
  364. package/third-party/include/c10/util/Half-inl.h +347 -0
  365. package/third-party/include/c10/util/Half.h +416 -0
  366. package/third-party/include/c10/util/TypeSafeSignMath.h +133 -0
  367. package/third-party/include/c10/util/bit_cast.h +43 -0
  368. package/third-party/include/c10/util/floating_point_utils.h +33 -0
  369. package/third-party/include/c10/util/irange.h +107 -0
  370. package/third-party/include/executorch/ExecuTorch.h +13 -0
  371. package/third-party/include/executorch/ExecuTorchError.h +16 -0
  372. package/third-party/include/executorch/ExecuTorchLog.h +76 -0
  373. package/third-party/include/executorch/ExecuTorchModule.h +286 -0
  374. package/third-party/include/executorch/ExecuTorchTensor.h +742 -0
  375. package/third-party/include/executorch/ExecuTorchValue.h +219 -0
  376. package/third-party/include/executorch/extension/module/module.h +492 -0
  377. package/third-party/include/executorch/extension/tensor/tensor.h +13 -0
  378. package/third-party/include/executorch/extension/tensor/tensor_accessor.h +190 -0
  379. package/third-party/include/executorch/extension/tensor/tensor_ptr.h +347 -0
  380. package/third-party/include/executorch/extension/tensor/tensor_ptr_maker.h +653 -0
  381. package/third-party/include/executorch/runtime/backend/backend_execution_context.h +71 -0
  382. package/third-party/include/executorch/runtime/backend/backend_init_context.h +72 -0
  383. package/third-party/include/executorch/runtime/backend/interface.h +166 -0
  384. package/third-party/include/executorch/runtime/core/array_ref.h +235 -0
  385. package/third-party/include/executorch/runtime/core/data_loader.h +136 -0
  386. package/third-party/include/executorch/runtime/core/defines.h +20 -0
  387. package/third-party/include/executorch/runtime/core/error.h +229 -0
  388. package/third-party/include/executorch/runtime/core/evalue.h +521 -0
  389. package/third-party/include/executorch/runtime/core/event_tracer.h +565 -0
  390. package/third-party/include/executorch/runtime/core/event_tracer_hooks.h +323 -0
  391. package/third-party/include/executorch/runtime/core/event_tracer_hooks_delegate.h +197 -0
  392. package/third-party/include/executorch/runtime/core/exec_aten/exec_aten.h +147 -0
  393. package/third-party/include/executorch/runtime/core/exec_aten/util/dim_order_util.h +263 -0
  394. package/third-party/include/executorch/runtime/core/exec_aten/util/scalar_type_util.h +1331 -0
  395. package/third-party/include/executorch/runtime/core/exec_aten/util/tensor_dimension_limit.h +21 -0
  396. package/third-party/include/executorch/runtime/core/exec_aten/util/tensor_shape_to_c_string.h +69 -0
  397. package/third-party/include/executorch/runtime/core/exec_aten/util/tensor_util.h +1250 -0
  398. package/third-party/include/executorch/runtime/core/freeable_buffer.h +107 -0
  399. package/third-party/include/executorch/runtime/core/hierarchical_allocator.h +107 -0
  400. package/third-party/include/executorch/runtime/core/memory_allocator.h +198 -0
  401. package/third-party/include/executorch/runtime/core/named_data_map.h +86 -0
  402. package/third-party/include/executorch/runtime/core/portable_type/bfloat16.h +27 -0
  403. package/third-party/include/executorch/runtime/core/portable_type/bfloat16_math.h +14 -0
  404. package/third-party/include/executorch/runtime/core/portable_type/bits_types.h +83 -0
  405. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/macros/Export.h +163 -0
  406. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/macros/Macros.h +497 -0
  407. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-inl.h +342 -0
  408. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-math.h +266 -0
  409. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/BFloat16.h +125 -0
  410. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/Half-inl.h +347 -0
  411. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/Half.h +416 -0
  412. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/TypeSafeSignMath.h +133 -0
  413. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/bit_cast.h +43 -0
  414. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/floating_point_utils.h +33 -0
  415. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/irange.h +107 -0
  416. package/third-party/include/executorch/runtime/core/portable_type/complex.h +44 -0
  417. package/third-party/include/executorch/runtime/core/portable_type/device.h +70 -0
  418. package/third-party/include/executorch/runtime/core/portable_type/half.h +27 -0
  419. package/third-party/include/executorch/runtime/core/portable_type/optional.h +36 -0
  420. package/third-party/include/executorch/runtime/core/portable_type/qint_types.h +83 -0
  421. package/third-party/include/executorch/runtime/core/portable_type/scalar.h +110 -0
  422. package/third-party/include/executorch/runtime/core/portable_type/scalar_type.h +154 -0
  423. package/third-party/include/executorch/runtime/core/portable_type/string_view.h +29 -0
  424. package/third-party/include/executorch/runtime/core/portable_type/tensor.h +142 -0
  425. package/third-party/include/executorch/runtime/core/portable_type/tensor_impl.h +261 -0
  426. package/third-party/include/executorch/runtime/core/portable_type/tensor_options.h +60 -0
  427. package/third-party/include/executorch/runtime/core/result.h +258 -0
  428. package/third-party/include/executorch/runtime/core/span.h +93 -0
  429. package/third-party/include/executorch/runtime/core/tag.h +71 -0
  430. package/third-party/include/executorch/runtime/core/tensor_layout.h +79 -0
  431. package/third-party/include/executorch/runtime/core/tensor_shape_dynamism.h +39 -0
  432. package/third-party/include/executorch/runtime/executor/memory_manager.h +113 -0
  433. package/third-party/include/executorch/runtime/executor/method.h +387 -0
  434. package/third-party/include/executorch/runtime/executor/method_meta.h +251 -0
  435. package/third-party/include/executorch/runtime/executor/program.h +320 -0
  436. package/third-party/include/executorch/runtime/executor/pte_data_map.h +144 -0
  437. package/third-party/include/executorch/runtime/executor/tensor_parser.h +156 -0
  438. package/third-party/include/executorch/runtime/kernel/kernel_runtime_context.h +122 -0
  439. package/third-party/include/executorch/runtime/kernel/operator_registry.h +278 -0
  440. package/third-party/include/executorch/runtime/platform/abort.h +36 -0
  441. package/third-party/include/executorch/runtime/platform/assert.h +119 -0
  442. package/third-party/include/executorch/runtime/platform/clock.h +43 -0
  443. package/third-party/include/executorch/runtime/platform/compat_unistd.h +75 -0
  444. package/third-party/include/executorch/runtime/platform/compiler.h +191 -0
  445. package/third-party/include/executorch/runtime/platform/log.h +177 -0
  446. package/third-party/include/executorch/runtime/platform/platform.h +133 -0
  447. package/third-party/include/executorch/runtime/platform/profiler.h +292 -0
  448. package/third-party/include/executorch/runtime/platform/runtime.h +35 -0
  449. package/third-party/include/executorch/runtime/platform/system.h +49 -0
  450. package/third-party/include/executorch/runtime/platform/types.h +24 -0
  451. package/third-party/include/executorch/schema/extended_header.h +76 -0
  452. package/third-party/include/opencv2/core/affine.hpp +676 -0
  453. package/third-party/include/opencv2/core/async.hpp +107 -0
  454. package/third-party/include/opencv2/core/base.hpp +735 -0
  455. package/third-party/include/opencv2/core/bindings_utils.hpp +279 -0
  456. package/third-party/include/opencv2/core/bufferpool.hpp +39 -0
  457. package/third-party/include/opencv2/core/check.hpp +231 -0
  458. package/third-party/include/opencv2/core/core.hpp +55 -0
  459. package/third-party/include/opencv2/core/core_c.h +3261 -0
  460. package/third-party/include/opencv2/core/cv_cpu_dispatch.h +404 -0
  461. package/third-party/include/opencv2/core/cv_cpu_helper.h +856 -0
  462. package/third-party/include/opencv2/core/cvdef.h +1003 -0
  463. package/third-party/include/opencv2/core/cvstd.hpp +196 -0
  464. package/third-party/include/opencv2/core/cvstd.inl.hpp +188 -0
  465. package/third-party/include/opencv2/core/cvstd_wrapper.hpp +187 -0
  466. package/third-party/include/opencv2/core/detail/async_promise.hpp +73 -0
  467. package/third-party/include/opencv2/core/detail/dispatch_helper.impl.hpp +48 -0
  468. package/third-party/include/opencv2/core/detail/exception_ptr.hpp +24 -0
  469. package/third-party/include/opencv2/core/dualquaternion.hpp +1054 -0
  470. package/third-party/include/opencv2/core/dualquaternion.inl.hpp +464 -0
  471. package/third-party/include/opencv2/core/eigen.hpp +405 -0
  472. package/third-party/include/opencv2/core/fast_math.hpp +433 -0
  473. package/third-party/include/opencv2/core/hal/hal.hpp +451 -0
  474. package/third-party/include/opencv2/core/hal/interface.h +191 -0
  475. package/third-party/include/opencv2/core/hal/intrin.hpp +1222 -0
  476. package/third-party/include/opencv2/core/hal/intrin_avx.hpp +3378 -0
  477. package/third-party/include/opencv2/core/hal/intrin_avx512.hpp +3688 -0
  478. package/third-party/include/opencv2/core/hal/intrin_cpp.hpp +3446 -0
  479. package/third-party/include/opencv2/core/hal/intrin_forward.hpp +195 -0
  480. package/third-party/include/opencv2/core/hal/intrin_lasx.hpp +3243 -0
  481. package/third-party/include/opencv2/core/hal/intrin_lsx.hpp +2671 -0
  482. package/third-party/include/opencv2/core/hal/intrin_math.hpp +772 -0
  483. package/third-party/include/opencv2/core/hal/intrin_msa.hpp +1973 -0
  484. package/third-party/include/opencv2/core/hal/intrin_neon.hpp +2710 -0
  485. package/third-party/include/opencv2/core/hal/intrin_rvv071.hpp +3452 -0
  486. package/third-party/include/opencv2/core/hal/intrin_rvv_scalable.hpp +2559 -0
  487. package/third-party/include/opencv2/core/hal/intrin_sse.hpp +3528 -0
  488. package/third-party/include/opencv2/core/hal/intrin_sse_em.hpp +175 -0
  489. package/third-party/include/opencv2/core/hal/intrin_vsx.hpp +1756 -0
  490. package/third-party/include/opencv2/core/hal/intrin_wasm.hpp +2911 -0
  491. package/third-party/include/opencv2/core/hal/msa_macros.h +2079 -0
  492. package/third-party/include/opencv2/core/hal/simd_utils.impl.hpp +313 -0
  493. package/third-party/include/opencv2/core/mat.hpp +3842 -0
  494. package/third-party/include/opencv2/core/mat.inl.hpp +2753 -0
  495. package/third-party/include/opencv2/core/matx.hpp +603 -0
  496. package/third-party/include/opencv2/core/matx.inl.hpp +1132 -0
  497. package/third-party/include/opencv2/core/neon_utils.hpp +127 -0
  498. package/third-party/include/opencv2/core/operations.hpp +610 -0
  499. package/third-party/include/opencv2/core/optim.hpp +362 -0
  500. package/third-party/include/opencv2/core/parallel/backend/parallel_for.openmp.hpp +66 -0
  501. package/third-party/include/opencv2/core/parallel/backend/parallel_for.tbb.hpp +148 -0
  502. package/third-party/include/opencv2/core/parallel/parallel_backend.hpp +108 -0
  503. package/third-party/include/opencv2/core/persistence.hpp +1321 -0
  504. package/third-party/include/opencv2/core/quaternion.hpp +1889 -0
  505. package/third-party/include/opencv2/core/quaternion.inl.hpp +907 -0
  506. package/third-party/include/opencv2/core/saturate.hpp +347 -0
  507. package/third-party/include/opencv2/core/simd_intrinsics.hpp +90 -0
  508. package/third-party/include/opencv2/core/softfloat.hpp +657 -0
  509. package/third-party/include/opencv2/core/sse_utils.hpp +861 -0
  510. package/third-party/include/opencv2/core/traits.hpp +417 -0
  511. package/third-party/include/opencv2/core/types.hpp +2368 -0
  512. package/third-party/include/opencv2/core/types_c.h +2064 -0
  513. package/third-party/include/opencv2/core/utility.hpp +1296 -0
  514. package/third-party/include/opencv2/core/utils/allocator_stats.hpp +31 -0
  515. package/third-party/include/opencv2/core/utils/allocator_stats.impl.hpp +111 -0
  516. package/third-party/include/opencv2/core/utils/filesystem.hpp +91 -0
  517. package/third-party/include/opencv2/core/utils/fp_control_utils.hpp +70 -0
  518. package/third-party/include/opencv2/core/utils/instrumentation.hpp +127 -0
  519. package/third-party/include/opencv2/core/utils/logger.defines.hpp +50 -0
  520. package/third-party/include/opencv2/core/utils/logger.hpp +258 -0
  521. package/third-party/include/opencv2/core/utils/logtag.hpp +27 -0
  522. package/third-party/include/opencv2/core/utils/tls.hpp +230 -0
  523. package/third-party/include/opencv2/core/utils/trace.hpp +281 -0
  524. package/third-party/include/opencv2/core/version.hpp +29 -0
  525. package/third-party/include/opencv2/core/vsx_utils.hpp +1115 -0
  526. package/third-party/include/opencv2/core.hpp +3699 -0
  527. package/third-party/include/opencv2/cvconfig.h +155 -0
  528. package/third-party/include/opencv2/dnn/dnn.hpp +51 -0
  529. package/third-party/include/opencv2/dnn.hpp +17 -0
  530. package/third-party/include/opencv2/features2d/features2d.hpp +55 -0
  531. package/third-party/include/opencv2/features2d/hal/interface.h +32 -0
  532. package/third-party/include/opencv2/features2d.hpp +1756 -0
  533. package/third-party/include/opencv2/highgui/highgui.hpp +113 -0
  534. package/third-party/include/opencv2/highgui.hpp +17 -0
  535. package/third-party/include/opencv2/imgproc/bindings.hpp +34 -0
  536. package/third-party/include/opencv2/imgproc/detail/gcgraph.hpp +355 -0
  537. package/third-party/include/opencv2/imgproc/detail/legacy.hpp +35 -0
  538. package/third-party/include/opencv2/imgproc/hal/hal.hpp +246 -0
  539. package/third-party/include/opencv2/imgproc/hal/interface.h +52 -0
  540. package/third-party/include/opencv2/imgproc/imgproc.hpp +55 -0
  541. package/third-party/include/opencv2/imgproc/imgproc_c.h +1261 -0
  542. package/third-party/include/opencv2/imgproc/segmentation.hpp +168 -0
  543. package/third-party/include/opencv2/imgproc/types_c.h +632 -0
  544. package/third-party/include/opencv2/imgproc.hpp +5956 -0
  545. package/third-party/include/opencv2/opencv.hpp +102 -0
  546. package/third-party/include/opencv2/opencv_modules.hpp +19 -0
  547. package/third-party/include/opencv2/photo/legacy/constants_c.h +10 -0
  548. package/third-party/include/opencv2/photo/photo.hpp +55 -0
  549. package/third-party/include/opencv2/photo.hpp +975 -0
  550. package/third-party/include/opencv2/video/background_segm.hpp +341 -0
  551. package/third-party/include/opencv2/video/detail/tracking.detail.hpp +435 -0
  552. package/third-party/include/opencv2/video/legacy/constants_c.h +15 -0
  553. package/third-party/include/opencv2/video/tracking.hpp +1014 -0
  554. package/third-party/include/opencv2/video/video.hpp +55 -0
  555. package/third-party/include/opencv2/video.hpp +65 -0
  556. package/third-party/include/tokenizers-cpp/tokenizers_c.h +61 -0
  557. package/third-party/include/tokenizers-cpp/tokenizers_cpp.h +118 -0
  558. package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/ETModel.h +27 -0
  559. package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/ETModel.mm +249 -0
  560. package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/HuggingFaceTokenizer.h +14 -0
  561. package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/HuggingFaceTokenizer.mm +80 -0
  562. package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/LLaMARunner.h +32 -0
  563. package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/LLaMARunner.mm +95 -0
  564. package/third-party/ios/ExecutorchLib/ExecutorchLib/InputType.h +12 -0
  565. package/third-party/ios/ExecutorchLib/ExecutorchLib/Utils.hpp +217 -0
  566. package/third-party/ios/ExecutorchLib/ExecutorchLib/model/Model.cpp +11 -0
  567. package/third-party/ios/ExecutorchLib/ExecutorchLib/model/Model.h +11 -0
  568. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/irunner.h +48 -0
  569. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/runner.cpp +278 -0
  570. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/runner.h +67 -0
  571. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/stats.h +164 -0
  572. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/text_decoder_runner.cpp +65 -0
  573. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/text_decoder_runner.h +105 -0
  574. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/text_prefiller.cpp +91 -0
  575. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/text_prefiller.h +51 -0
  576. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/text_token_generator.h +162 -0
  577. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/util.h +108 -0
  578. package/third-party/ios/ExecutorchLib/ExecutorchLib/sampler/sampler.cpp +193 -0
  579. package/third-party/ios/ExecutorchLib/ExecutorchLib/sampler/sampler.h +64 -0
  580. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/base64.h +202 -0
  581. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/bpe_tokenizer.cpp +313 -0
  582. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/bpe_tokenizer.h +57 -0
  583. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/llama_tiktoken.cpp +78 -0
  584. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/llama_tiktoken.h +23 -0
  585. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/tiktoken.cpp +427 -0
  586. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/tiktoken.h +87 -0
  587. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/tokenizer.h +76 -0
  588. package/third-party/ios/ExecutorchLib/ExecutorchLib.xcodeproj/project.pbxproj +683 -0
  589. package/third-party/ios/ExecutorchLib/build.sh +44 -0
  590. package/third-party/ios/ExecutorchLib/frameworks/backend_coreml.xcframework/Info.plist +43 -0
  591. package/third-party/ios/ExecutorchLib/frameworks/backend_coreml.xcframework/ios-arm64/libbackend_coreml_ios.a +0 -0
  592. package/third-party/ios/ExecutorchLib/frameworks/backend_coreml.xcframework/ios-arm64-simulator/libbackend_coreml_simulator.a +0 -0
  593. package/third-party/ios/ExecutorchLib/frameworks/backend_mps.xcframework/Info.plist +43 -0
  594. package/third-party/ios/ExecutorchLib/frameworks/backend_mps.xcframework/ios-arm64/libbackend_mps_ios.a +0 -0
  595. package/third-party/ios/ExecutorchLib/frameworks/backend_mps.xcframework/ios-arm64-simulator/libbackend_mps_simulator.a +0 -0
  596. package/third-party/ios/ExecutorchLib/frameworks/backend_xnnpack.xcframework/Info.plist +43 -0
  597. package/third-party/ios/ExecutorchLib/frameworks/backend_xnnpack.xcframework/ios-arm64/libbackend_xnnpack_ios.a +0 -0
  598. package/third-party/ios/ExecutorchLib/frameworks/backend_xnnpack.xcframework/ios-arm64-simulator/libbackend_xnnpack_simulator.a +0 -0
  599. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/Info.plist +47 -0
  600. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/macros/Export.h +163 -0
  601. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/macros/Macros.h +497 -0
  602. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/BFloat16-inl.h +342 -0
  603. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/BFloat16-math.h +266 -0
  604. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/BFloat16.h +125 -0
  605. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/Half-inl.h +347 -0
  606. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/Half.h +416 -0
  607. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/TypeSafeSignMath.h +133 -0
  608. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/bit_cast.h +43 -0
  609. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/floating_point_utils.h +33 -0
  610. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/irange.h +107 -0
  611. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorch.h +13 -0
  612. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchError.h +16 -0
  613. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchLog.h +76 -0
  614. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchModule.h +286 -0
  615. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchTensor.h +742 -0
  616. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchValue.h +219 -0
  617. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/module/module.h +492 -0
  618. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/tensor/tensor.h +13 -0
  619. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/tensor/tensor_accessor.h +190 -0
  620. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/tensor/tensor_ptr.h +347 -0
  621. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/tensor/tensor_ptr_maker.h +653 -0
  622. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/backend/backend_execution_context.h +71 -0
  623. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/backend/backend_init_context.h +72 -0
  624. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/backend/interface.h +166 -0
  625. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/array_ref.h +235 -0
  626. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/data_loader.h +136 -0
  627. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/defines.h +20 -0
  628. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/error.h +229 -0
  629. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/evalue.h +521 -0
  630. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/event_tracer.h +565 -0
  631. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/event_tracer_hooks.h +323 -0
  632. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/event_tracer_hooks_delegate.h +197 -0
  633. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/exec_aten.h +147 -0
  634. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/util/dim_order_util.h +263 -0
  635. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/util/scalar_type_util.h +1331 -0
  636. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/util/tensor_dimension_limit.h +21 -0
  637. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/util/tensor_shape_to_c_string.h +69 -0
  638. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/util/tensor_util.h +1250 -0
  639. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/freeable_buffer.h +107 -0
  640. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/hierarchical_allocator.h +107 -0
  641. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/memory_allocator.h +198 -0
  642. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/named_data_map.h +86 -0
  643. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/bfloat16.h +27 -0
  644. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/bfloat16_math.h +14 -0
  645. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/bits_types.h +83 -0
  646. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/macros/Export.h +163 -0
  647. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/macros/Macros.h +497 -0
  648. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-inl.h +342 -0
  649. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-math.h +266 -0
  650. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16.h +125 -0
  651. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/Half-inl.h +347 -0
  652. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/Half.h +416 -0
  653. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/TypeSafeSignMath.h +133 -0
  654. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/bit_cast.h +43 -0
  655. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/floating_point_utils.h +33 -0
  656. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/irange.h +107 -0
  657. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/complex.h +44 -0
  658. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/device.h +70 -0
  659. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/half.h +27 -0
  660. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/optional.h +36 -0
  661. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/qint_types.h +83 -0
  662. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/scalar.h +110 -0
  663. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/scalar_type.h +154 -0
  664. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/string_view.h +29 -0
  665. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/tensor.h +142 -0
  666. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/tensor_impl.h +261 -0
  667. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/tensor_options.h +60 -0
  668. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/result.h +258 -0
  669. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/span.h +93 -0
  670. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/tag.h +71 -0
  671. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/tensor_layout.h +79 -0
  672. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/tensor_shape_dynamism.h +39 -0
  673. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/memory_manager.h +113 -0
  674. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/method.h +387 -0
  675. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/method_meta.h +251 -0
  676. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/program.h +320 -0
  677. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/pte_data_map.h +144 -0
  678. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/tensor_parser.h +156 -0
  679. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/kernel/kernel_runtime_context.h +122 -0
  680. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/kernel/operator_registry.h +278 -0
  681. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/abort.h +36 -0
  682. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/assert.h +119 -0
  683. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/clock.h +43 -0
  684. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/compat_unistd.h +75 -0
  685. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/compiler.h +191 -0
  686. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/log.h +177 -0
  687. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/platform.h +133 -0
  688. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/profiler.h +292 -0
  689. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/runtime.h +35 -0
  690. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/system.h +49 -0
  691. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/types.h +24 -0
  692. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/schema/extended_header.h +76 -0
  693. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/module.modulemap +5 -0
  694. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/libexecutorch_ios.a +0 -0
  695. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/macros/Export.h +163 -0
  696. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/macros/Macros.h +497 -0
  697. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/BFloat16-inl.h +342 -0
  698. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/BFloat16-math.h +266 -0
  699. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/BFloat16.h +125 -0
  700. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/Half-inl.h +347 -0
  701. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/Half.h +416 -0
  702. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/TypeSafeSignMath.h +133 -0
  703. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/bit_cast.h +43 -0
  704. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/floating_point_utils.h +33 -0
  705. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/irange.h +107 -0
  706. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorch.h +13 -0
  707. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchError.h +16 -0
  708. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchLog.h +76 -0
  709. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchModule.h +286 -0
  710. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchTensor.h +742 -0
  711. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchValue.h +219 -0
  712. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/module/module.h +492 -0
  713. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/tensor/tensor.h +13 -0
  714. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/tensor/tensor_accessor.h +190 -0
  715. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/tensor/tensor_ptr.h +347 -0
  716. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/tensor/tensor_ptr_maker.h +653 -0
  717. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/backend/backend_execution_context.h +71 -0
  718. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/backend/backend_init_context.h +72 -0
  719. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/backend/interface.h +166 -0
  720. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/array_ref.h +235 -0
  721. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/data_loader.h +136 -0
  722. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/defines.h +20 -0
  723. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/error.h +229 -0
  724. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/evalue.h +521 -0
  725. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/event_tracer.h +565 -0
  726. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/event_tracer_hooks.h +323 -0
  727. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/event_tracer_hooks_delegate.h +197 -0
  728. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/exec_aten.h +147 -0
  729. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/util/dim_order_util.h +263 -0
  730. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/util/scalar_type_util.h +1331 -0
  731. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/util/tensor_dimension_limit.h +21 -0
  732. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/util/tensor_shape_to_c_string.h +69 -0
  733. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/util/tensor_util.h +1250 -0
  734. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/freeable_buffer.h +107 -0
  735. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/hierarchical_allocator.h +107 -0
  736. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/memory_allocator.h +198 -0
  737. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/named_data_map.h +86 -0
  738. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/bfloat16.h +27 -0
  739. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/bfloat16_math.h +14 -0
  740. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/bits_types.h +83 -0
  741. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/macros/Export.h +163 -0
  742. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/macros/Macros.h +497 -0
  743. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-inl.h +342 -0
  744. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-math.h +266 -0
  745. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16.h +125 -0
  746. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/Half-inl.h +347 -0
  747. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/Half.h +416 -0
  748. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/TypeSafeSignMath.h +133 -0
  749. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/bit_cast.h +43 -0
  750. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/floating_point_utils.h +33 -0
  751. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/irange.h +107 -0
  752. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/complex.h +44 -0
  753. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/device.h +70 -0
  754. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/half.h +27 -0
  755. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/optional.h +36 -0
  756. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/qint_types.h +83 -0
  757. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/scalar.h +110 -0
  758. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/scalar_type.h +154 -0
  759. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/string_view.h +29 -0
  760. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/tensor.h +142 -0
  761. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/tensor_impl.h +261 -0
  762. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/tensor_options.h +60 -0
  763. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/result.h +258 -0
  764. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/span.h +93 -0
  765. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/tag.h +71 -0
  766. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/tensor_layout.h +79 -0
  767. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/tensor_shape_dynamism.h +39 -0
  768. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/memory_manager.h +113 -0
  769. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/method.h +387 -0
  770. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/method_meta.h +251 -0
  771. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/program.h +320 -0
  772. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/pte_data_map.h +144 -0
  773. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/tensor_parser.h +156 -0
  774. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/kernel/kernel_runtime_context.h +122 -0
  775. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/kernel/operator_registry.h +278 -0
  776. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/abort.h +36 -0
  777. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/assert.h +119 -0
  778. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/clock.h +43 -0
  779. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/compat_unistd.h +75 -0
  780. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/compiler.h +191 -0
  781. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/log.h +177 -0
  782. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/platform.h +133 -0
  783. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/profiler.h +292 -0
  784. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/runtime.h +35 -0
  785. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/system.h +49 -0
  786. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/types.h +24 -0
  787. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/schema/extended_header.h +76 -0
  788. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/module.modulemap +5 -0
  789. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/libexecutorch_simulator.a +0 -0
  790. package/third-party/ios/ExecutorchLib/frameworks/kernels_custom.xcframework/Info.plist +43 -0
  791. package/third-party/ios/ExecutorchLib/frameworks/kernels_custom.xcframework/ios-arm64/libkernels_custom_ios.a +0 -0
  792. package/third-party/ios/ExecutorchLib/frameworks/kernels_custom.xcframework/ios-arm64-simulator/libkernels_custom_simulator.a +0 -0
  793. package/third-party/ios/ExecutorchLib/frameworks/kernels_optimized.xcframework/Info.plist +43 -0
  794. package/third-party/ios/ExecutorchLib/frameworks/kernels_optimized.xcframework/ios-arm64/libkernels_optimized_ios.a +0 -0
  795. package/third-party/ios/ExecutorchLib/frameworks/kernels_optimized.xcframework/ios-arm64-simulator/libkernels_optimized_simulator.a +0 -0
  796. package/third-party/ios/ExecutorchLib/frameworks/kernels_portable.xcframework/Info.plist +43 -0
  797. package/third-party/ios/ExecutorchLib/frameworks/kernels_portable.xcframework/ios-arm64/libkernels_portable_ios.a +0 -0
  798. package/third-party/ios/ExecutorchLib/frameworks/kernels_portable.xcframework/ios-arm64-simulator/libkernels_portable_simulator.a +0 -0
  799. package/third-party/ios/ExecutorchLib/frameworks/kernels_quantized.xcframework/Info.plist +43 -0
  800. package/third-party/ios/ExecutorchLib/frameworks/kernels_quantized.xcframework/ios-arm64/libkernels_quantized_ios.a +0 -0
  801. package/third-party/ios/ExecutorchLib/frameworks/kernels_quantized.xcframework/ios-arm64-simulator/libkernels_quantized_simulator.a +0 -0
  802. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/Info.plist +43 -0
  803. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/bitmap256.h +82 -0
  804. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/filtered_re2.h +111 -0
  805. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/pod_array.h +43 -0
  806. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/prefilter.h +130 -0
  807. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/prefilter_tree.h +139 -0
  808. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/prog.h +483 -0
  809. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/re2.h +994 -0
  810. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/regexp.h +692 -0
  811. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/set.h +85 -0
  812. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/sparse_array.h +367 -0
  813. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/sparse_set.h +241 -0
  814. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/stringpiece.h +205 -0
  815. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/unicode_casefold.h +78 -0
  816. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/unicode_groups.h +64 -0
  817. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/walker-inl.h +235 -0
  818. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Info.plist +26 -0
  819. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/re2 +0 -0
  820. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/bitmap256.h +82 -0
  821. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/filtered_re2.h +111 -0
  822. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/pod_array.h +43 -0
  823. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/prefilter.h +130 -0
  824. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/prefilter_tree.h +139 -0
  825. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/prog.h +483 -0
  826. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/re2.h +994 -0
  827. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/regexp.h +692 -0
  828. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/set.h +85 -0
  829. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/sparse_array.h +367 -0
  830. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/sparse_set.h +241 -0
  831. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/stringpiece.h +205 -0
  832. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/unicode_casefold.h +78 -0
  833. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/unicode_groups.h +64 -0
  834. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/walker-inl.h +235 -0
  835. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Info.plist +26 -0
  836. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/re2 +0 -0
  837. package/third-party/ios/ios.toolchain.cmake +1122 -0
  838. package/LICENSE +0 -79
  839. package/README.md +0 -148
  840. package/android/src/main/java/com/swmansion/rnexecutorch/Classification.kt +0 -64
  841. package/android/src/main/java/com/swmansion/rnexecutorch/ETModule.kt +0 -90
  842. package/android/src/main/java/com/swmansion/rnexecutorch/ImageSegmentation.kt +0 -58
  843. package/android/src/main/java/com/swmansion/rnexecutorch/OCR.kt +0 -90
  844. package/android/src/main/java/com/swmansion/rnexecutorch/ObjectDetection.kt +0 -64
  845. package/android/src/main/java/com/swmansion/rnexecutorch/SpeechToText.kt +0 -91
  846. package/android/src/main/java/com/swmansion/rnexecutorch/StyleTransfer.kt +0 -54
  847. package/android/src/main/java/com/swmansion/rnexecutorch/TextEmbeddings.kt +0 -51
  848. package/android/src/main/java/com/swmansion/rnexecutorch/Tokenizer.kt +0 -86
  849. package/android/src/main/java/com/swmansion/rnexecutorch/VerticalOCR.kt +0 -179
  850. package/android/src/main/java/com/swmansion/rnexecutorch/models/BaseModel.kt +0 -54
  851. package/android/src/main/java/com/swmansion/rnexecutorch/models/TextEmbeddings/TextEmbeddingsModel.kt +0 -48
  852. package/android/src/main/java/com/swmansion/rnexecutorch/models/TextEmbeddings/TextEmbeddingsUtils.kt +0 -37
  853. package/android/src/main/java/com/swmansion/rnexecutorch/models/classification/ClassificationModel.kt +0 -46
  854. package/android/src/main/java/com/swmansion/rnexecutorch/models/classification/Constants.kt +0 -1005
  855. package/android/src/main/java/com/swmansion/rnexecutorch/models/imageSegmentation/Constants.kt +0 -26
  856. package/android/src/main/java/com/swmansion/rnexecutorch/models/imageSegmentation/ImageSegmentationModel.kt +0 -142
  857. package/android/src/main/java/com/swmansion/rnexecutorch/models/objectDetection/SSDLiteLargeModel.kt +0 -74
  858. package/android/src/main/java/com/swmansion/rnexecutorch/models/ocr/Detector.kt +0 -82
  859. package/android/src/main/java/com/swmansion/rnexecutorch/models/ocr/RecognitionHandler.kt +0 -117
  860. package/android/src/main/java/com/swmansion/rnexecutorch/models/ocr/Recognizer.kt +0 -51
  861. package/android/src/main/java/com/swmansion/rnexecutorch/models/ocr/VerticalDetector.kt +0 -89
  862. package/android/src/main/java/com/swmansion/rnexecutorch/models/ocr/utils/CTCLabelConverter.kt +0 -58
  863. package/android/src/main/java/com/swmansion/rnexecutorch/models/ocr/utils/Constants.kt +0 -31
  864. package/android/src/main/java/com/swmansion/rnexecutorch/models/ocr/utils/DetectorUtils.kt +0 -608
  865. package/android/src/main/java/com/swmansion/rnexecutorch/models/ocr/utils/RecognizerUtils.kt +0 -430
  866. package/android/src/main/java/com/swmansion/rnexecutorch/models/speechToText/BaseS2TDecoder.kt +0 -39
  867. package/android/src/main/java/com/swmansion/rnexecutorch/models/speechToText/BaseS2TModule.kt +0 -43
  868. package/android/src/main/java/com/swmansion/rnexecutorch/models/speechToText/Moonshine.kt +0 -16
  869. package/android/src/main/java/com/swmansion/rnexecutorch/models/speechToText/MoonshineDecoder.kt +0 -23
  870. package/android/src/main/java/com/swmansion/rnexecutorch/models/speechToText/MoonshineEncoder.kt +0 -20
  871. package/android/src/main/java/com/swmansion/rnexecutorch/models/speechToText/Whisper.kt +0 -16
  872. package/android/src/main/java/com/swmansion/rnexecutorch/models/speechToText/WhisperDecoder.kt +0 -22
  873. package/android/src/main/java/com/swmansion/rnexecutorch/models/speechToText/WhisperEncoder.kt +0 -29
  874. package/android/src/main/java/com/swmansion/rnexecutorch/models/styleTransfer/StyleTransferModel.kt +0 -43
  875. package/android/src/main/java/com/swmansion/rnexecutorch/utils/ArrayUtils.kt +0 -87
  876. package/android/src/main/java/com/swmansion/rnexecutorch/utils/ETError.kt +0 -34
  877. package/android/src/main/java/com/swmansion/rnexecutorch/utils/ImageProcessor.kt +0 -237
  878. package/android/src/main/java/com/swmansion/rnexecutorch/utils/Numerical.kt +0 -8
  879. package/android/src/main/java/com/swmansion/rnexecutorch/utils/ObjectDetectionUtils.kt +0 -201
  880. package/android/src/main/java/com/swmansion/rnexecutorch/utils/STFT.kt +0 -50
  881. package/android/src/main/java/com/swmansion/rnexecutorch/utils/TensorUtils.kt +0 -103
  882. package/ios/RnExecutorch/Classification.h +0 -5
  883. package/ios/RnExecutorch/Classification.mm +0 -54
  884. package/ios/RnExecutorch/ETModule.h +0 -5
  885. package/ios/RnExecutorch/ETModule.mm +0 -75
  886. package/ios/RnExecutorch/ImageSegmentation.h +0 -5
  887. package/ios/RnExecutorch/ImageSegmentation.mm +0 -60
  888. package/ios/RnExecutorch/OCR.h +0 -5
  889. package/ios/RnExecutorch/OCR.mm +0 -96
  890. package/ios/RnExecutorch/ObjectDetection.h +0 -5
  891. package/ios/RnExecutorch/ObjectDetection.mm +0 -56
  892. package/ios/RnExecutorch/SpeechToText.h +0 -5
  893. package/ios/RnExecutorch/SpeechToText.mm +0 -125
  894. package/ios/RnExecutorch/StyleTransfer.h +0 -5
  895. package/ios/RnExecutorch/StyleTransfer.mm +0 -55
  896. package/ios/RnExecutorch/TextEmbeddings.h +0 -5
  897. package/ios/RnExecutorch/TextEmbeddings.mm +0 -62
  898. package/ios/RnExecutorch/Tokenizer.h +0 -5
  899. package/ios/RnExecutorch/Tokenizer.mm +0 -83
  900. package/ios/RnExecutorch/VerticalOCR.h +0 -5
  901. package/ios/RnExecutorch/VerticalOCR.mm +0 -183
  902. package/ios/RnExecutorch/models/BaseModel.h +0 -21
  903. package/ios/RnExecutorch/models/BaseModel.mm +0 -43
  904. package/ios/RnExecutorch/models/classification/ClassificationModel.h +0 -10
  905. package/ios/RnExecutorch/models/classification/ClassificationModel.mm +0 -53
  906. package/ios/RnExecutorch/models/classification/Constants.h +0 -3
  907. package/ios/RnExecutorch/models/image_segmentation/Constants.h +0 -4
  908. package/ios/RnExecutorch/models/image_segmentation/ImageSegmentationModel.h +0 -10
  909. package/ios/RnExecutorch/models/image_segmentation/ImageSegmentationModel.mm +0 -146
  910. package/ios/RnExecutorch/models/object_detection/SSDLiteLargeModel.hpp +0 -11
  911. package/ios/RnExecutorch/models/object_detection/SSDLiteLargeModel.mm +0 -64
  912. package/ios/RnExecutorch/models/ocr/Detector.h +0 -9
  913. package/ios/RnExecutorch/models/ocr/Detector.mm +0 -101
  914. package/ios/RnExecutorch/models/ocr/RecognitionHandler.h +0 -16
  915. package/ios/RnExecutorch/models/ocr/RecognitionHandler.mm +0 -135
  916. package/ios/RnExecutorch/models/ocr/Recognizer.h +0 -8
  917. package/ios/RnExecutorch/models/ocr/Recognizer.mm +0 -77
  918. package/ios/RnExecutorch/models/ocr/VerticalDetector.h +0 -10
  919. package/ios/RnExecutorch/models/ocr/VerticalDetector.mm +0 -118
  920. package/ios/RnExecutorch/models/ocr/utils/CTCLabelConverter.h +0 -16
  921. package/ios/RnExecutorch/models/ocr/utils/CTCLabelConverter.mm +0 -80
  922. package/ios/RnExecutorch/models/ocr/utils/Constants.h +0 -26
  923. package/ios/RnExecutorch/models/ocr/utils/DetectorUtils.h +0 -31
  924. package/ios/RnExecutorch/models/ocr/utils/DetectorUtils.mm +0 -754
  925. package/ios/RnExecutorch/models/ocr/utils/OCRUtils.h +0 -10
  926. package/ios/RnExecutorch/models/ocr/utils/OCRUtils.mm +0 -67
  927. package/ios/RnExecutorch/models/ocr/utils/RecognizerUtils.h +0 -35
  928. package/ios/RnExecutorch/models/ocr/utils/RecognizerUtils.mm +0 -331
  929. package/ios/RnExecutorch/models/stt/Moonshine.hpp +0 -13
  930. package/ios/RnExecutorch/models/stt/Moonshine.mm +0 -64
  931. package/ios/RnExecutorch/models/stt/MoonshineDecoder.hpp +0 -16
  932. package/ios/RnExecutorch/models/stt/MoonshineDecoder.mm +0 -24
  933. package/ios/RnExecutorch/models/stt/MoonshineEncoder.hpp +0 -15
  934. package/ios/RnExecutorch/models/stt/MoonshineEncoder.mm +0 -18
  935. package/ios/RnExecutorch/models/stt/SpeechToTextBaseModel.hpp +0 -26
  936. package/ios/RnExecutorch/models/stt/SpeechToTextBaseModel.mm +0 -19
  937. package/ios/RnExecutorch/models/stt/Whisper.hpp +0 -12
  938. package/ios/RnExecutorch/models/stt/Whisper.mm +0 -68
  939. package/ios/RnExecutorch/models/stt/WhisperDecoder.hpp +0 -16
  940. package/ios/RnExecutorch/models/stt/WhisperDecoder.mm +0 -22
  941. package/ios/RnExecutorch/models/stt/WhisperEncoder.hpp +0 -15
  942. package/ios/RnExecutorch/models/stt/WhisperEncoder.mm +0 -21
  943. package/ios/RnExecutorch/models/style_transfer/StyleTransferModel.h +0 -11
  944. package/ios/RnExecutorch/models/style_transfer/StyleTransferModel.mm +0 -50
  945. package/ios/RnExecutorch/models/text_embeddings/TextEmbeddingsModel.h +0 -15
  946. package/ios/RnExecutorch/models/text_embeddings/TextEmbeddingsModel.mm +0 -45
  947. package/ios/RnExecutorch/models/text_embeddings/TextEmbeddingsUtils.h +0 -8
  948. package/ios/RnExecutorch/models/text_embeddings/TextEmbeddingsUtils.mm +0 -49
  949. package/ios/RnExecutorch/utils/Constants.h +0 -8
  950. package/ios/RnExecutorch/utils/ObjectDetectionUtils.hpp +0 -23
  951. package/ios/RnExecutorch/utils/SFFT.hpp +0 -13
  952. package/ios/RnExecutorch/utils/SFFT.mm +0 -71
  953. package/lib/module/constants/sttDefaults.js +0 -72
  954. package/lib/module/constants/sttDefaults.js.map +0 -1
  955. package/lib/module/controllers/SpeechToTextController.js +0 -307
  956. package/lib/module/controllers/SpeechToTextController.js.map +0 -1
  957. package/lib/module/native/NativeClassification.js +0 -5
  958. package/lib/module/native/NativeClassification.js.map +0 -1
  959. package/lib/module/native/NativeETModule.js +0 -5
  960. package/lib/module/native/NativeETModule.js.map +0 -1
  961. package/lib/module/native/NativeImageSegmentation.js +0 -5
  962. package/lib/module/native/NativeImageSegmentation.js.map +0 -1
  963. package/lib/module/native/NativeOCR.js +0 -5
  964. package/lib/module/native/NativeOCR.js.map +0 -1
  965. package/lib/module/native/NativeObjectDetection.js +0 -5
  966. package/lib/module/native/NativeObjectDetection.js.map +0 -1
  967. package/lib/module/native/NativeSpeechToText.js +0 -5
  968. package/lib/module/native/NativeSpeechToText.js.map +0 -1
  969. package/lib/module/native/NativeStyleTransfer.js +0 -5
  970. package/lib/module/native/NativeStyleTransfer.js.map +0 -1
  971. package/lib/module/native/NativeTextEmbeddings.js +0 -5
  972. package/lib/module/native/NativeTextEmbeddings.js.map +0 -1
  973. package/lib/module/native/NativeTokenizer.js +0 -5
  974. package/lib/module/native/NativeTokenizer.js.map +0 -1
  975. package/lib/module/native/NativeVerticalOCR.js +0 -5
  976. package/lib/module/native/NativeVerticalOCR.js.map +0 -1
  977. package/lib/module/package.json +0 -1
  978. package/lib/typescript/constants/sttDefaults.d.ts +0 -28
  979. package/lib/typescript/constants/sttDefaults.d.ts.map +0 -1
  980. package/lib/typescript/controllers/SpeechToTextController.d.ts +0 -52
  981. package/lib/typescript/controllers/SpeechToTextController.d.ts.map +0 -1
  982. package/lib/typescript/native/NativeClassification.d.ts +0 -10
  983. package/lib/typescript/native/NativeClassification.d.ts.map +0 -1
  984. package/lib/typescript/native/NativeETModule.d.ts +0 -9
  985. package/lib/typescript/native/NativeETModule.d.ts.map +0 -1
  986. package/lib/typescript/native/NativeImageSegmentation.d.ts +0 -10
  987. package/lib/typescript/native/NativeImageSegmentation.d.ts.map +0 -1
  988. package/lib/typescript/native/NativeOCR.d.ts +0 -9
  989. package/lib/typescript/native/NativeOCR.d.ts.map +0 -1
  990. package/lib/typescript/native/NativeObjectDetection.d.ts +0 -9
  991. package/lib/typescript/native/NativeObjectDetection.d.ts.map +0 -1
  992. package/lib/typescript/native/NativeSpeechToText.d.ts +0 -12
  993. package/lib/typescript/native/NativeSpeechToText.d.ts.map +0 -1
  994. package/lib/typescript/native/NativeStyleTransfer.d.ts.map +0 -1
  995. package/lib/typescript/native/NativeTextEmbeddings.d.ts +0 -8
  996. package/lib/typescript/native/NativeTextEmbeddings.d.ts.map +0 -1
  997. package/lib/typescript/native/NativeTokenizer.d.ts +0 -12
  998. package/lib/typescript/native/NativeTokenizer.d.ts.map +0 -1
  999. package/lib/typescript/native/NativeVerticalOCR.d.ts +0 -9
  1000. package/lib/typescript/native/NativeVerticalOCR.d.ts.map +0 -1
  1001. package/src/constants/sttDefaults.ts +0 -86
  1002. package/src/controllers/SpeechToTextController.ts +0 -458
  1003. package/src/index.tsx +0 -47
  1004. package/src/native/NativeClassification.ts +0 -9
  1005. package/src/native/NativeETModule.ts +0 -14
  1006. package/src/native/NativeImageSegmentation.ts +0 -14
  1007. package/src/native/NativeOCR.ts +0 -16
  1008. package/src/native/NativeObjectDetection.ts +0 -10
  1009. package/src/native/NativeSpeechToText.ts +0 -17
  1010. package/src/native/NativeStyleTransfer.ts +0 -10
  1011. package/src/native/NativeTextEmbeddings.ts +0 -9
  1012. package/src/native/NativeTokenizer.ts +0 -13
  1013. package/src/native/NativeVerticalOCR.ts +0 -16
@@ -0,0 +1,3452 @@
1
+ // This file is part of OpenCV project.
2
+ // It is subject to the license terms in the LICENSE file found in the top-level
3
+ // directory of this distribution and at http://opencv.org/license.html
4
+
5
+ // Copyright (C) 2015, PingTouGe Semiconductor Co., Ltd., all rights reserved.
6
+
7
+ #ifndef OPENCV_HAL_INTRIN_RISCVV_HPP
8
+ #define OPENCV_HAL_INTRIN_RISCVV_HPP
9
+
10
+ #include "opencv2/core/utility.hpp"
11
+ #include <algorithm>
12
+ #include <float.h>
13
+
14
+ namespace cv {
15
+
16
+ //! @cond IGNORED
17
+
18
+ CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
19
+
20
+ #define CV_SIMD128 1
21
+ #define CV_SIMD128_64F 1
22
+ //////////// Types ////////////
23
+ struct v_uint8x16 {
24
+ typedef uchar lane_type;
25
+ enum { nlanes = 16 };
26
+
27
+ v_uint8x16() {}
28
+ explicit v_uint8x16(vuint8m1_t v) : val(v) {}
29
+ v_uint8x16(uchar v0, uchar v1, uchar v2, uchar v3, uchar v4, uchar v5,
30
+ uchar v6, uchar v7, uchar v8, uchar v9, uchar v10, uchar v11,
31
+ uchar v12, uchar v13, uchar v14, uchar v15) {
32
+ uchar v[] = {v0, v1, v2, v3, v4, v5, v6, v7,
33
+ v8, v9, v10, v11, v12, v13, v14, v15};
34
+ val = (vuint8m1_t)vle8_v_u8m1((unsigned char *)v, 16);
35
+ }
36
+ uchar get0() const { return vmv_x_s_u8m1_u8(val); }
37
+
38
+ vuint8m1_t val;
39
+ };
40
+
41
+ struct v_int8x16 {
42
+ typedef schar lane_type;
43
+ enum { nlanes = 16 };
44
+
45
+ v_int8x16() {}
46
+ explicit v_int8x16(vint8m1_t v) : val(v) {}
47
+ v_int8x16(schar v0, schar v1, schar v2, schar v3, schar v4, schar v5,
48
+ schar v6, schar v7, schar v8, schar v9, schar v10, schar v11,
49
+ schar v12, schar v13, schar v14, schar v15) {
50
+ schar v[] = {v0, v1, v2, v3, v4, v5, v6, v7,
51
+ v8, v9, v10, v11, v12, v13, v14, v15};
52
+ val = (vint8m1_t)vle8_v_i8m1((schar *)v, 16);
53
+ }
54
+ schar get0() const { return vmv_x_s_i8m1_i8(val); }
55
+
56
+ vint8m1_t val;
57
+ };
58
+
59
+ struct v_uint16x8 {
60
+ typedef ushort lane_type;
61
+ enum { nlanes = 8 };
62
+
63
+ v_uint16x8() {}
64
+ explicit v_uint16x8(vuint16m1_t v) : val(v) {}
65
+ v_uint16x8(ushort v0, ushort v1, ushort v2, ushort v3, ushort v4, ushort v5,
66
+ ushort v6, ushort v7) {
67
+ ushort v[] = {v0, v1, v2, v3, v4, v5, v6, v7};
68
+ val = (vuint16m1_t)vle16_v_u16m1((unsigned short *)v, 8);
69
+ }
70
+ ushort get0() const { return vmv_x_s_u16m1_u16(val); }
71
+
72
+ vuint16m1_t val;
73
+ };
74
+
75
+ struct v_int16x8 {
76
+ typedef short lane_type;
77
+ enum { nlanes = 8 };
78
+
79
+ v_int16x8() {}
80
+ explicit v_int16x8(vint16m1_t v) : val(v) {}
81
+ v_int16x8(short v0, short v1, short v2, short v3, short v4, short v5,
82
+ short v6, short v7) {
83
+ short v[] = {v0, v1, v2, v3, v4, v5, v6, v7};
84
+ val = (vint16m1_t)vle16_v_i16m1((signed short *)v, 8);
85
+ }
86
+ short get0() const { return vmv_x_s_i16m1_i16(val); }
87
+
88
+ vint16m1_t val;
89
+ };
90
+
91
+ struct v_uint32x4 {
92
+ typedef unsigned lane_type;
93
+ enum { nlanes = 4 };
94
+
95
+ v_uint32x4() {}
96
+ explicit v_uint32x4(vuint32m1_t v) : val(v) {}
97
+ v_uint32x4(unsigned v0, unsigned v1, unsigned v2, unsigned v3) {
98
+ unsigned v[] = {v0, v1, v2, v3};
99
+ val = (vuint32m1_t)vle32_v_u32m1((unsigned int *)v, 4);
100
+ }
101
+ unsigned get0() const { return vmv_x_s_u32m1_u32(val); }
102
+
103
+ vuint32m1_t val;
104
+ };
105
+
106
+ struct v_int32x4 {
107
+ typedef int lane_type;
108
+ enum { nlanes = 4 };
109
+
110
+ v_int32x4() {}
111
+ explicit v_int32x4(vint32m1_t v) : val(v) {}
112
+ v_int32x4(int v0, int v1, int v2, int v3) {
113
+ int v[] = {v0, v1, v2, v3};
114
+ val = (vint32m1_t)vle32_v_i32m1((signed int *)v, 4);
115
+ }
116
+ int get0() const { return vmv_x_s_i32m1_i32(val); }
117
+ vint32m1_t val;
118
+ };
119
+
120
+ struct v_float32x4 {
121
+ typedef float lane_type;
122
+ enum { nlanes = 4 };
123
+
124
+ v_float32x4() {}
125
+ explicit v_float32x4(vfloat32m1_t v) : val(v) {}
126
+ v_float32x4(float v0, float v1, float v2, float v3) {
127
+ float v[] = {v0, v1, v2, v3};
128
+ val = (vfloat32m1_t)vle32_v_f32m1((float *)v, 4);
129
+ }
130
+ float get0() const { return vfmv_f_s_f32m1_f32(val); }
131
+ vfloat32m1_t val;
132
+ };
133
+
134
+ struct v_uint64x2 {
135
+ typedef uint64 lane_type;
136
+ enum { nlanes = 2 };
137
+
138
+ v_uint64x2() {}
139
+ explicit v_uint64x2(vuint64m1_t v) : val(v) {}
140
+ v_uint64x2(uint64 v0, uint64 v1) {
141
+ uint64 v[] = {v0, v1};
142
+ val = (vuint64m1_t)vle64_v_u64m1((unsigned long *)v, 2);
143
+ }
144
+ uint64 get0() const { return vmv_x_s_u64m1_u64(val); }
145
+ vuint64m1_t val;
146
+ };
147
+
148
+ struct v_int64x2 {
149
+ typedef int64 lane_type;
150
+ enum { nlanes = 2 };
151
+
152
+ v_int64x2() {}
153
+ explicit v_int64x2(vint64m1_t v) : val(v) {}
154
+ v_int64x2(int64 v0, int64 v1) {
155
+ int64 v[] = {v0, v1};
156
+ val = (vint64m1_t)vle64_v_i64m1((long *)v, 2);
157
+ }
158
+ int64 get0() const { return vmv_x_s_i64m1_i64(val); }
159
+ vint64m1_t val;
160
+ };
161
+
162
+ struct v_float64x2 {
163
+ typedef double lane_type;
164
+ enum { nlanes = 2 };
165
+
166
+ v_float64x2() {}
167
+ explicit v_float64x2(vfloat64m1_t v) : val(v) {}
168
+ v_float64x2(double v0, double v1) {
169
+ double v[] = {v0, v1};
170
+ val = (vfloat64m1_t)vle64_v_f64m1((double *)v, 2);
171
+ }
172
+ double get0() const { return vfmv_f_s_f64m1_f64(val); }
173
+ vfloat64m1_t val;
174
+ };
175
+ /*
176
+ #define OPENCV_HAL_IMPL_RISCVV_INIT(_Tpv, _Tp, suffix) \
177
+ inline _Tp##m1_t vreinterpret_v_##suffix##m1_##suffix##m1(_Tp##m1_t v) { return
178
+ v; } \
179
+ inline v_uint8x16 v_reinterpret_as_u8(const v_##_Tpv& v) { return
180
+ v_uint8x16((vuint8m1_t)(v.val)); } \
181
+ inline v_int8x16 v_reinterpret_as_s8(const v_##_Tpv& v) { return
182
+ v_int8x16((vint8m1_t)(v.val)); } \
183
+ inline v_uint16x8 v_reinterpret_as_u16(const v_##_Tpv& v) { return
184
+ v_uint16x8((vuint16m1_t)(v.val)); } \
185
+ inline v_int16x8 v_reinterpret_as_s16(const v_##_Tpv& v) { return
186
+ v_int16x8(vreinterpret_v_i8m1_i16m1(v.val)); } \
187
+ inline v_uint32x4 v_reinterpret_as_u32(const v_##_Tpv& v) { return
188
+ v_uint32x4((vuint32m1_t)(v.val)); } \
189
+ inline v_int32x4 v_reinterpret_as_s32(const v_##_Tpv& v) { return
190
+ v_int32x4((vint32m1_t)(v.val)); } \
191
+ inline v_uint64x2 v_reinterpret_as_u64(const v_##_Tpv& v) { return
192
+ v_uint64x2((vuint64m1_t)(v.val)); } \
193
+ inline v_int64x2 v_reinterpret_as_s64(const v_##_Tpv& v) { return
194
+ v_int64x2((vint64m1_t)(v.val)); } \
195
+ inline v_float32x4 v_reinterpret_as_f32(const v_##_Tpv& v) { return
196
+ v_float32x4((vfloat32m1_t)(v.val)); }\ inline v_float64x2
197
+ v_reinterpret_as_f64(const v_##_Tpv& v) { return
198
+ v_float64x2((vfloat64m1_t)(v.val)); }
199
+
200
+
201
+ OPENCV_HAL_IMPL_RISCVV_INIT(uint8x16, vuint8, u8)
202
+ OPENCV_HAL_IMPL_RISCVV_INIT(int8x16, vint8, i8)
203
+ OPENCV_HAL_IMPL_RISCVV_INIT(uint16x8, vuint16, u16)
204
+ OPENCV_HAL_IMPL_RISCVV_INIT(int16x8, vint16, i16)
205
+ OPENCV_HAL_IMPL_RISCVV_INIT(uint32x4, vuint32, u32)
206
+ OPENCV_HAL_IMPL_RISCVV_INIT(int32x4, vint32, i32)
207
+ OPENCV_HAL_IMPL_RISCVV_INIT(uint64x2, vuint64, u64)
208
+ OPENCV_HAL_IMPL_RISCVV_INIT(int64x2, vint64, i64)
209
+ OPENCV_HAL_IMPL_RISCVV_INIT(float64x2, vfloat64, f64)
210
+ OPENCV_HAL_IMPL_RISCVV_INIT(float32x4, vfloat32, f32)
211
+ */
212
+ inline v_uint8x16 v_reinterpret_as_u8(const v_uint8x16 &v) {
213
+ return v_uint8x16(v.val);
214
+ }
215
+ inline v_int8x16 v_reinterpret_as_s8(const v_uint8x16 &v) {
216
+ return v_int8x16(vreinterpret_v_u8m1_i8m1(v.val));
217
+ }
218
+ inline v_uint16x8 v_reinterpret_as_u16(const v_uint8x16 &v) {
219
+ return v_uint16x8(vreinterpret_v_u8m1_u16m1(v.val));
220
+ }
221
+ inline v_int16x8 v_reinterpret_as_s16(const v_uint8x16 &v) {
222
+ return v_int16x8(
223
+ vreinterpret_v_u16m1_i16m1(vreinterpret_v_u8m1_u16m1(v.val)));
224
+ }
225
+ inline v_uint32x4 v_reinterpret_as_u32(const v_uint8x16 &v) {
226
+ return v_uint32x4(vreinterpret_v_u8m1_u32m1(v.val));
227
+ }
228
+ inline v_int32x4 v_reinterpret_as_s32(const v_uint8x16 &v) {
229
+ return v_int32x4(
230
+ vreinterpret_v_u32m1_i32m1(vreinterpret_v_u8m1_u32m1(v.val)));
231
+ }
232
+ inline v_uint64x2 v_reinterpret_as_u64(const v_uint8x16 &v) {
233
+ return v_uint64x2(vreinterpret_v_u8m1_u64m1(v.val));
234
+ }
235
+ inline v_int64x2 v_reinterpret_as_s64(const v_uint8x16 &v) {
236
+ return v_int64x2(
237
+ vreinterpret_v_u64m1_i64m1(vreinterpret_v_u8m1_u64m1(v.val)));
238
+ }
239
+ inline v_float32x4 v_reinterpret_as_f32(const v_uint8x16 &v) {
240
+ return v_float32x4(
241
+ vreinterpret_v_u32m1_f32m1(vreinterpret_v_u8m1_u32m1(v.val)));
242
+ }
243
+ inline v_float64x2 v_reinterpret_as_f64(const v_uint8x16 &v) {
244
+ return v_float64x2(
245
+ vreinterpret_v_u64m1_f64m1(vreinterpret_v_u8m1_u64m1(v.val)));
246
+ }
247
+
248
+ inline v_uint8x16 v_reinterpret_as_u8(const v_int8x16 &v) {
249
+ return v_uint8x16(vreinterpret_v_i8m1_u8m1(v.val));
250
+ }
251
+ inline v_int8x16 v_reinterpret_as_s8(const v_int8x16 &v) {
252
+ return v_int8x16(v.val);
253
+ }
254
+ inline v_uint16x8 v_reinterpret_as_u16(const v_int8x16 &v) {
255
+ return v_uint16x8(vreinterpret_v_u8m1_u16m1(vreinterpret_v_i8m1_u8m1(v.val)));
256
+ }
257
+ inline v_int16x8 v_reinterpret_as_s16(const v_int8x16 &v) {
258
+ return v_int16x8(vreinterpret_v_i8m1_i16m1(v.val));
259
+ }
260
+ inline v_uint32x4 v_reinterpret_as_u32(const v_int8x16 &v) {
261
+ return v_uint32x4(vreinterpret_v_u8m1_u32m1(vreinterpret_v_i8m1_u8m1(v.val)));
262
+ }
263
+ inline v_int32x4 v_reinterpret_as_s32(const v_int8x16 &v) {
264
+ return v_int32x4(vreinterpret_v_i8m1_i32m1(v.val));
265
+ }
266
+ inline v_uint64x2 v_reinterpret_as_u64(const v_int8x16 &v) {
267
+ return v_uint64x2(vreinterpret_v_u8m1_u64m1(vreinterpret_v_i8m1_u8m1(v.val)));
268
+ }
269
+ inline v_int64x2 v_reinterpret_as_s64(const v_int8x16 &v) {
270
+ return v_int64x2(vreinterpret_v_i8m1_i64m1(v.val));
271
+ }
272
+ inline v_float32x4 v_reinterpret_as_f32(const v_int8x16 &v) {
273
+ return v_float32x4(
274
+ vreinterpret_v_i32m1_f32m1(vreinterpret_v_i8m1_i32m1(v.val)));
275
+ }
276
+ inline v_float64x2 v_reinterpret_as_f64(const v_int8x16 &v) {
277
+ return v_float64x2(
278
+ vreinterpret_v_i64m1_f64m1(vreinterpret_v_i8m1_i64m1(v.val)));
279
+ }
280
+
281
+ inline v_uint8x16 v_reinterpret_as_u8(const v_uint16x8 &v) {
282
+ return v_uint8x16(vreinterpret_v_u16m1_u8m1(v.val));
283
+ }
284
+ inline v_int8x16 v_reinterpret_as_s8(const v_uint16x8 &v) {
285
+ return v_int8x16(
286
+ vreinterpret_v_i16m1_i8m1(vreinterpret_v_u16m1_i16m1(v.val)));
287
+ }
288
+ inline v_uint16x8 v_reinterpret_as_u16(const v_uint16x8 &v) {
289
+ return v_uint16x8(v.val);
290
+ }
291
+ inline v_int16x8 v_reinterpret_as_s16(const v_uint16x8 &v) {
292
+ return v_int16x8(vreinterpret_v_u16m1_i16m1(v.val));
293
+ }
294
+ inline v_uint32x4 v_reinterpret_as_u32(const v_uint16x8 &v) {
295
+ return v_uint32x4(vreinterpret_v_u16m1_u32m1(v.val));
296
+ }
297
+ inline v_int32x4 v_reinterpret_as_s32(const v_uint16x8 &v) {
298
+ return v_int32x4(
299
+ vreinterpret_v_u32m1_i32m1(vreinterpret_v_u16m1_u32m1(v.val)));
300
+ }
301
+ inline v_uint64x2 v_reinterpret_as_u64(const v_uint16x8 &v) {
302
+ return v_uint64x2(vreinterpret_v_u16m1_u64m1(v.val));
303
+ }
304
+ inline v_int64x2 v_reinterpret_as_s64(const v_uint16x8 &v) {
305
+ return v_int64x2(
306
+ vreinterpret_v_u64m1_i64m1(vreinterpret_v_u16m1_u64m1(v.val)));
307
+ }
308
+ inline v_float32x4 v_reinterpret_as_f32(const v_uint16x8 &v) {
309
+ return v_float32x4(
310
+ vreinterpret_v_u32m1_f32m1(vreinterpret_v_u16m1_u32m1(v.val)));
311
+ }
312
+ inline v_float64x2 v_reinterpret_as_f64(const v_uint16x8 &v) {
313
+ return v_float64x2(
314
+ vreinterpret_v_u64m1_f64m1(vreinterpret_v_u16m1_u64m1(v.val)));
315
+ }
316
+
317
+ inline v_uint8x16 v_reinterpret_as_u8(const v_int16x8 &v) {
318
+ return v_uint8x16(vreinterpret_v_i8m1_u8m1(vreinterpret_v_i16m1_i8m1(v.val)));
319
+ }
320
+ inline v_int8x16 v_reinterpret_as_s8(const v_int16x8 &v) {
321
+ return v_int8x16(vreinterpret_v_i16m1_i8m1(v.val));
322
+ }
323
+ inline v_uint16x8 v_reinterpret_as_u16(const v_int16x8 &v) {
324
+ return v_uint16x8(vreinterpret_v_i16m1_u16m1(v.val));
325
+ }
326
+ inline v_int16x8 v_reinterpret_as_s16(const v_int16x8 &v) {
327
+ return v_int16x8(v.val);
328
+ }
329
+ inline v_uint32x4 v_reinterpret_as_u32(const v_int16x8 &v) {
330
+ return v_uint32x4(
331
+ vreinterpret_v_u16m1_u32m1(vreinterpret_v_i16m1_u16m1(v.val)));
332
+ }
333
+ inline v_int32x4 v_reinterpret_as_s32(const v_int16x8 &v) {
334
+ return v_int32x4(vreinterpret_v_i16m1_i32m1(v.val));
335
+ }
336
+ inline v_uint64x2 v_reinterpret_as_u64(const v_int16x8 &v) {
337
+ return v_uint64x2(
338
+ vreinterpret_v_u16m1_u64m1(vreinterpret_v_i16m1_u16m1(v.val)));
339
+ }
340
+ inline v_int64x2 v_reinterpret_as_s64(const v_int16x8 &v) {
341
+ return v_int64x2(vreinterpret_v_i16m1_i64m1(v.val));
342
+ }
343
+ inline v_float32x4 v_reinterpret_as_f32(const v_int16x8 &v) {
344
+ return v_float32x4(
345
+ vreinterpret_v_i32m1_f32m1(vreinterpret_v_i16m1_i32m1(v.val)));
346
+ }
347
+ inline v_float64x2 v_reinterpret_as_f64(const v_int16x8 &v) {
348
+ return v_float64x2(
349
+ vreinterpret_v_i64m1_f64m1(vreinterpret_v_i16m1_i64m1(v.val)));
350
+ }
351
+
352
+ inline v_uint8x16 v_reinterpret_as_u8(const v_uint32x4 &v) {
353
+ return v_uint8x16(vreinterpret_v_u32m1_u8m1(v.val));
354
+ }
355
+ inline v_int8x16 v_reinterpret_as_s8(const v_uint32x4 &v) {
356
+ return v_int8x16(
357
+ vreinterpret_v_i32m1_i8m1(vreinterpret_v_u32m1_i32m1(v.val)));
358
+ }
359
+ inline v_uint16x8 v_reinterpret_as_u16(const v_uint32x4 &v) {
360
+ return v_uint16x8(vreinterpret_v_u32m1_u16m1(v.val));
361
+ }
362
+ inline v_int16x8 v_reinterpret_as_s16(const v_uint32x4 &v) {
363
+ return v_int16x8(
364
+ vreinterpret_v_i32m1_i16m1(vreinterpret_v_u32m1_i32m1(v.val)));
365
+ }
366
+ inline v_uint32x4 v_reinterpret_as_u32(const v_uint32x4 &v) {
367
+ return v_uint32x4(v.val);
368
+ }
369
+ inline v_int32x4 v_reinterpret_as_s32(const v_uint32x4 &v) {
370
+ return v_int32x4(vreinterpret_v_u32m1_i32m1(v.val));
371
+ }
372
+ inline v_uint64x2 v_reinterpret_as_u64(const v_uint32x4 &v) {
373
+ return v_uint64x2(vreinterpret_v_u32m1_u64m1(v.val));
374
+ }
375
+ inline v_int64x2 v_reinterpret_as_s64(const v_uint32x4 &v) {
376
+ return v_int64x2(
377
+ vreinterpret_v_u64m1_i64m1(vreinterpret_v_u32m1_u64m1(v.val)));
378
+ }
379
+ inline v_float32x4 v_reinterpret_as_f32(const v_uint32x4 &v) {
380
+ return v_float32x4(vreinterpret_v_u32m1_f32m1(v.val));
381
+ }
382
+ inline v_float64x2 v_reinterpret_as_f64(const v_uint32x4 &v) {
383
+ return v_float64x2(
384
+ vreinterpret_v_u64m1_f64m1(vreinterpret_v_u32m1_u64m1(v.val)));
385
+ }
386
+
387
+ inline v_uint8x16 v_reinterpret_as_u8(const v_int32x4 &v) {
388
+ return v_uint8x16(vreinterpret_v_i8m1_u8m1(vreinterpret_v_i32m1_i8m1(v.val)));
389
+ }
390
+ inline v_int8x16 v_reinterpret_as_s8(const v_int32x4 &v) {
391
+ return v_int8x16(vreinterpret_v_i32m1_i8m1(v.val));
392
+ }
393
+ inline v_uint16x8 v_reinterpret_as_u16(const v_int32x4 &v) {
394
+ return v_uint16x8(
395
+ vreinterpret_v_u32m1_u16m1(vreinterpret_v_i32m1_u32m1(v.val)));
396
+ }
397
+ inline v_int16x8 v_reinterpret_as_s16(const v_int32x4 &v) {
398
+ return v_int16x8(vreinterpret_v_i32m1_i16m1(v.val));
399
+ }
400
+ inline v_uint32x4 v_reinterpret_as_u32(const v_int32x4 &v) {
401
+ return v_uint32x4(vreinterpret_v_i32m1_u32m1(v.val));
402
+ }
403
+ inline v_int32x4 v_reinterpret_as_s32(const v_int32x4 &v) {
404
+ return v_int32x4(v.val);
405
+ }
406
+ inline v_uint64x2 v_reinterpret_as_u64(const v_int32x4 &v) {
407
+ return v_uint64x2(
408
+ vreinterpret_v_u32m1_u64m1(vreinterpret_v_i32m1_u32m1(v.val)));
409
+ }
410
+ inline v_int64x2 v_reinterpret_as_s64(const v_int32x4 &v) {
411
+ return v_int64x2(vreinterpret_v_i32m1_i64m1(v.val));
412
+ }
413
+ inline v_float32x4 v_reinterpret_as_f32(const v_int32x4 &v) {
414
+ return v_float32x4(vreinterpret_v_i32m1_f32m1(v.val));
415
+ }
416
+ inline v_float64x2 v_reinterpret_as_f64(const v_int32x4 &v) {
417
+ return v_float64x2(
418
+ vreinterpret_v_i64m1_f64m1(vreinterpret_v_i32m1_i64m1(v.val)));
419
+ }
420
+
421
+ inline v_uint8x16 v_reinterpret_as_u8(const v_uint64x2 &v) {
422
+ return v_uint8x16(vreinterpret_v_u64m1_u8m1(v.val));
423
+ }
424
+ inline v_int8x16 v_reinterpret_as_s8(const v_uint64x2 &v) {
425
+ return v_int8x16(
426
+ vreinterpret_v_i64m1_i8m1(vreinterpret_v_u64m1_i64m1(v.val)));
427
+ }
428
+ inline v_uint16x8 v_reinterpret_as_u16(const v_uint64x2 &v) {
429
+ return v_uint16x8(vreinterpret_v_u64m1_u16m1(v.val));
430
+ }
431
+ inline v_int16x8 v_reinterpret_as_s16(const v_uint64x2 &v) {
432
+ return v_int16x8(
433
+ vreinterpret_v_i64m1_i16m1(vreinterpret_v_u64m1_i64m1(v.val)));
434
+ }
435
+ inline v_uint32x4 v_reinterpret_as_u32(const v_uint64x2 &v) {
436
+ return v_uint32x4(vreinterpret_v_u64m1_u32m1(v.val));
437
+ }
438
+ inline v_int32x4 v_reinterpret_as_s32(const v_uint64x2 &v) {
439
+ return v_int32x4(
440
+ vreinterpret_v_i64m1_i32m1(vreinterpret_v_u64m1_i64m1(v.val)));
441
+ }
442
+ inline v_uint64x2 v_reinterpret_as_u64(const v_uint64x2 &v) {
443
+ return v_uint64x2(v.val);
444
+ }
445
+ inline v_int64x2 v_reinterpret_as_s64(const v_uint64x2 &v) {
446
+ return v_int64x2(vreinterpret_v_u64m1_i64m1(v.val));
447
+ }
448
+ inline v_float32x4 v_reinterpret_as_f32(const v_uint64x2 &v) {
449
+ return v_float32x4(
450
+ vreinterpret_v_u32m1_f32m1(vreinterpret_v_u64m1_u32m1(v.val)));
451
+ }
452
+ inline v_float64x2 v_reinterpret_as_f64(const v_uint64x2 &v) {
453
+ return v_float64x2(vreinterpret_v_u64m1_f64m1(v.val));
454
+ }
455
+
456
+ inline v_uint8x16 v_reinterpret_as_u8(const v_int64x2 &v) {
457
+ return v_uint8x16(vreinterpret_v_i8m1_u8m1(vreinterpret_v_i64m1_i8m1(v.val)));
458
+ }
459
+ inline v_int8x16 v_reinterpret_as_s8(const v_int64x2 &v) {
460
+ return v_int8x16(vreinterpret_v_i64m1_i8m1(v.val));
461
+ }
462
+ inline v_uint16x8 v_reinterpret_as_u16(const v_int64x2 &v) {
463
+ return v_uint16x8(
464
+ vreinterpret_v_u64m1_u16m1(vreinterpret_v_i64m1_u64m1(v.val)));
465
+ }
466
+ inline v_int16x8 v_reinterpret_as_s16(const v_int64x2 &v) {
467
+ return v_int16x8(vreinterpret_v_i64m1_i16m1(v.val));
468
+ }
469
+ inline v_uint32x4 v_reinterpret_as_u32(const v_int64x2 &v) {
470
+ return v_uint32x4(
471
+ vreinterpret_v_u64m1_u32m1(vreinterpret_v_i64m1_u64m1(v.val)));
472
+ }
473
+ inline v_int32x4 v_reinterpret_as_s32(const v_int64x2 &v) {
474
+ return v_int32x4(vreinterpret_v_i64m1_i32m1(v.val));
475
+ }
476
+ inline v_uint64x2 v_reinterpret_as_u64(const v_int64x2 &v) {
477
+ return v_uint64x2(vreinterpret_v_i64m1_u64m1(v.val));
478
+ }
479
+ inline v_int64x2 v_reinterpret_as_s64(const v_int64x2 &v) {
480
+ return v_int64x2(v.val);
481
+ }
482
+ inline v_float32x4 v_reinterpret_as_f32(const v_int64x2 &v) {
483
+ return v_float32x4(
484
+ vreinterpret_v_i32m1_f32m1(vreinterpret_v_i64m1_i32m1(v.val)));
485
+ }
486
+ inline v_float64x2 v_reinterpret_as_f64(const v_int64x2 &v) {
487
+ return v_float64x2(vreinterpret_v_i64m1_f64m1(v.val));
488
+ }
489
+
490
+ inline v_uint8x16 v_reinterpret_as_u8(const v_float32x4 &v) {
491
+ return v_uint8x16(
492
+ vreinterpret_v_u32m1_u8m1(vreinterpret_v_f32m1_u32m1(v.val)));
493
+ }
494
+ inline v_int8x16 v_reinterpret_as_s8(const v_float32x4 &v) {
495
+ return v_int8x16(
496
+ vreinterpret_v_i32m1_i8m1(vreinterpret_v_f32m1_i32m1(v.val)));
497
+ }
498
+ inline v_uint16x8 v_reinterpret_as_u16(const v_float32x4 &v) {
499
+ return v_uint16x8(
500
+ vreinterpret_v_u32m1_u16m1(vreinterpret_v_f32m1_u32m1(v.val)));
501
+ }
502
+ inline v_int16x8 v_reinterpret_as_s16(const v_float32x4 &v) {
503
+ return v_int16x8(
504
+ vreinterpret_v_i32m1_i16m1(vreinterpret_v_f32m1_i32m1(v.val)));
505
+ }
506
+ inline v_uint32x4 v_reinterpret_as_u32(const v_float32x4 &v) {
507
+ return v_uint32x4(vreinterpret_v_f32m1_u32m1(v.val));
508
+ }
509
+ inline v_int32x4 v_reinterpret_as_s32(const v_float32x4 &v) {
510
+ return v_int32x4(vreinterpret_v_f32m1_i32m1(v.val));
511
+ }
512
+ inline v_uint64x2 v_reinterpret_as_u64(const v_float32x4 &v) {
513
+ return v_uint64x2(
514
+ vreinterpret_v_u32m1_u64m1(vreinterpret_v_f32m1_u32m1(v.val)));
515
+ }
516
+ inline v_int64x2 v_reinterpret_as_s64(const v_float32x4 &v) {
517
+ return v_int64x2(
518
+ vreinterpret_v_i32m1_i64m1(vreinterpret_v_f32m1_i32m1(v.val)));
519
+ }
520
+ inline v_float32x4 v_reinterpret_as_f32(const v_float32x4 &v) {
521
+ return v_float32x4(v.val);
522
+ }
523
+ inline v_float64x2 v_reinterpret_as_f64(const v_float32x4 &v) {
524
+ return v_float64x2(vreinterpret_v_i64m1_f64m1(
525
+ vreinterpret_v_i32m1_i64m1(vreinterpret_v_f32m1_i32m1(v.val))));
526
+ }
527
+
528
+ inline v_uint8x16 v_reinterpret_as_u8(const v_float64x2 &v) {
529
+ return v_uint8x16(
530
+ vreinterpret_v_u64m1_u8m1(vreinterpret_v_f64m1_u64m1(v.val)));
531
+ }
532
+ inline v_int8x16 v_reinterpret_as_s8(const v_float64x2 &v) {
533
+ return v_int8x16(
534
+ vreinterpret_v_i64m1_i8m1(vreinterpret_v_f64m1_i64m1(v.val)));
535
+ }
536
+ inline v_uint16x8 v_reinterpret_as_u16(const v_float64x2 &v) {
537
+ return v_uint16x8(
538
+ vreinterpret_v_u64m1_u16m1(vreinterpret_v_f64m1_u64m1(v.val)));
539
+ }
540
+ inline v_int16x8 v_reinterpret_as_s16(const v_float64x2 &v) {
541
+ return v_int16x8(
542
+ vreinterpret_v_i64m1_i16m1(vreinterpret_v_f64m1_i64m1(v.val)));
543
+ }
544
+ inline v_uint32x4 v_reinterpret_as_u32(const v_float64x2 &v) {
545
+ return v_uint32x4(
546
+ vreinterpret_v_u64m1_u32m1(vreinterpret_v_f64m1_u64m1(v.val)));
547
+ }
548
+ inline v_int32x4 v_reinterpret_as_s32(const v_float64x2 &v) {
549
+ return v_int32x4(
550
+ vreinterpret_v_i64m1_i32m1(vreinterpret_v_f64m1_i64m1(v.val)));
551
+ }
552
+ inline v_uint64x2 v_reinterpret_as_u64(const v_float64x2 &v) {
553
+ return v_uint64x2(vreinterpret_v_f64m1_u64m1(v.val));
554
+ }
555
+ inline v_int64x2 v_reinterpret_as_s64(const v_float64x2 &v) {
556
+ return v_int64x2(vreinterpret_v_f64m1_i64m1(v.val));
557
+ }
558
+ inline v_float32x4 v_reinterpret_as_f32(const v_float64x2 &v) {
559
+ return v_float32x4(vreinterpret_v_i32m1_f32m1(
560
+ vreinterpret_v_i64m1_i32m1(vreinterpret_v_f64m1_i64m1(v.val))));
561
+ }
562
+ inline v_float64x2 v_reinterpret_as_f64(const v_float64x2 &v) {
563
+ return v_float64x2(v.val);
564
+ }
565
+
566
+ #define OPENCV_HAL_IMPL_RISCVV_INIT_SET(__Tp, _Tp, suffix, len, num) \
567
+ inline v_##_Tp##x##num v_setzero_##suffix() { \
568
+ return v_##_Tp##x##num(vmv_v_x_##len##m1(0, num)); \
569
+ } \
570
+ inline v_##_Tp##x##num v_setall_##suffix(__Tp v) { \
571
+ return v_##_Tp##x##num(vmv_v_x_##len##m1(v, num)); \
572
+ } \
573
+ template <> inline v_##_Tp##x##num v_setzero_() { \
574
+ return v_setzero_##suffix(); \
575
+ } \
576
+ template <> inline v_##_Tp##x##num v_setall_(__Tp v) { \
577
+ return v_setall_##suffix(v); \
578
+ }
579
+
580
+ OPENCV_HAL_IMPL_RISCVV_INIT_SET(uchar, uint8, u8, u8, 16)
581
+ OPENCV_HAL_IMPL_RISCVV_INIT_SET(schar, int8, s8, i8, 16)
582
+ OPENCV_HAL_IMPL_RISCVV_INIT_SET(ushort, uint16, u16, u16, 8)
583
+ OPENCV_HAL_IMPL_RISCVV_INIT_SET(short, int16, s16, i16, 8)
584
+ OPENCV_HAL_IMPL_RISCVV_INIT_SET(unsigned int, uint32, u32, u32, 4)
585
+ OPENCV_HAL_IMPL_RISCVV_INIT_SET(int, int32, s32, i32, 4)
586
+ OPENCV_HAL_IMPL_RISCVV_INIT_SET(unsigned long, uint64, u64, u64, 2)
587
+ OPENCV_HAL_IMPL_RISCVV_INIT_SET(long, int64, s64, i64, 2)
588
+ inline v_float32x4 v_setzero_f32() { return v_float32x4(vfmv_v_f_f32m1(0, 4)); }
589
+ inline v_float32x4 v_setall_f32(float v) {
590
+ return v_float32x4(vfmv_v_f_f32m1(v, 4));
591
+ }
592
+
593
+ inline v_float64x2 v_setzero_f64() { return v_float64x2(vfmv_v_f_f64m1(0, 2)); }
594
+ inline v_float64x2 v_setall_f64(double v) {
595
+ return v_float64x2(vfmv_v_f_f64m1(v, 2));
596
+ }
597
+
598
+ template <> inline v_float32x4 v_setzero_() { return v_setzero_f32(); }
599
+ template <> inline v_float32x4 v_setall_(float v) { return v_setall_f32(v); }
600
+
601
+ template <> inline v_float64x2 v_setzero_() { return v_setzero_f64(); }
602
+ template <> inline v_float64x2 v_setall_(double v) { return v_setall_f64(v); }
603
+
604
+ #define OPENCV_HAL_IMPL_RISCVV_BIN_OP(bin_op, _Tpvec, intrin) \
605
+ inline _Tpvec bin_op(const _Tpvec &a, const _Tpvec &b) { \
606
+ return _Tpvec(intrin(a.val, b.val)); \
607
+ }
608
+
609
+ #define OPENCV_HAL_IMPL_RISCVV_BIN_OPN(bin_op, _Tpvec, intrin, num) \
610
+ inline _Tpvec bin_op(const _Tpvec &a, const _Tpvec &b) { \
611
+ return _Tpvec(intrin(a.val, b.val, num)); \
612
+ }
613
+
614
+ OPENCV_HAL_IMPL_RISCVV_BIN_OPN(v_add, v_uint8x16, vsaddu_vv_u8m1, 16)
615
+ OPENCV_HAL_IMPL_RISCVV_BIN_OPN(v_sub, v_uint8x16, vssubu_vv_u8m1, 16)
616
+ OPENCV_HAL_IMPL_RISCVV_BIN_OPN(v_add, v_int8x16, vsadd_vv_i8m1, 16)
617
+ OPENCV_HAL_IMPL_RISCVV_BIN_OPN(v_sub, v_int8x16, vssub_vv_i8m1, 16)
618
+ OPENCV_HAL_IMPL_RISCVV_BIN_OPN(v_add, v_uint16x8, vsaddu_vv_u16m1, 8)
619
+ OPENCV_HAL_IMPL_RISCVV_BIN_OPN(v_sub, v_uint16x8, vssubu_vv_u16m1, 8)
620
+ OPENCV_HAL_IMPL_RISCVV_BIN_OPN(v_add, v_int16x8, vsadd_vv_i16m1, 8)
621
+ OPENCV_HAL_IMPL_RISCVV_BIN_OPN(v_sub, v_int16x8, vssub_vv_i16m1, 8)
622
+ OPENCV_HAL_IMPL_RISCVV_BIN_OPN(v_add, v_int32x4, vadd_vv_i32m1, 4)
623
+ OPENCV_HAL_IMPL_RISCVV_BIN_OPN(v_sub, v_int32x4, vsub_vv_i32m1, 4)
624
+ OPENCV_HAL_IMPL_RISCVV_BIN_OPN(v_mul, v_int32x4, vmul_vv_i32m1, 4)
625
+ OPENCV_HAL_IMPL_RISCVV_BIN_OPN(v_add, v_uint32x4, vadd_vv_u32m1, 4)
626
+ OPENCV_HAL_IMPL_RISCVV_BIN_OPN(v_sub, v_uint32x4, vsub_vv_u32m1, 4)
627
+ OPENCV_HAL_IMPL_RISCVV_BIN_OPN(v_mul, v_uint32x4, vmul_vv_u32m1, 4)
628
+ OPENCV_HAL_IMPL_RISCVV_BIN_OPN(v_add, v_int64x2, vadd_vv_i64m1, 2)
629
+ OPENCV_HAL_IMPL_RISCVV_BIN_OPN(v_sub, v_int64x2, vsub_vv_i64m1, 2)
630
+ OPENCV_HAL_IMPL_RISCVV_BIN_OPN(v_add, v_uint64x2, vadd_vv_u64m1, 2)
631
+ OPENCV_HAL_IMPL_RISCVV_BIN_OPN(v_sub, v_uint64x2, vsub_vv_u64m1, 2)
632
+ OPENCV_HAL_IMPL_RISCVV_BIN_OPN(v_add, v_float32x4, vfadd_vv_f32m1, 4)
633
+ OPENCV_HAL_IMPL_RISCVV_BIN_OPN(v_sub, v_float32x4, vfsub_vv_f32m1, 4)
634
+ OPENCV_HAL_IMPL_RISCVV_BIN_OPN(v_mul, v_float32x4, vfmul_vv_f32m1, 4)
635
+ inline v_float32x4 v_div(const v_float32x4 &a, const v_float32x4 &b) {
636
+ return v_float32x4(vfdiv_vv_f32m1(a.val, b.val, 4));
637
+ }
638
+
639
+ OPENCV_HAL_IMPL_RISCVV_BIN_OPN(v_add, v_float64x2, vfadd_vv_f64m1, 2)
640
+ OPENCV_HAL_IMPL_RISCVV_BIN_OPN(v_sub, v_float64x2, vfsub_vv_f64m1, 2)
641
+ OPENCV_HAL_IMPL_RISCVV_BIN_OPN(v_mul, v_float64x2, vfmul_vv_f64m1, 2)
642
+ inline v_float64x2 v_div(const v_float64x2 &a, const v_float64x2 &b) {
643
+ return v_float64x2(vfdiv_vv_f64m1(a.val, b.val, 2));
644
+ }
645
+ // TODO: exp, log, sin, cos
646
+
647
+ #define OPENCV_HAL_IMPL_RISCVV_BIN_FUNC(_Tpvec, func, intrin) \
648
+ inline _Tpvec func(const _Tpvec &a, const _Tpvec &b) { \
649
+ return _Tpvec(intrin(a.val, b.val)); \
650
+ }
651
+
652
+ #define OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(_Tpvec, func, intrin, num) \
653
+ inline _Tpvec func(const _Tpvec &a, const _Tpvec &b) { \
654
+ return _Tpvec(intrin(a.val, b.val, num)); \
655
+ }
656
+ OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint8x16, v_min, vminu_vv_u8m1, 16)
657
+ OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint8x16, v_max, vmaxu_vv_u8m1, 16)
658
+ OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int8x16, v_min, vmin_vv_i8m1, 16)
659
+ OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int8x16, v_max, vmax_vv_i8m1, 16)
660
+ OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint16x8, v_min, vminu_vv_u16m1, 8)
661
+ OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint16x8, v_max, vmaxu_vv_u16m1, 8)
662
+ OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int16x8, v_min, vmin_vv_i16m1, 8)
663
+ OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int16x8, v_max, vmax_vv_i16m1, 8)
664
+ OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint32x4, v_min, vminu_vv_u32m1, 4)
665
+ OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint32x4, v_max, vmaxu_vv_u32m1, 4)
666
+ OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int32x4, v_min, vmin_vv_i32m1, 4)
667
+ OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int32x4, v_max, vmax_vv_i32m1, 4)
668
+ OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_float32x4, v_min, vfmin_vv_f32m1, 4)
669
+ OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_float32x4, v_max, vfmax_vv_f32m1, 4)
670
+ OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_float64x2, v_min, vfmin_vv_f64m1, 2)
671
+ OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_float64x2, v_max, vfmax_vv_f64m1, 2)
672
+
673
+ inline v_float32x4 v_sqrt(const v_float32x4 &x) {
674
+ return v_float32x4(vfsqrt_v_f32m1(x.val, 4));
675
+ }
676
+
677
+ inline v_float32x4 v_invsqrt(const v_float32x4 &x) {
678
+ return v_float32x4(vfrdiv_vf_f32m1(vfsqrt_v_f32m1(x.val, 4), 1, 4));
679
+ }
680
+
681
+ inline v_float32x4 v_magnitude(const v_float32x4 &a, const v_float32x4 &b) {
682
+ v_float32x4 x(
683
+ vfmacc_vv_f32m1(vfmul_vv_f32m1(a.val, a.val, 4), b.val, b.val, 4));
684
+ return v_sqrt(x);
685
+ }
686
+
687
+ inline v_float32x4 v_sqr_magnitude(const v_float32x4 &a, const v_float32x4 &b) {
688
+ return v_float32x4(
689
+ vfmacc_vv_f32m1(vfmul_vv_f32m1(a.val, a.val, 4), b.val, b.val, 4));
690
+ }
691
+
692
+ inline v_float32x4 v_fma(const v_float32x4 &a, const v_float32x4 &b,
693
+ const v_float32x4 &c) {
694
+ return v_float32x4(vfmadd_vv_f32m1(a.val, b.val, c.val, 4));
695
+ }
696
+
697
+ inline v_int32x4 v_fma(const v_int32x4 &a, const v_int32x4 &b,
698
+ const v_int32x4 &c) {
699
+ return v_int32x4(vmadd_vv_i32m1(a.val, b.val, c.val, 4));
700
+ }
701
+
702
+ inline v_float32x4 v_muladd(const v_float32x4 &a, const v_float32x4 &b,
703
+ const v_float32x4 &c) {
704
+ return v_fma(a, b, c);
705
+ }
706
+
707
+ inline v_int32x4 v_muladd(const v_int32x4 &a, const v_int32x4 &b,
708
+ const v_int32x4 &c) {
709
+ return v_fma(a, b, c);
710
+ }
711
+
712
+ inline v_float32x4 v_matmul(const v_float32x4 &v, const v_float32x4 &m0,
713
+ const v_float32x4 &m1, const v_float32x4 &m2,
714
+ const v_float32x4 &m3) {
715
+ vfloat32m1_t res = vfmul_vv_f32m1(m0.val, vrgather_vx_f32m1(v.val, 0, 4),
716
+ 4); // vmuli_f32(m0.val, v.val, 0);
717
+ res = vfmacc_vv_f32m1(res, vrgather_vx_f32m1(v.val, 1, 4), m1.val,
718
+ 4); // vmulai_f32(res, m1.val, v.val, 1);
719
+ res = vfmacc_vv_f32m1(res, vrgather_vx_f32m1(v.val, 2, 4), m2.val,
720
+ 4); // vmulai_f32(res, m1.val, v.val, 1);
721
+ res = vfmacc_vv_f32m1(res, vrgather_vx_f32m1(v.val, 3, 4), m3.val,
722
+ 4); // vmulai_f32(res, m1.val, v.val, 1);
723
+ return v_float32x4(res);
724
+ }
725
+
726
+ inline v_float32x4 v_matmuladd(const v_float32x4 &v, const v_float32x4 &m0,
727
+ const v_float32x4 &m1, const v_float32x4 &m2,
728
+ const v_float32x4 &a) {
729
+ vfloat32m1_t res = vfmul_vv_f32m1(m0.val, vrgather_vx_f32m1(v.val, 0, 4),
730
+ 4); // vmuli_f32(m0.val, v.val, 0);
731
+ res = vfmacc_vv_f32m1(res, vrgather_vx_f32m1(v.val, 1, 4), m1.val,
732
+ 4); // vmulai_f32(res, m1.val, v.val, 1);
733
+ res = vfmacc_vv_f32m1(res, vrgather_vx_f32m1(v.val, 2, 4), m2.val,
734
+ 4); // vmulai_f32(res, m1.val, v.val, 1);
735
+ res = vfadd_vv_f32m1(res, a.val, 4); // vmulai_f32(res, m1.val, v.val, 1);
736
+ return v_float32x4(res);
737
+ }
738
+
739
+ inline v_float64x2 v_sqrt(const v_float64x2 &x) {
740
+ return v_float64x2(vfsqrt_v_f64m1(x.val, 2));
741
+ }
742
+
743
+ inline v_float64x2 v_invsqrt(const v_float64x2 &x) {
744
+ return v_float64x2(vfrdiv_vf_f64m1(vfsqrt_v_f64m1(x.val, 2), 1, 2));
745
+ }
746
+
747
+ inline v_float64x2 v_magnitude(const v_float64x2 &a, const v_float64x2 &b) {
748
+ v_float64x2 x(
749
+ vfmacc_vv_f64m1(vfmul_vv_f64m1(a.val, a.val, 2), b.val, b.val, 2));
750
+ return v_sqrt(x);
751
+ }
752
+
753
+ inline v_float64x2 v_sqr_magnitude(const v_float64x2 &a, const v_float64x2 &b) {
754
+ return v_float64x2(
755
+ vfmacc_vv_f64m1(vfmul_vv_f64m1(a.val, a.val, 2), b.val, b.val, 2));
756
+ }
757
+
758
+ inline v_float64x2 v_fma(const v_float64x2 &a, const v_float64x2 &b,
759
+ const v_float64x2 &c) {
760
+ return v_float64x2(vfmadd_vv_f64m1(a.val, b.val, c.val, 2));
761
+ }
762
+
763
+ inline v_float64x2 v_muladd(const v_float64x2 &a, const v_float64x2 &b,
764
+ const v_float64x2 &c) {
765
+ return v_fma(a, b, c);
766
+ }
767
+
768
+ #define OPENCV_HAL_IMPL_RISCVV_LOGIC_OPN(_Tpvec, suffix, num) \
769
+ OPENCV_HAL_IMPL_RISCVV_BIN_OPN(v_and, _Tpvec, vand_vv_##suffix, num) \
770
+ OPENCV_HAL_IMPL_RISCVV_BIN_OPN(v_or, _Tpvec, vor_vv_##suffix, num) \
771
+ OPENCV_HAL_IMPL_RISCVV_BIN_OPN(v_xor, _Tpvec, vxor_vv_##suffix, num) \
772
+ inline _Tpvec v_not(const _Tpvec &a) { \
773
+ return _Tpvec(vnot_v_##suffix(a.val, num)); \
774
+ }
775
+
776
+ OPENCV_HAL_IMPL_RISCVV_LOGIC_OPN(v_uint8x16, u8m1, 16)
777
+ OPENCV_HAL_IMPL_RISCVV_LOGIC_OPN(v_uint16x8, u16m1, 8)
778
+ OPENCV_HAL_IMPL_RISCVV_LOGIC_OPN(v_uint32x4, u32m1, 4)
779
+ OPENCV_HAL_IMPL_RISCVV_LOGIC_OPN(v_uint64x2, u64m1, 2)
780
+ OPENCV_HAL_IMPL_RISCVV_LOGIC_OPN(v_int8x16, i8m1, 16)
781
+ OPENCV_HAL_IMPL_RISCVV_LOGIC_OPN(v_int16x8, i16m1, 8)
782
+ OPENCV_HAL_IMPL_RISCVV_LOGIC_OPN(v_int32x4, i32m1, 4)
783
+ OPENCV_HAL_IMPL_RISCVV_LOGIC_OPN(v_int64x2, i64m1, 2)
784
+
785
+ #define OPENCV_HAL_IMPL_RISCVV_FLT_BIT_OP(bin_op, intrin) \
786
+ inline v_float32x4 bin_op(const v_float32x4 &a, const v_float32x4 &b) { \
787
+ return v_float32x4(vreinterpret_v_i32m1_f32m1( \
788
+ intrin(vreinterpret_v_f32m1_i32m1(a.val), \
789
+ vreinterpret_v_f32m1_i32m1(b.val), 4))); \
790
+ }
791
+
792
+ OPENCV_HAL_IMPL_RISCVV_FLT_BIT_OP(v_and, vand_vv_i32m1)
793
+ OPENCV_HAL_IMPL_RISCVV_FLT_BIT_OP(v_or, vor_vv_i32m1)
794
+ OPENCV_HAL_IMPL_RISCVV_FLT_BIT_OP(v_xor, vxor_vv_i32m1)
795
+
796
+ inline v_float32x4 v_not(const v_float32x4 &a) {
797
+ return v_float32x4(vreinterpret_v_i32m1_f32m1(
798
+ vnot_v_i32m1(vreinterpret_v_f32m1_i32m1(a.val), 4)));
799
+ }
800
+
801
+ #define OPENCV_HAL_IMPL_RISCVV_FLT_64BIT_OP(bin_op, intrin) \
802
+ inline v_float64x2 bin_op(const v_float64x2 &a, const v_float64x2 &b) { \
803
+ return v_float64x2(vreinterpret_v_i64m1_f64m1( \
804
+ intrin(vreinterpret_v_f64m1_i64m1(a.val), \
805
+ vreinterpret_v_f64m1_i64m1(b.val), 2))); \
806
+ }
807
+
808
+ OPENCV_HAL_IMPL_RISCVV_FLT_64BIT_OP(v_and, vand_vv_i64m1)
809
+ OPENCV_HAL_IMPL_RISCVV_FLT_64BIT_OP(v_or, vor_vv_i64m1)
810
+ OPENCV_HAL_IMPL_RISCVV_FLT_64BIT_OP(v_xor, vxor_vv_i64m1)
811
+
812
+ inline v_float64x2 v_not(const v_float64x2 &a) {
813
+ return v_float64x2(vreinterpret_v_i64m1_f64m1(
814
+ vnot_v_i64m1(vreinterpret_v_f64m1_i64m1(a.val), 2)));
815
+ }
816
+ inline v_int16x8 v_mul_hi(const v_int16x8 &a, const v_int16x8 &b) {
817
+ return v_int16x8(vmulh_vv_i16m1(a.val, b.val, 8));
818
+ }
819
+ inline v_uint16x8 v_mul_hi(const v_uint16x8 &a, const v_uint16x8 &b) {
820
+ return v_uint16x8(vmulhu_vv_u16m1(a.val, b.val, 8));
821
+ }
822
+
823
+ //#define OPENCV_HAL_IMPL_RISCVV_ABS(_Tpuvec, _Tpsvec, usuffix, ssuffix) \
824
+ //inline _Tpuvec v_abs(const _Tpsvec& a) { \
825
+ // E##xm1_t mask=vmflt_vf_e32xm1_f32m1(x.val, 0.0, 4);
826
+
827
+ // OPENCV_HAL_IMPL_RISCVV_ABS(v_uint8x16, v_int8x16, u8, s8)
828
+ // OPENCV_HAL_IMPL_RISCVV_ABS(v_uint16x8, v_int16x8, u16, s16)
829
+ // OPENCV_HAL_IMPL_RISCVV_ABS(v_uint32x4, v_int32x4, u32, s32)
830
+
831
+ inline v_uint32x4 v_abs(v_int32x4 x) {
832
+ vbool32_t mask = vmslt_vx_i32m1_b32(x.val, 0, 4);
833
+ return v_uint32x4(
834
+ vreinterpret_v_i32m1_u32m1(vrsub_vx_i32m1_m(mask, x.val, x.val, 0, 4)));
835
+ }
836
+
837
+ inline v_uint16x8 v_abs(v_int16x8 x) {
838
+ vbool16_t mask = vmslt_vx_i16m1_b16(x.val, 0, 8);
839
+ return v_uint16x8(
840
+ vreinterpret_v_i16m1_u16m1(vrsub_vx_i16m1_m(mask, x.val, x.val, 0, 8)));
841
+ }
842
+
843
+ inline v_uint8x16 v_abs(v_int8x16 x) {
844
+ vbool8_t mask = vmslt_vx_i8m1_b8(x.val, 0, 16);
845
+ return v_uint8x16(
846
+ vreinterpret_v_i8m1_u8m1(vrsub_vx_i8m1_m(mask, x.val, x.val, 0, 16)));
847
+ }
848
+
849
+ inline v_float32x4 v_abs(v_float32x4 x) {
850
+ return (v_float32x4)vfsgnjx_vv_f32m1(x.val, x.val, 4);
851
+ }
852
+
853
+ inline v_float64x2 v_abs(v_float64x2 x) {
854
+ return (v_float64x2)vfsgnjx_vv_f64m1(x.val, x.val, 2);
855
+ }
856
+
857
+ inline v_float32x4 v_absdiff(const v_float32x4 &a, const v_float32x4 &b) {
858
+ vfloat32m1_t ret = vfsub_vv_f32m1(a.val, b.val, 4);
859
+ return (v_float32x4)vfsgnjx_vv_f32m1(ret, ret, 4);
860
+ }
861
+
862
+ inline v_float64x2 v_absdiff(const v_float64x2 &a, const v_float64x2 &b) {
863
+ vfloat64m1_t ret = vfsub_vv_f64m1(a.val, b.val, 2);
864
+ return (v_float64x2)vfsgnjx_vv_f64m1(ret, ret, 2);
865
+ }
866
+
867
+ #define OPENCV_HAL_IMPL_RISCVV_ABSDIFF_U(bit, num) \
868
+ inline v_uint##bit##x##num v_absdiff(v_uint##bit##x##num a, \
869
+ v_uint##bit##x##num b) { \
870
+ vuint##bit##m1_t vmax = vmaxu_vv_u##bit##m1(a.val, b.val, num); \
871
+ vuint##bit##m1_t vmin = vminu_vv_u##bit##m1(a.val, b.val, num); \
872
+ return v_uint##bit##x##num(vsub_vv_u##bit##m1(vmax, vmin, num)); \
873
+ }
874
+
875
+ OPENCV_HAL_IMPL_RISCVV_ABSDIFF_U(8, 16)
876
+ OPENCV_HAL_IMPL_RISCVV_ABSDIFF_U(16, 8)
877
+ OPENCV_HAL_IMPL_RISCVV_ABSDIFF_U(32, 4)
878
+
879
+ /** Saturating absolute difference **/
880
+ inline v_int8x16 v_absdiffs(v_int8x16 a, v_int8x16 b) {
881
+ vint8m1_t vmax = vmax_vv_i8m1(a.val, b.val, 16);
882
+ vint8m1_t vmin = vmin_vv_i8m1(a.val, b.val, 16);
883
+ return v_int8x16(vssub_vv_i8m1(vmax, vmin, 16));
884
+ }
885
+ inline v_int16x8 v_absdiffs(v_int16x8 a, v_int16x8 b) {
886
+ vint16m1_t vmax = vmax_vv_i16m1(a.val, b.val, 8);
887
+ vint16m1_t vmin = vmin_vv_i16m1(a.val, b.val, 8);
888
+ return v_int16x8(vssub_vv_i16m1(vmax, vmin, 8));
889
+ }
890
+
891
+ #define OPENCV_HAL_IMPL_RISCVV_ABSDIFF(_Tpvec, _Tpv, num) \
892
+ inline v_uint##_Tpvec v_absdiff(v_int##_Tpvec a, v_int##_Tpvec b) { \
893
+ vint##_Tpv##_t max = vmax_vv_i##_Tpv(a.val, b.val, num); \
894
+ vint##_Tpv##_t min = vmin_vv_i##_Tpv(a.val, b.val, num); \
895
+ return v_uint##_Tpvec( \
896
+ vreinterpret_v_i##_Tpv##_u##_Tpv(vsub_vv_i##_Tpv(max, min, num))); \
897
+ }
898
+
899
+ OPENCV_HAL_IMPL_RISCVV_ABSDIFF(8x16, 8m1, 16)
900
+ OPENCV_HAL_IMPL_RISCVV_ABSDIFF(16x8, 16m1, 8)
901
+ OPENCV_HAL_IMPL_RISCVV_ABSDIFF(32x4, 32m1, 4)
902
+
903
+ // Multiply and expand
904
+ inline void v_mul_expand(const v_int8x16 &a, const v_int8x16 &b, v_int16x8 &c,
905
+ v_int16x8 &d) {
906
+ vint16m2_t res = vundefined_i16m2();
907
+ res = vwmul_vv_i16m2(a.val, b.val, 16);
908
+ c.val = vget_v_i16m2_i16m1(res, 0);
909
+ d.val = vget_v_i16m2_i16m1(res, 1);
910
+ }
911
+
912
+ inline void v_mul_expand(const v_uint8x16 &a, const v_uint8x16 &b,
913
+ v_uint16x8 &c, v_uint16x8 &d) {
914
+ vuint16m2_t res = vundefined_u16m2();
915
+ res = vwmulu_vv_u16m2(a.val, b.val, 16);
916
+ c.val = vget_v_u16m2_u16m1(res, 0);
917
+ d.val = vget_v_u16m2_u16m1(res, 1);
918
+ }
919
+
920
+ inline void v_mul_expand(const v_int16x8 &a, const v_int16x8 &b, v_int32x4 &c,
921
+ v_int32x4 &d) {
922
+ vint32m2_t res = vundefined_i32m2();
923
+ res = vwmul_vv_i32m2(a.val, b.val, 8);
924
+ c.val = vget_v_i32m2_i32m1(res, 0);
925
+ d.val = vget_v_i32m2_i32m1(res, 1);
926
+ }
927
+
928
+ inline void v_mul_expand(const v_uint16x8 &a, const v_uint16x8 &b,
929
+ v_uint32x4 &c, v_uint32x4 &d) {
930
+ vuint32m2_t res = vundefined_u32m2();
931
+ res = vwmulu_vv_u32m2(a.val, b.val, 8);
932
+ c.val = vget_v_u32m2_u32m1(res, 0);
933
+ d.val = vget_v_u32m2_u32m1(res, 1);
934
+ }
935
+
936
+ inline void v_mul_expand(const v_int32x4 &a, const v_int32x4 &b, v_int64x2 &c,
937
+ v_int64x2 &d) {
938
+ vint64m2_t res = vundefined_i64m2();
939
+ res = vwmul_vv_i64m2(a.val, b.val, 4);
940
+ c.val = vget_v_i64m2_i64m1(res, 0);
941
+ d.val = vget_v_i64m2_i64m1(res, 1);
942
+ }
943
+
944
+ inline void v_mul_expand(const v_uint32x4 &a, const v_uint32x4 &b,
945
+ v_uint64x2 &c, v_uint64x2 &d) {
946
+ vuint64m2_t res = vundefined_u64m2();
947
+ res = vwmulu_vv_u64m2(a.val, b.val, 4);
948
+ c.val = vget_v_u64m2_u64m1(res, 0);
949
+ d.val = vget_v_u64m2_u64m1(res, 1);
950
+ }
951
+
952
+ OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint8x16, v_add_wrap, vadd_vv_u8m1, 16)
953
+ OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int8x16, v_add_wrap, vadd_vv_i8m1, 16)
954
+ OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint16x8, v_add_wrap, vadd_vv_u16m1, 8)
955
+ OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int16x8, v_add_wrap, vadd_vv_i16m1, 8)
956
+ OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint8x16, v_sub_wrap, vsub_vv_u8m1, 16)
957
+ OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int8x16, v_sub_wrap, vsub_vv_i8m1, 16)
958
+ OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint16x8, v_sub_wrap, vsub_vv_u16m1, 8)
959
+ OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int16x8, v_sub_wrap, vsub_vv_i16m1, 8)
960
+ OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint8x16, v_mul_wrap, vmul_vv_u8m1, 16)
961
+ OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int8x16, v_mul_wrap, vmul_vv_i8m1, 16)
962
+ OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint16x8, v_mul_wrap, vmul_vv_u16m1, 8)
963
+ OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int16x8, v_mul_wrap, vmul_vv_i16m1, 8)
964
+ //////// Dot Product ////////
965
+ // 16 >> 32
966
+ inline v_int32x4 v_dotprod(const v_int16x8 &a, const v_int16x8 &b) {
967
+ vuint32m2_t vindex = vundefined_u32m2();
968
+ vuint32m1_t vindex0 = vid_v_u32m1(4);
969
+ vindex0 = vsll_vx_u32m1(vindex0, 1, 4);
970
+ vindex = vset_v_u32m1_u32m2(vindex, 0, vindex0);
971
+ vindex = vset_v_u32m1_u32m2(vindex, 1, vadd_vx_u32m1(vindex0, 1, 4));
972
+ vint32m2_t res = vundefined_i32m2();
973
+ res = vwmul_vv_i32m2(a.val, b.val, 8);
974
+ res = vrgather_vv_i32m2(res, vindex, 8);
975
+ return v_int32x4(
976
+ vadd_vv_i32m1(vget_v_i32m2_i32m1(res, 0), vget_v_i32m2_i32m1(res, 1), 4));
977
+ }
978
+ inline v_int32x4 v_dotprod(const v_int16x8 &a, const v_int16x8 &b,
979
+ const v_int32x4 &c) {
980
+ vuint32m2_t vindex = vundefined_u32m2();
981
+ vuint32m1_t vindex0 = vid_v_u32m1(4);
982
+ vindex0 = vsll_vx_u32m1(vindex0, 1, 4);
983
+ vindex = vset_v_u32m1_u32m2(vindex, 0, vindex0);
984
+ vindex = vset_v_u32m1_u32m2(vindex, 1, vadd_vx_u32m1(vindex0, 1, 4));
985
+ vint32m2_t res = vundefined_i32m2();
986
+ res = vwmul_vv_i32m2(a.val, b.val, 8);
987
+ res = vrgather_vv_i32m2(res, vindex, 8);
988
+ return v_int32x4(vadd_vv_i32m1(
989
+ vadd_vv_i32m1(vget_v_i32m2_i32m1(res, 0), vget_v_i32m2_i32m1(res, 1), 4),
990
+ c.val, 4));
991
+ }
992
+
993
+ // 32 >> 64
994
+ inline v_int64x2 v_dotprod(const v_int32x4 &a, const v_int32x4 &b) {
995
+ vuint64m2_t vindex = vundefined_u64m2();
996
+ vuint64m1_t vindex0 = vid_v_u64m1(2);
997
+ vindex0 = vsll_vx_u64m1(vindex0, 1, 2);
998
+ vindex = vset_v_u64m1_u64m2(vindex, 0, vindex0);
999
+ vindex = vset_v_u64m1_u64m2(vindex, 1, vadd_vx_u64m1(vindex0, 1, 2));
1000
+ vint64m2_t res = vundefined_i64m2();
1001
+ res = vwmul_vv_i64m2(a.val, b.val, 4);
1002
+ res = vrgather_vv_i64m2(res, vindex, 4);
1003
+ return v_int64x2(
1004
+ vadd_vv_i64m1(vget_v_i64m2_i64m1(res, 0), vget_v_i64m2_i64m1(res, 1), 2));
1005
+ }
1006
+ inline v_int64x2 v_dotprod(const v_int32x4 &a, const v_int32x4 &b,
1007
+ const v_int64x2 &c) {
1008
+ vuint64m2_t vindex = vundefined_u64m2();
1009
+ vuint64m1_t vindex0 = vid_v_u64m1(2);
1010
+ vindex0 = vsll_vx_u64m1(vindex0, 1, 2);
1011
+ vindex = vset_v_u64m1_u64m2(vindex, 0, vindex0);
1012
+ vindex = vset_v_u64m1_u64m2(vindex, 1, vadd_vx_u64m1(vindex0, 1, 2));
1013
+ vint64m2_t res = vundefined_i64m2();
1014
+ res = vwmul_vv_i64m2(a.val, b.val, 4);
1015
+ res = vrgather_vv_i64m2(res, vindex, 4);
1016
+ return v_int64x2(vadd_vv_i64m1(
1017
+ vadd_vv_i64m1(vget_v_i64m2_i64m1(res, 0), vget_v_i64m2_i64m1(res, 1), 2),
1018
+ c.val, 2));
1019
+ }
1020
+
1021
+ // 8 >> 32
1022
+ inline v_uint32x4 v_dotprod_expand(const v_uint8x16 &a, const v_uint8x16 &b) {
1023
+ vuint32m4_t vindex32 = vundefined_u32m4();
1024
+ vuint32m1_t vindex0 = vid_v_u32m1(4);
1025
+ vindex0 = vsll_vx_u32m1(vindex0, 2, 4);
1026
+ vindex32 = vset_v_u32m1_u32m4(vindex32, 0, vindex0);
1027
+ vindex32 = vset_v_u32m1_u32m4(vindex32, 1, vadd_vx_u32m1(vindex0, 1, 4));
1028
+ vindex32 = vset_v_u32m1_u32m4(vindex32, 2, vadd_vx_u32m1(vindex0, 2, 4));
1029
+ vindex32 = vset_v_u32m1_u32m4(vindex32, 3, vadd_vx_u32m1(vindex0, 3, 4));
1030
+ vuint16m2_t vindex = vnsrl_wx_u16m2(vindex32, 0, 16);
1031
+ vuint16m2_t v1 = vundefined_u16m2();
1032
+ vuint32m2_t v2 = vundefined_u32m2();
1033
+ v1 = vwmulu_vv_u16m2(a.val, b.val, 16);
1034
+ v1 = vrgather_vv_u16m2(v1, vindex, 16);
1035
+ v2 = vwaddu_vv_u32m2(vget_v_u16m2_u16m1(v1, 0), vget_v_u16m2_u16m1(v1, 1), 8);
1036
+ return v_uint32x4(
1037
+ vadd_vv_u32m1(vget_v_u32m2_u32m1(v2, 0), vget_v_u32m2_u32m1(v2, 1), 4));
1038
+ }
1039
+
1040
+ inline v_uint32x4 v_dotprod_expand(const v_uint8x16 &a, const v_uint8x16 &b,
1041
+ const v_uint32x4 &c) {
1042
+ vuint32m4_t vindex32 = vundefined_u32m4();
1043
+ vuint32m1_t vindex0 = vid_v_u32m1(4);
1044
+ vindex0 = vsll_vx_u32m1(vindex0, 2, 4);
1045
+ vindex32 = vset_v_u32m1_u32m4(vindex32, 0, vindex0);
1046
+ vindex32 = vset_v_u32m1_u32m4(vindex32, 1, vadd_vx_u32m1(vindex0, 1, 4));
1047
+ vindex32 = vset_v_u32m1_u32m4(vindex32, 2, vadd_vx_u32m1(vindex0, 2, 4));
1048
+ vindex32 = vset_v_u32m1_u32m4(vindex32, 3, vadd_vx_u32m1(vindex0, 3, 4));
1049
+ vuint16m2_t vindex = vnsrl_wx_u16m2(vindex32, 0, 16);
1050
+ vuint16m2_t v1 = vundefined_u16m2();
1051
+ vuint32m2_t v2 = vundefined_u32m2();
1052
+ v1 = vwmulu_vv_u16m2(a.val, b.val, 16);
1053
+ v1 = vrgather_vv_u16m2(v1, vindex, 16);
1054
+ v2 = vwaddu_vv_u32m2(vget_v_u16m2_u16m1(v1, 0), vget_v_u16m2_u16m1(v1, 1), 8);
1055
+ return v_uint32x4(vadd_vv_u32m1(
1056
+ vadd_vv_u32m1(vget_v_u32m2_u32m1(v2, 0), vget_v_u32m2_u32m1(v2, 1), 4),
1057
+ c.val, 4));
1058
+ }
1059
+
1060
+ inline v_int32x4 v_dotprod_expand(const v_int8x16 &a, const v_int8x16 &b) {
1061
+ vuint32m4_t vindex32 = vundefined_u32m4();
1062
+ vuint32m1_t vindex0 = vid_v_u32m1(4);
1063
+ vindex0 = vsll_vx_u32m1(vindex0, 2, 4);
1064
+ vindex32 = vset_v_u32m1_u32m4(vindex32, 0, vindex0);
1065
+ vindex32 = vset_v_u32m1_u32m4(vindex32, 1, vadd_vx_u32m1(vindex0, 1, 4));
1066
+ vindex32 = vset_v_u32m1_u32m4(vindex32, 2, vadd_vx_u32m1(vindex0, 2, 4));
1067
+ vindex32 = vset_v_u32m1_u32m4(vindex32, 3, vadd_vx_u32m1(vindex0, 3, 4));
1068
+ vuint16m2_t vindex = vnsrl_wx_u16m2(vindex32, 0, 16);
1069
+ vint16m2_t v1 = vundefined_i16m2();
1070
+ vint32m2_t v2 = vundefined_i32m2();
1071
+ v1 = vwmul_vv_i16m2(a.val, b.val, 16);
1072
+ v1 = vrgather_vv_i16m2(v1, vindex, 16);
1073
+ v2 = vwadd_vv_i32m2(vget_v_i16m2_i16m1(v1, 0), vget_v_i16m2_i16m1(v1, 1), 8);
1074
+ return v_int32x4(
1075
+ vadd_vv_i32m1(vget_v_i32m2_i32m1(v2, 0), vget_v_i32m2_i32m1(v2, 1), 4));
1076
+ }
1077
+
1078
+ inline v_int32x4 v_dotprod_expand(const v_int8x16 &a, const v_int8x16 &b,
1079
+ const v_int32x4 &c) {
1080
+ vuint32m4_t vindex32 = vundefined_u32m4();
1081
+ vuint32m1_t vindex0 = vid_v_u32m1(4);
1082
+ vindex0 = vsll_vx_u32m1(vindex0, 2, 4);
1083
+ vindex32 = vset_v_u32m1_u32m4(vindex32, 0, vindex0);
1084
+ vindex32 = vset_v_u32m1_u32m4(vindex32, 1, vadd_vx_u32m1(vindex0, 1, 4));
1085
+ vindex32 = vset_v_u32m1_u32m4(vindex32, 2, vadd_vx_u32m1(vindex0, 2, 4));
1086
+ vindex32 = vset_v_u32m1_u32m4(vindex32, 3, vadd_vx_u32m1(vindex0, 3, 4));
1087
+ vuint16m2_t vindex = vnsrl_wx_u16m2(vindex32, 0, 16);
1088
+ vint16m2_t v1 = vundefined_i16m2();
1089
+ vint32m2_t v2 = vundefined_i32m2();
1090
+ v1 = vwmul_vv_i16m2(a.val, b.val, 16);
1091
+ v1 = vrgather_vv_i16m2(v1, vindex, 16);
1092
+ v2 = vwadd_vv_i32m2(vget_v_i16m2_i16m1(v1, 0), vget_v_i16m2_i16m1(v1, 1), 8);
1093
+ return v_int32x4(vadd_vv_i32m1(
1094
+ vadd_vv_i32m1(vget_v_i32m2_i32m1(v2, 0), vget_v_i32m2_i32m1(v2, 1), 4),
1095
+ c.val, 4));
1096
+ }
1097
+
1098
+ inline v_uint64x2 v_dotprod_expand(const v_uint16x8 &a, const v_uint16x8 &b) {
1099
+ vuint64m4_t vindex64 = vundefined_u64m4();
1100
+ vuint64m1_t vindex0 = vid_v_u64m1(2);
1101
+ vindex0 = vsll_vx_u64m1(vindex0, 2, 2);
1102
+ vindex64 = vset_v_u64m1_u64m4(vindex64, 0, vindex0);
1103
+ vindex64 = vset_v_u64m1_u64m4(vindex64, 1, vadd_vx_u64m1(vindex0, 1, 2));
1104
+ vindex64 = vset_v_u64m1_u64m4(vindex64, 2, vadd_vx_u64m1(vindex0, 2, 2));
1105
+ vindex64 = vset_v_u64m1_u64m4(vindex64, 3, vadd_vx_u64m1(vindex0, 3, 2));
1106
+ vuint32m2_t vindex = vnsrl_wx_u32m2(vindex64, 0, 8);
1107
+ vuint32m2_t v1 = vundefined_u32m2();
1108
+ vuint64m2_t v2 = vundefined_u64m2();
1109
+ v1 = vwmulu_vv_u32m2(a.val, b.val, 8);
1110
+ v1 = vrgather_vv_u32m2(v1, vindex, 8);
1111
+ v2 = vwaddu_vv_u64m2(vget_v_u32m2_u32m1(v1, 0), vget_v_u32m2_u32m1(v1, 1), 4);
1112
+ return v_uint64x2(
1113
+ vadd_vv_u64m1(vget_v_u64m2_u64m1(v2, 0), vget_v_u64m2_u64m1(v2, 1), 2));
1114
+ }
1115
+
1116
+ inline v_uint64x2 v_dotprod_expand(const v_uint16x8 &a, const v_uint16x8 &b,
1117
+ const v_uint64x2 &c) {
1118
+ vuint64m4_t vindex64 = vundefined_u64m4();
1119
+ vuint64m1_t vindex0 = vid_v_u64m1(2);
1120
+ vindex0 = vsll_vx_u64m1(vindex0, 2, 2);
1121
+ vindex64 = vset_v_u64m1_u64m4(vindex64, 0, vindex0);
1122
+ vindex64 = vset_v_u64m1_u64m4(vindex64, 1, vadd_vx_u64m1(vindex0, 1, 2));
1123
+ vindex64 = vset_v_u64m1_u64m4(vindex64, 2, vadd_vx_u64m1(vindex0, 2, 2));
1124
+ vindex64 = vset_v_u64m1_u64m4(vindex64, 3, vadd_vx_u64m1(vindex0, 3, 2));
1125
+ vuint32m2_t vindex = vnsrl_wx_u32m2(vindex64, 0, 8);
1126
+ vuint32m2_t v1 = vundefined_u32m2();
1127
+ vuint64m2_t v2 = vundefined_u64m2();
1128
+ v1 = vwmulu_vv_u32m2(a.val, b.val, 8);
1129
+ v1 = vrgather_vv_u32m2(v1, vindex, 8);
1130
+ v2 = vwaddu_vv_u64m2(vget_v_u32m2_u32m1(v1, 0), vget_v_u32m2_u32m1(v1, 1), 4);
1131
+ return v_uint64x2(vadd_vv_u64m1(
1132
+ vadd_vv_u64m1(vget_v_u64m2_u64m1(v2, 0), vget_v_u64m2_u64m1(v2, 1), 2),
1133
+ c.val, 2));
1134
+ }
1135
+
1136
+ inline v_int64x2 v_dotprod_expand(const v_int16x8 &a, const v_int16x8 &b) {
1137
+ vuint64m4_t vindex64 = vundefined_u64m4();
1138
+ vuint64m1_t vindex0 = vid_v_u64m1(2);
1139
+ vindex0 = vsll_vx_u64m1(vindex0, 2, 2);
1140
+ vindex64 = vset_v_u64m1_u64m4(vindex64, 0, vindex0);
1141
+ vindex64 = vset_v_u64m1_u64m4(vindex64, 1, vadd_vx_u64m1(vindex0, 1, 2));
1142
+ vindex64 = vset_v_u64m1_u64m4(vindex64, 2, vadd_vx_u64m1(vindex0, 2, 2));
1143
+ vindex64 = vset_v_u64m1_u64m4(vindex64, 3, vadd_vx_u64m1(vindex0, 3, 2));
1144
+ vuint32m2_t vindex = vnsrl_wx_u32m2(vindex64, 0, 8);
1145
+ vint32m2_t v1 = vundefined_i32m2();
1146
+ vint64m2_t v2 = vundefined_i64m2();
1147
+ v1 = vwmul_vv_i32m2(a.val, b.val, 8);
1148
+ v1 = vrgather_vv_i32m2(v1, vindex, 8);
1149
+ v2 = vwadd_vv_i64m2(vget_v_i32m2_i32m1(v1, 0), vget_v_i32m2_i32m1(v1, 1), 4);
1150
+ return v_int64x2(
1151
+ vadd_vv_i64m1(vget_v_i64m2_i64m1(v2, 0), vget_v_i64m2_i64m1(v2, 1), 2));
1152
+ }
1153
+
1154
+ inline v_int64x2 v_dotprod_expand(const v_int16x8 &a, const v_int16x8 &b,
1155
+ const v_int64x2 &c) {
1156
+ vuint64m4_t vindex64 = vundefined_u64m4();
1157
+ vuint64m1_t vindex0 = vid_v_u64m1(2);
1158
+ vindex0 = vsll_vx_u64m1(vindex0, 2, 2);
1159
+ vindex64 = vset_v_u64m1_u64m4(vindex64, 0, vindex0);
1160
+ vindex64 = vset_v_u64m1_u64m4(vindex64, 1, vadd_vx_u64m1(vindex0, 1, 2));
1161
+ vindex64 = vset_v_u64m1_u64m4(vindex64, 2, vadd_vx_u64m1(vindex0, 2, 2));
1162
+ vindex64 = vset_v_u64m1_u64m4(vindex64, 3, vadd_vx_u64m1(vindex0, 3, 2));
1163
+ vuint32m2_t vindex = vnsrl_wx_u32m2(vindex64, 0, 8);
1164
+ vint32m2_t v1 = vundefined_i32m2();
1165
+ vint64m2_t v2 = vundefined_i64m2();
1166
+ v1 = vwmul_vv_i32m2(a.val, b.val, 8);
1167
+ v1 = vrgather_vv_i32m2(v1, vindex, 8);
1168
+ v2 = vwadd_vv_i64m2(vget_v_i32m2_i32m1(v1, 0), vget_v_i32m2_i32m1(v1, 1), 4);
1169
+ return v_int64x2(vadd_vv_i64m1(
1170
+ vadd_vv_i64m1(vget_v_i64m2_i64m1(v2, 0), vget_v_i64m2_i64m1(v2, 1), 2),
1171
+ c.val, 2));
1172
+ }
1173
+
1174
+ //////// Fast Dot Product ////////
1175
+ // 16 >> 32
1176
+ inline v_int32x4 v_dotprod_fast(const v_int16x8 &a, const v_int16x8 &b) {
1177
+ vint32m2_t v1 = vundefined_i32m2();
1178
+ v1 = vwmul_vv_i32m2(a.val, b.val, 8);
1179
+ return v_int32x4(
1180
+ vadd_vv_i32m1(vget_v_i32m2_i32m1(v1, 0), vget_v_i32m2_i32m1(v1, 1), 4));
1181
+ }
1182
+
1183
+ inline v_int32x4 v_dotprod_fast(const v_int16x8 &a, const v_int16x8 &b,
1184
+ const v_int32x4 &c) {
1185
+ vint32m2_t v1 = vundefined_i32m2();
1186
+ v1 = vwmul_vv_i32m2(a.val, b.val, 8);
1187
+ return v_int32x4(vadd_vv_i32m1(
1188
+ vadd_vv_i32m1(vget_v_i32m2_i32m1(v1, 0), vget_v_i32m2_i32m1(v1, 1), 4),
1189
+ c.val, 4));
1190
+ }
1191
+
1192
+ // 32 >> 64
1193
+ inline v_int64x2 v_dotprod_fast(const v_int32x4 &a, const v_int32x4 &b) {
1194
+ vint64m2_t v1 = vundefined_i64m2();
1195
+ v1 = vwmul_vv_i64m2(a.val, b.val, 4);
1196
+ return v_int64x2(
1197
+ vadd_vv_i64m1(vget_v_i64m2_i64m1(v1, 0), vget_v_i64m2_i64m1(v1, 1), 2));
1198
+ }
1199
+ inline v_int64x2 v_dotprod_fast(const v_int32x4 &a, const v_int32x4 &b,
1200
+ const v_int64x2 &c) {
1201
+ vint64m2_t v1 = vundefined_i64m2();
1202
+ v1 = vwmul_vv_i64m2(a.val, b.val, 8);
1203
+ return v_int64x2(vadd_vv_i64m1(
1204
+ vadd_vv_i64m1(vget_v_i64m2_i64m1(v1, 0), vget_v_i64m2_i64m1(v1, 1), 4),
1205
+ c.val, 4));
1206
+ }
1207
+
1208
+ // 8 >> 32
1209
+ inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16 &a,
1210
+ const v_uint8x16 &b) {
1211
+ vuint16m2_t v1 = vundefined_u16m2();
1212
+ vuint32m2_t v2 = vundefined_u32m2();
1213
+ v1 = vwmulu_vv_u16m2(a.val, b.val, 16);
1214
+ v2 = vwaddu_vv_u32m2(vget_v_u16m2_u16m1(v1, 0), vget_v_u16m2_u16m1(v1, 1), 8);
1215
+ return v_uint32x4(
1216
+ vadd_vv_u32m1(vget_v_u32m2_u32m1(v2, 0), vget_v_u32m2_u32m1(v2, 1), 4));
1217
+ }
1218
+
1219
+ inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16 &a,
1220
+ const v_uint8x16 &b,
1221
+ const v_uint32x4 &c) {
1222
+ vuint16m2_t v1 = vundefined_u16m2();
1223
+ vuint32m2_t v2 = vundefined_u32m2();
1224
+ v1 = vwmulu_vv_u16m2(a.val, b.val, 16);
1225
+ v2 = vwaddu_vv_u32m2(vget_v_u16m2_u16m1(v1, 0), vget_v_u16m2_u16m1(v1, 1), 8);
1226
+ return v_uint32x4(vadd_vv_u32m1(
1227
+ vadd_vv_u32m1(vget_v_u32m2_u32m1(v2, 0), vget_v_u32m2_u32m1(v2, 1), 4),
1228
+ c.val, 4));
1229
+ }
1230
+
1231
+ inline v_int32x4 v_dotprod_expand_fast(const v_int8x16 &a, const v_int8x16 &b) {
1232
+ vint16m2_t v1 = vundefined_i16m2();
1233
+ vint32m2_t v2 = vundefined_i32m2();
1234
+ v1 = vwmul_vv_i16m2(a.val, b.val, 16);
1235
+ v2 = vwadd_vv_i32m2(vget_v_i16m2_i16m1(v1, 0), vget_v_i16m2_i16m1(v1, 1), 8);
1236
+ return v_int32x4(
1237
+ vadd_vv_i32m1(vget_v_i32m2_i32m1(v2, 0), vget_v_i32m2_i32m1(v2, 1), 4));
1238
+ }
1239
+ inline v_int32x4 v_dotprod_expand_fast(const v_int8x16 &a, const v_int8x16 &b,
1240
+ const v_int32x4 &c) {
1241
+ vint16m2_t v1 = vundefined_i16m2();
1242
+ vint32m2_t v2 = vundefined_i32m2();
1243
+ v1 = vwmul_vv_i16m2(a.val, b.val, 16);
1244
+ v2 = vwadd_vv_i32m2(vget_v_i16m2_i16m1(v1, 0), vget_v_i16m2_i16m1(v1, 1), 8);
1245
+ return v_int32x4(vadd_vv_i32m1(
1246
+ vadd_vv_i32m1(vget_v_i32m2_i32m1(v2, 0), vget_v_i32m2_i32m1(v2, 1), 4),
1247
+ c.val, 4));
1248
+ }
1249
+
1250
+ // 16 >> 64
1251
+ inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8 &a,
1252
+ const v_uint16x8 &b) {
1253
+ vuint32m2_t v1 = vundefined_u32m2();
1254
+ vuint64m2_t v2 = vundefined_u64m2();
1255
+ v1 = vwmulu_vv_u32m2(a.val, b.val, 8);
1256
+ v2 = vwaddu_vv_u64m2(vget_v_u32m2_u32m1(v1, 0), vget_v_u32m2_u32m1(v1, 1), 4);
1257
+ return v_uint64x2(
1258
+ vadd_vv_u64m1(vget_v_u64m2_u64m1(v2, 0), vget_v_u64m2_u64m1(v2, 1), 2));
1259
+ }
1260
+ inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8 &a,
1261
+ const v_uint16x8 &b,
1262
+ const v_uint64x2 &c) {
1263
+ vuint32m2_t v1 = vundefined_u32m2();
1264
+ vuint64m2_t v2 = vundefined_u64m2();
1265
+ v1 = vwmulu_vv_u32m2(a.val, b.val, 8);
1266
+ v2 = vwaddu_vv_u64m2(vget_v_u32m2_u32m1(v1, 0), vget_v_u32m2_u32m1(v1, 1), 4);
1267
+ return v_uint64x2(vadd_vv_u64m1(
1268
+ vadd_vv_u64m1(vget_v_u64m2_u64m1(v2, 0), vget_v_u64m2_u64m1(v2, 1), 2),
1269
+ c.val, 2));
1270
+ }
1271
+
1272
+ inline v_int64x2 v_dotprod_expand_fast(const v_int16x8 &a, const v_int16x8 &b) {
1273
+ vint32m2_t v1 = vundefined_i32m2();
1274
+ vint64m2_t v2 = vundefined_i64m2();
1275
+ v1 = vwmul_vv_i32m2(a.val, b.val, 8);
1276
+ v2 = vwadd_vv_i64m2(vget_v_i32m2_i32m1(v1, 0), vget_v_i32m2_i32m1(v1, 1), 4);
1277
+ return v_int64x2(
1278
+ vadd_vv_i64m1(vget_v_i64m2_i64m1(v2, 0), vget_v_i64m2_i64m1(v2, 1), 2));
1279
+ }
1280
+ inline v_int64x2 v_dotprod_expand_fast(const v_int16x8 &a, const v_int16x8 &b,
1281
+ const v_int64x2 &c) {
1282
+ vint32m2_t v1 = vundefined_i32m2();
1283
+ vint64m2_t v2 = vundefined_i64m2();
1284
+ v1 = vwmul_vv_i32m2(a.val, b.val, 8);
1285
+ v2 = vwadd_vv_i64m2(vget_v_i32m2_i32m1(v1, 0), vget_v_i32m2_i32m1(v1, 1), 4);
1286
+ return v_int64x2(vadd_vv_i64m1(
1287
+ vadd_vv_i64m1(vget_v_i64m2_i64m1(v2, 0), vget_v_i64m2_i64m1(v2, 1), 2),
1288
+ c.val, 2));
1289
+ }
1290
+
1291
+ #define OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_W(_Tpvec, _Tpvec2, len, scalartype, \
1292
+ func, intrin, num) \
1293
+ inline scalartype v_reduce_##func(const v_##_Tpvec##x##num &a) { \
1294
+ v##_Tpvec2##m1_t val = vmv_v_x_##len##m1(0, num); \
1295
+ val = intrin(val, a.val, val, num); \
1296
+ return vmv_x_s_##len##m1_##len(val); \
1297
+ }
1298
+
1299
+ #define OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_(_Tpvec, _Tpvec2, scalartype, func, \
1300
+ funcu, num, scalerfunc) \
1301
+ inline scalartype v_reduce_##func(const v_##_Tpvec##x##num &a) { \
1302
+ v##_Tpvec##m1_t val = vundefined_##_Tpvec2##m1(); \
1303
+ val = v##funcu##_vs_##_Tpvec2##m1_##_Tpvec2##m1(val, a.val, a.val, num); \
1304
+ return scalerfunc(val); \
1305
+ }
1306
+ OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_W(int8, int16, i16, int, sum,
1307
+ vwredsum_vs_i8m1_i16m1, 16)
1308
+ OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_W(int16, int32, i32, int, sum,
1309
+ vwredsum_vs_i16m1_i32m1, 8)
1310
+ OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_W(int32, int64, i64, int, sum,
1311
+ vwredsum_vs_i32m1_i64m1, 4)
1312
+ OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_W(uint8, uint16, u16, unsigned, sum,
1313
+ vwredsumu_vs_u8m1_u16m1, 16)
1314
+ OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_W(uint16, uint32, u32, unsigned, sum,
1315
+ vwredsumu_vs_u16m1_u32m1, 8)
1316
+ OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_W(uint32, uint64, u64, unsigned, sum,
1317
+ vwredsumu_vs_u32m1_u64m1, 4)
1318
+ inline float v_reduce_sum(const v_float32x4 &a) {
1319
+ vfloat32m1_t val = vfmv_v_f_f32m1(0.0, 4);
1320
+ val = vfredosum_vs_f32m1_f32m1(val, a.val, val, 4);
1321
+ return vfmv_f_s_f32m1_f32(val);
1322
+ }
1323
+ inline double v_reduce_sum(const v_float64x2 &a) {
1324
+ vfloat64m1_t val = vfmv_v_f_f64m1(0.0, 2);
1325
+ val = vfredosum_vs_f64m1_f64m1(val, a.val, val, 2);
1326
+ return vfmv_f_s_f64m1_f64(val);
1327
+ }
1328
+ inline uint64 v_reduce_sum(const v_uint64x2 &a) {
1329
+ vuint64m1_t res = vundefined_u64m1();
1330
+ return vmv_x_s_u64m1_u64(
1331
+ vredsum_vs_u64m1_u64m1(res, a.val, vmv_v_x_u64m1(0, 2), 2));
1332
+ }
1333
+
1334
+ inline int64 v_reduce_sum(const v_int64x2 &a) {
1335
+ vint64m1_t res = vundefined_i64m1();
1336
+ return vmv_x_s_i64m1_i64(
1337
+ vredsum_vs_i64m1_i64m1(res, a.val, vmv_v_x_i64m1(0, 2), 2));
1338
+ }
1339
+
1340
+ #define OPENCV_HAL_IMPL_RISCVV_REDUCE_OP(func) \
1341
+ OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_(int8, i8, int, func, red##func, 16, \
1342
+ vmv_x_s_i8m1_i8) \
1343
+ OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_(int16, i16, int, func, red##func, 8, \
1344
+ vmv_x_s_i16m1_i16) \
1345
+ OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_(int32, i32, int, func, red##func, 4, \
1346
+ vmv_x_s_i32m1_i32) \
1347
+ OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_(int64, i64, int, func, red##func, 2, \
1348
+ vmv_x_s_i64m1_i64) \
1349
+ OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_(uint8, u8, unsigned, func, red##func##u, \
1350
+ 16, vmv_x_s_u8m1_u8) \
1351
+ OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_(uint16, u16, unsigned, func, red##func##u, \
1352
+ 8, vmv_x_s_u16m1_u16) \
1353
+ OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_(uint32, u32, unsigned, func, red##func##u, \
1354
+ 4, vmv_x_s_u32m1_u32) \
1355
+ OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_(float32, f32, float, func, fred##func, 4, \
1356
+ vfmv_f_s_f32m1_f32)
1357
+ OPENCV_HAL_IMPL_RISCVV_REDUCE_OP(max)
1358
+ OPENCV_HAL_IMPL_RISCVV_REDUCE_OP(min)
1359
+
1360
+ inline v_float32x4 v_reduce_sum4(const v_float32x4 &a, const v_float32x4 &b,
1361
+ const v_float32x4 &c, const v_float32x4 &d) {
1362
+ vfloat32m1_t a0 = vfmv_v_f_f32m1(0.0, 4);
1363
+ vfloat32m1_t b0 = vfmv_v_f_f32m1(0.0, 4);
1364
+ vfloat32m1_t c0 = vfmv_v_f_f32m1(0.0, 4);
1365
+ vfloat32m1_t d0 = vfmv_v_f_f32m1(0.0, 4);
1366
+ a0 = vfredosum_vs_f32m1_f32m1(a0, a.val, a0, 4);
1367
+ b0 = vfredosum_vs_f32m1_f32m1(b0, b.val, b0, 4);
1368
+ c0 = vfredosum_vs_f32m1_f32m1(c0, c.val, c0, 4);
1369
+ d0 = vfredosum_vs_f32m1_f32m1(d0, d.val, d0, 4);
1370
+ vfloat32m1_t res;
1371
+ res = vslideup_vx_f32m1(a0, b0, 1, 4);
1372
+ res = vslideup_vx_f32m1(res, c0, 2, 4);
1373
+ res = vslideup_vx_f32m1(res, d0, 3, 4);
1374
+ return v_float32x4(res);
1375
+ }
1376
+
1377
+ inline float v_reduce_sad(const v_float32x4 &a, const v_float32x4 &b) {
1378
+ vfloat32m1_t a0 = vfmv_v_f_f32m1(0.0, 4);
1379
+ vfloat32m1_t x = vfsub_vv_f32m1(a.val, b.val, 4);
1380
+ vbool32_t mask = vmflt_vf_f32m1_b32(x, 0, 4);
1381
+ vfloat32m1_t val = vfrsub_vf_f32m1_m(mask, x, x, 0, 4);
1382
+ a0 = vfredosum_vs_f32m1_f32m1(a0, val, a0, 4);
1383
+ return vfmv_f_s_f32m1_f32(a0);
1384
+ }
1385
+
1386
+ #define OPENCV_HAL_IMPL_RISCVV_REDUCE_SAD(_Tpvec, _Tpvec2) \
1387
+ inline unsigned v_reduce_sad(const _Tpvec &a, const _Tpvec &b) { \
1388
+ _Tpvec2 x = v_absdiff(a, b); \
1389
+ return v_reduce_sum(x); \
1390
+ }
1391
+
1392
+ OPENCV_HAL_IMPL_RISCVV_REDUCE_SAD(v_int8x16, v_uint8x16)
1393
+ OPENCV_HAL_IMPL_RISCVV_REDUCE_SAD(v_uint8x16, v_uint8x16)
1394
+ OPENCV_HAL_IMPL_RISCVV_REDUCE_SAD(v_int16x8, v_uint16x8)
1395
+ OPENCV_HAL_IMPL_RISCVV_REDUCE_SAD(v_uint16x8, v_uint16x8)
1396
+ OPENCV_HAL_IMPL_RISCVV_REDUCE_SAD(v_int32x4, v_uint32x4)
1397
+ OPENCV_HAL_IMPL_RISCVV_REDUCE_SAD(v_uint32x4, v_uint32x4)
1398
+
1399
+ #define OPENCV_HAL_IMPL_RISCVV_INT_CMP_OP(_Tpvec, _Tp, _T, num, uv) \
1400
+ inline _Tpvec v_eq(const _Tpvec &a, const _Tpvec &b) { \
1401
+ vbool##_T##_t mask = vmseq_vv_##_Tp##_b##_T(a.val, b.val, num); \
1402
+ return _Tpvec(vmerge_vxm_##_Tp(mask, vmv_v_x_##_Tp(0, num), -1, num)); \
1403
+ } \
1404
+ inline _Tpvec v_ne(const _Tpvec &a, const _Tpvec &b) { \
1405
+ vbool##_T##_t mask = vmsne_vv_##_Tp##_b##_T(a.val, b.val, num); \
1406
+ return _Tpvec(vmerge_vxm_##_Tp(mask, vmv_v_x_##_Tp(0, num), -1, num)); \
1407
+ } \
1408
+ inline _Tpvec v_lt(const _Tpvec &a, const _Tpvec &b) { \
1409
+ vbool##_T##_t mask = vmslt##uv##_Tp##_b##_T(a.val, b.val, num); \
1410
+ return _Tpvec(vmerge_vxm_##_Tp(mask, vmv_v_x_##_Tp(0, num), -1, num)); \
1411
+ } \
1412
+ inline _Tpvec v_gt(const _Tpvec &a, const _Tpvec &b) { \
1413
+ vbool##_T##_t mask = vmslt##uv##_Tp##_b##_T(b.val, a.val, num); \
1414
+ return _Tpvec(vmerge_vxm_##_Tp(mask, vmv_v_x_##_Tp(0, num), -1, num)); \
1415
+ } \
1416
+ inline _Tpvec v_le(const _Tpvec &a, const _Tpvec &b) { \
1417
+ vbool##_T##_t mask = vmsle##uv##_Tp##_b##_T(a.val, b.val, num); \
1418
+ return _Tpvec(vmerge_vxm_##_Tp(mask, vmv_v_x_##_Tp(0, num), -1, num)); \
1419
+ } \
1420
+ inline _Tpvec v_ge(const _Tpvec &a, const _Tpvec &b) { \
1421
+ vbool##_T##_t mask = vmsle##uv##_Tp##_b##_T(b.val, a.val, num); \
1422
+ return _Tpvec(vmerge_vxm_##_Tp(mask, vmv_v_x_##_Tp(0, num), -1, num)); \
1423
+ }
1424
+
1425
+ OPENCV_HAL_IMPL_RISCVV_INT_CMP_OP(v_int8x16, i8m1, 8, 16, _vv_)
1426
+ OPENCV_HAL_IMPL_RISCVV_INT_CMP_OP(v_int16x8, i16m1, 16, 8, _vv_)
1427
+ OPENCV_HAL_IMPL_RISCVV_INT_CMP_OP(v_int32x4, i32m1, 32, 4, _vv_)
1428
+ OPENCV_HAL_IMPL_RISCVV_INT_CMP_OP(v_int64x2, i64m1, 64, 2, _vv_)
1429
+ OPENCV_HAL_IMPL_RISCVV_INT_CMP_OP(v_uint8x16, u8m1, 8, 16, u_vv_)
1430
+ OPENCV_HAL_IMPL_RISCVV_INT_CMP_OP(v_uint16x8, u16m1, 16, 8, u_vv_)
1431
+ OPENCV_HAL_IMPL_RISCVV_INT_CMP_OP(v_uint32x4, u32m1, 32, 4, u_vv_)
1432
+ OPENCV_HAL_IMPL_RISCVV_INT_CMP_OP(v_uint64x2, u64m1, 64, 2, u_vv_)
1433
+
1434
+ // TODO: ==
1435
+ inline v_float32x4 v_eq(const v_float32x4 &a, const v_float32x4 &b) {
1436
+ vbool32_t mask = vmfeq_vv_f32m1_b32(a.val, b.val, 4);
1437
+ vint32m1_t res = vmerge_vxm_i32m1(mask, vmv_v_x_i32m1(0.0, 4), -1, 4);
1438
+ return v_float32x4(vreinterpret_v_i32m1_f32m1(res));
1439
+ }
1440
+ inline v_float32x4 v_ne(const v_float32x4 &a, const v_float32x4 &b) {
1441
+ vbool32_t mask = vmfne_vv_f32m1_b32(a.val, b.val, 4);
1442
+ vint32m1_t res = vmerge_vxm_i32m1(mask, vmv_v_x_i32m1(0.0, 4), -1, 4);
1443
+ return v_float32x4(vreinterpret_v_i32m1_f32m1(res));
1444
+ }
1445
+ inline v_float32x4 v_lt(const v_float32x4 &a, const v_float32x4 &b) {
1446
+ vbool32_t mask = vmflt_vv_f32m1_b32(a.val, b.val, 4);
1447
+ vint32m1_t res = vmerge_vxm_i32m1(mask, vmv_v_x_i32m1(0.0, 4), -1, 4);
1448
+ return v_float32x4(vreinterpret_v_i32m1_f32m1(res));
1449
+ }
1450
+ inline v_float32x4 v_le(const v_float32x4 &a, const v_float32x4 &b) {
1451
+ vbool32_t mask = vmfle_vv_f32m1_b32(a.val, b.val, 4);
1452
+ vint32m1_t res = vmerge_vxm_i32m1(mask, vmv_v_x_i32m1(0.0, 4), -1, 4);
1453
+ return v_float32x4(vreinterpret_v_i32m1_f32m1(res));
1454
+ }
1455
+ inline v_float32x4 v_gt(const v_float32x4 &a, const v_float32x4 &b) {
1456
+ vbool32_t mask = vmfgt_vv_f32m1_b32(a.val, b.val, 4);
1457
+ vint32m1_t res = vmerge_vxm_i32m1(mask, vmv_v_x_i32m1(0.0, 4), -1, 4);
1458
+ return v_float32x4(vreinterpret_v_i32m1_f32m1(res));
1459
+ }
1460
+ inline v_float32x4 v_ge(const v_float32x4 &a, const v_float32x4 &b) {
1461
+ vbool32_t mask = vmfge_vv_f32m1_b32(a.val, b.val, 4);
1462
+ vint32m1_t res = vmerge_vxm_i32m1(mask, vmv_v_x_i32m1(0.0, 4), -1, 4);
1463
+ return v_float32x4(vreinterpret_v_i32m1_f32m1(res));
1464
+ } /**/
1465
+ inline v_float32x4 v_not_nan(const v_float32x4 &a) {
1466
+ vbool32_t mask = vmfeq_vv_f32m1_b32(a.val, a.val, 4);
1467
+ vint32m1_t res = vmerge_vxm_i32m1(mask, vmv_v_x_i32m1(0.0, 4), -1, 4);
1468
+ return v_float32x4(vreinterpret_v_i32m1_f32m1(res));
1469
+ }
1470
+
1471
+ // TODO: ==
1472
+ inline v_float64x2 v_eq(const v_float64x2 &a, const v_float64x2 &b) {
1473
+ vbool64_t mask = vmfeq_vv_f64m1_b64(a.val, b.val, 2);
1474
+ vint64m1_t res = vmerge_vxm_i64m1(mask, vmv_v_x_i64m1(0.0, 2), -1, 2);
1475
+ return v_float64x2(vreinterpret_v_i64m1_f64m1(res));
1476
+ }
1477
+ inline v_float64x2 v_ne(const v_float64x2 &a, const v_float64x2 &b) {
1478
+ vbool64_t mask = vmfne_vv_f64m1_b64(a.val, b.val, 2);
1479
+ vint64m1_t res = vmerge_vxm_i64m1(mask, vmv_v_x_i64m1(0.0, 2), -1, 2);
1480
+ return v_float64x2(vreinterpret_v_i64m1_f64m1(res));
1481
+ }
1482
+ inline v_float64x2 v_lt(const v_float64x2 &a, const v_float64x2 &b) {
1483
+ vbool64_t mask = vmflt_vv_f64m1_b64(a.val, b.val, 2);
1484
+ vint64m1_t res = vmerge_vxm_i64m1(mask, vmv_v_x_i64m1(0.0, 2), -1, 2);
1485
+ return v_float64x2(vreinterpret_v_i64m1_f64m1(res));
1486
+ }
1487
+ inline v_float64x2 v_le(const v_float64x2 &a, const v_float64x2 &b) {
1488
+ vbool64_t mask = vmfle_vv_f64m1_b64(a.val, b.val, 2);
1489
+ vint64m1_t res = vmerge_vxm_i64m1(mask, vmv_v_x_i64m1(0.0, 2), -1, 2);
1490
+ return v_float64x2(vreinterpret_v_i64m1_f64m1(res));
1491
+ }
1492
+ inline v_float64x2 v_gt(const v_float64x2 &a, const v_float64x2 &b) {
1493
+ vbool64_t mask = vmfgt_vv_f64m1_b64(a.val, b.val, 2);
1494
+ vint64m1_t res = vmerge_vxm_i64m1(mask, vmv_v_x_i64m1(0.0, 2), -1, 2);
1495
+ return v_float64x2(vreinterpret_v_i64m1_f64m1(res));
1496
+ }
1497
+ inline v_float64x2 v_ge(const v_float64x2 &a, const v_float64x2 &b) {
1498
+ vbool64_t mask = vmfge_vv_f64m1_b64(a.val, b.val, 2);
1499
+ vint64m1_t res = vmerge_vxm_i64m1(mask, vmv_v_x_i64m1(0.0, 2), -1, 2);
1500
+ return v_float64x2(vreinterpret_v_i64m1_f64m1(res));
1501
+ } /**/
1502
+ inline v_float64x2 v_not_nan(const v_float64x2 &a) {
1503
+ vbool64_t mask = vmfeq_vv_f64m1_b64(a.val, a.val, 2);
1504
+ vint64m1_t res = vmerge_vxm_i64m1(mask, vmv_v_x_i64m1(0.0, 2), -1, 2);
1505
+ return v_float64x2(vreinterpret_v_i64m1_f64m1(res));
1506
+ }
1507
+ #define OPENCV_HAL_IMPL_RISCVV_TRANSPOSE4x4(_Tp, _T) \
1508
+ inline void v_transpose4x4( \
1509
+ const v_##_Tp##32x4 & a0, const v_##_Tp##32x4 & a1, \
1510
+ const v_##_Tp##32x4 & a2, const v_##_Tp##32x4 & a3, v_##_Tp##32x4 & b0, \
1511
+ v_##_Tp##32x4 & b1, v_##_Tp##32x4 & b2, v_##_Tp##32x4 & b3) { \
1512
+ vuint32m4_t vindex = vundefined_u32m4(); \
1513
+ vuint32m1_t vindex0 = vid_v_u32m1(4); \
1514
+ vindex0 = vsll_vx_u32m1(vindex0, 2, 4); \
1515
+ vindex = vset_v_u32m1_u32m4(vindex, 0, vindex0); \
1516
+ vindex = vset_v_u32m1_u32m4(vindex, 1, vadd_vx_u32m1(vindex0, 1, 4)); \
1517
+ vindex = vset_v_u32m1_u32m4(vindex, 2, vadd_vx_u32m1(vindex0, 2, 4)); \
1518
+ vindex = vset_v_u32m1_u32m4(vindex, 3, vadd_vx_u32m1(vindex0, 3, 4)); \
1519
+ v##_Tp##32m4_t val = vundefined_##_T##m4(); \
1520
+ val = vset_v_##_T##m1_##_T##m4(val, 0, a0.val); \
1521
+ val = vset_v_##_T##m1_##_T##m4(val, 1, a1.val); \
1522
+ val = vset_v_##_T##m1_##_T##m4(val, 2, a2.val); \
1523
+ val = vset_v_##_T##m1_##_T##m4(val, 3, a3.val); \
1524
+ val = vrgather_vv_##_T##m4(val, vindex, 16); \
1525
+ b0.val = vget_v_##_T##m4_##_T##m1(val, 0); \
1526
+ b1.val = vget_v_##_T##m4_##_T##m1(val, 1); \
1527
+ b2.val = vget_v_##_T##m4_##_T##m1(val, 2); \
1528
+ b3.val = vget_v_##_T##m4_##_T##m1(val, 3); \
1529
+ }
1530
+ OPENCV_HAL_IMPL_RISCVV_TRANSPOSE4x4(uint, u32) OPENCV_HAL_IMPL_RISCVV_TRANSPOSE4x4(
1531
+ int, i32) OPENCV_HAL_IMPL_RISCVV_TRANSPOSE4x4(float, f32)
1532
+
1533
+ #define OPENCV_HAL_IMPL_RISCVV_SHIFT_LEFT(_Tpvec, suffix, _T, num) \
1534
+ inline _Tpvec v_shl(const _Tpvec &a, int n) { \
1535
+ return _Tpvec((vsll_vx_##_T##m1(a.val, n, num))); \
1536
+ } \
1537
+ template <int n> inline _Tpvec v_shl(const _Tpvec &a) { \
1538
+ return _Tpvec((vsll_vx_##_T##m1(a.val, n, num))); \
1539
+ }
1540
+
1541
+ #define OPENCV_HAL_IMPL_RISCVV_SHIFT_RIGHT(_Tpvec, suffix, _T, num, intric) \
1542
+ inline _Tpvec v_shr(const _Tpvec &a, int n) { \
1543
+ return _Tpvec((v##intric##_vx_##_T##m1(a.val, n, num))); \
1544
+ } \
1545
+ template <int n> inline _Tpvec v_shr(const _Tpvec &a) { \
1546
+ return _Tpvec((v##intric##_vx_##_T##m1(a.val, n, num))); \
1547
+ } \
1548
+ template <int n> inline _Tpvec v_rshr(const _Tpvec &a) { \
1549
+ return _Tpvec((v##intric##_vx_##_T##m1( \
1550
+ vadd_vx_##_T##m1(a.val, 1 << (n - 1), num), n, num))); \
1551
+ }
1552
+
1553
+ // trade efficiency for convenience
1554
+ #define OPENCV_HAL_IMPL_RISCVV_SHIFT_OP(suffix, _T, num, intrin) \
1555
+ OPENCV_HAL_IMPL_RISCVV_SHIFT_LEFT(v_##suffix##x##num, suffix, _T, num) \
1556
+ OPENCV_HAL_IMPL_RISCVV_SHIFT_RIGHT(v_##suffix##x##num, suffix, _T, num, \
1557
+ intrin)
1558
+
1559
+ OPENCV_HAL_IMPL_RISCVV_SHIFT_OP(uint8, u8, 16, srl) OPENCV_HAL_IMPL_RISCVV_SHIFT_OP(
1560
+ uint16, u16, 8, srl) OPENCV_HAL_IMPL_RISCVV_SHIFT_OP(uint32, u32, 4,
1561
+ srl)
1562
+ OPENCV_HAL_IMPL_RISCVV_SHIFT_OP(uint64, u64, 2, srl) OPENCV_HAL_IMPL_RISCVV_SHIFT_OP(
1563
+ int8, i8, 16, sra) OPENCV_HAL_IMPL_RISCVV_SHIFT_OP(int16, i16, 8,
1564
+ sra)
1565
+ OPENCV_HAL_IMPL_RISCVV_SHIFT_OP(
1566
+ int32, i32, 4, sra) OPENCV_HAL_IMPL_RISCVV_SHIFT_OP(int64, i64,
1567
+ 2, sra)
1568
+
1569
+ #if 0
1570
+ #define VUP4(n) {0, 1, 2, 3}
1571
+ #define VUP8(n) {0, 1, 2, 3, 4, 5, 6, 7}
1572
+ #define VUP16(n) {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
1573
+ #define VUP2(n) {0, 1}
1574
+ #endif
1575
+ #define OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(_Tpvec, suffix, _T, num, num2, vmv, \
1576
+ len) \
1577
+ template <int n> inline _Tpvec v_rotate_left(const _Tpvec &a) { \
1578
+ suffix##m1_t tmp = vmv##_##_T##m1(0, num); \
1579
+ tmp = vslideup_vx_##_T##m1_m(vmset_m_##len(num), tmp, a.val, n, num); \
1580
+ return _Tpvec(tmp); \
1581
+ } \
1582
+ template <int n> inline _Tpvec v_rotate_right(const _Tpvec &a) { \
1583
+ suffix##m1_t res = vundefined_##_T##m1(); \
1584
+ return _Tpvec(vslidedown_vx_##_T##m1(res, a.val, n, num)); \
1585
+ } \
1586
+ template <> inline _Tpvec v_rotate_left<0>(const _Tpvec &a) { return a; } \
1587
+ template <int n> \
1588
+ inline _Tpvec v_rotate_right(const _Tpvec &a, const _Tpvec &b) { \
1589
+ suffix##m2_t tmp = vundefined_##_T##m2(); \
1590
+ suffix##m2_t res = vundefined_##_T##m2(); \
1591
+ tmp = vset_v_##_T##m1_##_T##m2(tmp, 0, a.val); \
1592
+ tmp = vset_v_##_T##m1_##_T##m2(tmp, 1, b.val); \
1593
+ res = vslidedown_vx_##_T##m2(res, tmp, n, num2); \
1594
+ return _Tpvec(vget_v_##_T##m2_##_T##m1(res, 0)); \
1595
+ } \
1596
+ template <int n> \
1597
+ inline _Tpvec v_rotate_left(const _Tpvec &a, const _Tpvec &b) { \
1598
+ suffix##m2_t tmp = vundefined_##_T##m2(); \
1599
+ suffix##m2_t res = vundefined_##_T##m2(); \
1600
+ tmp = vset_v_##_T##m1_##_T##m2(tmp, 0, b.val); \
1601
+ tmp = vset_v_##_T##m1_##_T##m2(tmp, 1, a.val); \
1602
+ res = vslideup_vx_##_T##m2(res, tmp, n, num2); \
1603
+ return _Tpvec(vget_v_##_T##m2_##_T##m1(res, 1)); \
1604
+ } \
1605
+ template <> \
1606
+ inline _Tpvec v_rotate_left<0>(const _Tpvec &a, const _Tpvec &b) { \
1607
+ CV_UNUSED(b); \
1608
+ return a; \
1609
+ }
1610
+
1611
+ OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(
1612
+ v_uint8x16, vuint8, u8, 16, 32, vmv_v_x,
1613
+ b8) OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(v_int8x16, vint8, i8,
1614
+ 16, 32, vmv_v_x, b8)
1615
+ OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(
1616
+ v_uint16x8, vuint16, u16, 8, 16, vmv_v_x,
1617
+ b16) OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(v_int16x8, vint16,
1618
+ i16, 8, 16,
1619
+ vmv_v_x, b16)
1620
+ OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(
1621
+ v_uint32x4, vuint32, u32, 4, 8, vmv_v_x,
1622
+ b32) OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(v_int32x4,
1623
+ vint32, i32,
1624
+ 4, 8, vmv_v_x,
1625
+ b32)
1626
+ OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(
1627
+ v_uint64x2, vuint64, u64, 2, 4, vmv_v_x,
1628
+ b64) OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(v_int64x2,
1629
+ vint64,
1630
+ i64, 2, 4,
1631
+ vmv_v_x,
1632
+ b64)
1633
+ OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(
1634
+ v_float32x4, vfloat32, f32, 4, 8, vfmv_v_f,
1635
+ b32) OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(v_float64x2,
1636
+ vfloat64,
1637
+ f64,
1638
+ 2, 4,
1639
+ vfmv_v_f,
1640
+ b64)
1641
+
1642
+ #if 1
1643
+ #define vreinterpret_v_i8m1_i8m1
1644
+ #define vreinterpret_v_u8m1_u8m1
1645
+ #define OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(_Tpvec, _Tp, _Tp2, len, hnum, num, \
1646
+ elemsize, ldst_len, ldst_type) \
1647
+ inline _Tpvec v_load_halves(const _Tp *ptr0, const _Tp *ptr1) { \
1648
+ _Tp2##_t res = vundefined_##len(); \
1649
+ _Tp2##_t res1 = vundefined_##len(); \
1650
+ res = vreinterpret_v_##ldst_len##_##len( \
1651
+ vle8_v_##ldst_len((ldst_type *)ptr0, 8)); \
1652
+ res1 = vreinterpret_v_##ldst_len##_##len( \
1653
+ vle8_v_##ldst_len((ldst_type *)ptr1, 8)); \
1654
+ res = vslideup_vx_##len(res, res1, hnum, num); \
1655
+ return _Tpvec(res); \
1656
+ } \
1657
+ inline _Tpvec v_load_low(const _Tp *ptr) { \
1658
+ return _Tpvec(vreinterpret_v_##ldst_len##_##len( \
1659
+ vle8_v_##ldst_len((ldst_type *)ptr, 8))); \
1660
+ } \
1661
+ inline _Tpvec v_load_aligned(const _Tp *ptr) { \
1662
+ return _Tpvec(vreinterpret_v_##ldst_len##_##len( \
1663
+ vle8_v_##ldst_len((ldst_type *)ptr, 16))); \
1664
+ } \
1665
+ inline _Tpvec v_load(const _Tp *ptr) { \
1666
+ return _Tpvec(vle##elemsize##_v_##len(ptr, num)); \
1667
+ } \
1668
+ inline void v_store_low(_Tp *ptr, const _Tpvec &a) { \
1669
+ vse8_v_##ldst_len((ldst_type *)ptr, \
1670
+ vreinterpret_v_##len##_##ldst_len(a.val), 8); \
1671
+ } \
1672
+ inline void v_store_high(_Tp *ptr, const _Tpvec &a) { \
1673
+ _Tp2##_t a0 = vundefined_##len(); \
1674
+ a0 = vslidedown_vx_##len(a0, a.val, hnum, num); \
1675
+ vse8_v_##ldst_len((ldst_type *)ptr, vreinterpret_v_##len##_##ldst_len(a0), \
1676
+ 8); \
1677
+ } \
1678
+ inline void v_store(_Tp *ptr, const _Tpvec &a) { \
1679
+ vse##elemsize##_v_##len(ptr, a.val, num); \
1680
+ } \
1681
+ inline void v_store_aligned(_Tp *ptr, const _Tpvec &a) { \
1682
+ vse8_v_##ldst_len((ldst_type *)ptr, \
1683
+ vreinterpret_v_##len##_##ldst_len(a.val), 16); \
1684
+ } \
1685
+ inline void v_store_aligned_nocache(_Tp *ptr, const _Tpvec &a) { \
1686
+ vse8_v_##ldst_len((ldst_type *)ptr, \
1687
+ vreinterpret_v_##len##_##ldst_len(a.val), 16); \
1688
+ } \
1689
+ inline void v_store(_Tp *ptr, const _Tpvec &a, hal::StoreMode /*mode*/) { \
1690
+ vse8_v_##ldst_len((ldst_type *)ptr, \
1691
+ vreinterpret_v_##len##_##ldst_len(a.val), 16); \
1692
+ }
1693
+
1694
+ OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(
1695
+ v_uint8x16, uchar, vuint8m1, u8m1, 8,
1696
+ 16, 8, u8m1, uchar)
1697
+ OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(
1698
+ v_int8x16, schar, vint8m1, i8m1, 8,
1699
+ 16, 8, i8m1, schar)
1700
+ OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(
1701
+ v_uint16x8, ushort, vuint16m1,
1702
+ u16m1, 4, 8, 16, u8m1, uchar)
1703
+ OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(
1704
+ v_int16x8, short, vint16m1,
1705
+ i16m1, 4, 8, 16, i8m1,
1706
+ schar)
1707
+ OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(
1708
+ v_uint32x4, unsigned,
1709
+ vuint32m1, u32m1, 2, 4,
1710
+ 32, u8m1, uchar)
1711
+ OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(
1712
+ v_int32x4, int,
1713
+ vint32m1, i32m1, 2,
1714
+ 4, 32, i8m1, schar)
1715
+ OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(
1716
+ v_uint64x2,
1717
+ unsigned long,
1718
+ vuint64m1,
1719
+ u64m1, 1, 2, 64,
1720
+ u8m1, uchar)
1721
+ OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(
1722
+ v_int64x2,
1723
+ long,
1724
+ vint64m1,
1725
+ i64m1, 1, 2,
1726
+ 64, i8m1,
1727
+ schar)
1728
+
1729
+ #define OPENCV_HAL_IMPL_RISCVV_LOADSTORE_FLOAT_OP(_Tpvec, _Tp, _Tp2, len, \
1730
+ hnum, num, elemsize) \
1731
+ inline _Tpvec v_load_halves(const _Tp *ptr0, const _Tp *ptr1) { \
1732
+ _Tp2##_t res = vundefined_##len(); \
1733
+ _Tp2##_t res1 = vundefined_##len(); \
1734
+ res = vreinterpret_v_u##elemsize##m1_##len( \
1735
+ vreinterpret_v_u8m1_u##elemsize##m1(vle8_v_u8m1((uchar *)ptr0, 8))); \
1736
+ res1 = vreinterpret_v_u##elemsize##m1_##len( \
1737
+ vreinterpret_v_u8m1_u##elemsize##m1(vle8_v_u8m1((uchar *)ptr1, 8))); \
1738
+ res = vslideup_vx_##len(res, res1, hnum, num); \
1739
+ return _Tpvec(res); \
1740
+ } \
1741
+ inline _Tpvec v_load_low(const _Tp *ptr) { \
1742
+ return _Tpvec(vreinterpret_v_u##elemsize##m1_##len( \
1743
+ vreinterpret_v_u8m1_u##elemsize##m1(vle8_v_u8m1((uchar *)ptr, 8)))); \
1744
+ } \
1745
+ inline _Tpvec v_load_aligned(const _Tp *ptr) { \
1746
+ return _Tpvec(vreinterpret_v_u##elemsize##m1_##len( \
1747
+ vreinterpret_v_u8m1_u##elemsize##m1(vle8_v_u8m1((uchar *)ptr, 16)))); \
1748
+ } \
1749
+ inline _Tpvec v_load(const _Tp *ptr) { \
1750
+ return _Tpvec(vle##elemsize##_v_##len(ptr, num)); \
1751
+ } \
1752
+ inline void v_store_low(_Tp *ptr, const _Tpvec &a) { \
1753
+ vse8_v_u8m1((uchar *)ptr, \
1754
+ vreinterpret_v_u##elemsize##m1_u8m1( \
1755
+ vreinterpret_v_##len##_u##elemsize##m1(a.val)), \
1756
+ 8); \
1757
+ } \
1758
+ inline void v_store_high(_Tp *ptr, const _Tpvec &a) { \
1759
+ _Tp2##_t a0 = vundefined_##len(); \
1760
+ a0 = vslidedown_vx_##len(a0, a.val, hnum, num); \
1761
+ vse8_v_u8m1((uchar *)ptr, \
1762
+ vreinterpret_v_u##elemsize##m1_u8m1( \
1763
+ vreinterpret_v_##len##_u##elemsize##m1(a0)), \
1764
+ 8); \
1765
+ } \
1766
+ inline void v_store(_Tp *ptr, const _Tpvec &a) { \
1767
+ vse##elemsize##_v_##len(ptr, a.val, num); \
1768
+ } \
1769
+ inline void v_store_aligned(_Tp *ptr, const _Tpvec &a) { \
1770
+ vse8_v_u8m1((uchar *)ptr, \
1771
+ vreinterpret_v_u##elemsize##m1_u8m1( \
1772
+ vreinterpret_v_##len##_u##elemsize##m1(a.val)), \
1773
+ 16); \
1774
+ } \
1775
+ inline void v_store_aligned_nocache(_Tp *ptr, const _Tpvec &a) { \
1776
+ vse8_v_u8m1((uchar *)ptr, \
1777
+ vreinterpret_v_u##elemsize##m1_u8m1( \
1778
+ vreinterpret_v_##len##_u##elemsize##m1(a.val)), \
1779
+ 16); \
1780
+ } \
1781
+ inline void v_store(_Tp *ptr, const _Tpvec &a, hal::StoreMode /*mode*/) { \
1782
+ vse8_v_u8m1((uchar *)ptr, \
1783
+ vreinterpret_v_u##elemsize##m1_u8m1( \
1784
+ vreinterpret_v_##len##_u##elemsize##m1(a.val)), \
1785
+ 16); \
1786
+ }
1787
+ OPENCV_HAL_IMPL_RISCVV_LOADSTORE_FLOAT_OP(
1788
+ v_float32x4,
1789
+ float,
1790
+ vfloat32m1,
1791
+ f32m1,
1792
+ 2, 4,
1793
+ 32)
1794
+ OPENCV_HAL_IMPL_RISCVV_LOADSTORE_FLOAT_OP(
1795
+ v_float64x2,
1796
+ double,
1797
+ vfloat64m1,
1798
+ f64m1,
1799
+ 1,
1800
+ 2,
1801
+ 64)
1802
+
1803
+ #else
1804
+
1805
+ #define OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(_Tpvec, _Tp, _Tp2, len, hnum, num, \
1806
+ elemsize) \
1807
+ inline _Tpvec v_load_halves(const _Tp *ptr0, const _Tp *ptr1) { \
1808
+ _Tp2##_t res, res1; \
1809
+ res = vle##elemsize##_v_##len(ptr0, hnum); \
1810
+ res1 = vle##elemsize##_v_##len(ptr1, hnum); \
1811
+ res = vslideup_vx_##len(res, res1, hnum, num); \
1812
+ return _Tpvec(res); \
1813
+ } \
1814
+ inline _Tpvec v_load_low(const _Tp *ptr) { \
1815
+ return _Tpvec(vle##elemsize##_v_##len(ptr, hnum)); \
1816
+ } \
1817
+ inline _Tpvec v_load_aligned(const _Tp *ptr) { \
1818
+ return _Tpvec(vle##elemsize##_v_##len(ptr, num)); \
1819
+ } \
1820
+ inline _Tpvec v_load(const _Tp *ptr) { \
1821
+ return _Tpvec((_Tp2##_t)vle##elemsize##_v_##len((const _Tp *)ptr, num)); \
1822
+ } \
1823
+ inline void v_store_low(_Tp *ptr, const _Tpvec &a) { \
1824
+ vse##elemsize##_v_##len(ptr, a.val, hnum); \
1825
+ } \
1826
+ inline void v_store_high(_Tp *ptr, const _Tpvec &a) { \
1827
+ _Tp2##_t a0; \
1828
+ a0 = vslidedown_vx_##len(a0, a.val, hnum, num); \
1829
+ vse##elemsize##_v_##len(ptr, a0, hnum); \
1830
+ } \
1831
+ inline void v_store(_Tp *ptr, const _Tpvec &a) { \
1832
+ vse##elemsize##_v_##len(ptr, a.val, num); \
1833
+ } \
1834
+ inline void v_store_aligned(_Tp *ptr, const _Tpvec &a) { \
1835
+ vse##elemsize##_v_##len(ptr, a.val, num); \
1836
+ } \
1837
+ inline void v_store_aligned_nocache(_Tp *ptr, const _Tpvec &a) { \
1838
+ vse##elemsize##_v_##len(ptr, a.val, num); \
1839
+ } \
1840
+ inline void v_store(_Tp *ptr, const _Tpvec &a, hal::StoreMode /*mode*/) { \
1841
+ vse##elemsize##_v_##len(ptr, a.val, num); \
1842
+ }
1843
+
1844
+ OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(
1845
+ v_uint8x16, uchar, vuint8m1, u8m1, 8,
1846
+ 16,
1847
+ 8) OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(v_int8x16,
1848
+ schar,
1849
+ vint8m1,
1850
+ i8m1,
1851
+ 8,
1852
+ 16,
1853
+ 8)
1854
+ OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(
1855
+ v_uint16x8, ushort, vuint16m1,
1856
+ u16m1, 4, 8, 16)
1857
+ OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(
1858
+ v_int16x8, short, vint16m1,
1859
+ i16m1, 4, 8, 16)
1860
+ OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(
1861
+ v_uint32x4, unsigned,
1862
+ vuint32m1, u32m1, 2, 4, 32)
1863
+ OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(
1864
+ v_int32x4, int,
1865
+ vint32m1, i32m1, 2, 4,
1866
+ 32)
1867
+ OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(
1868
+ v_uint64x2,
1869
+ unsigned long,
1870
+ vuint64m1, u64m1, 1,
1871
+ 2, 64)
1872
+ OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(
1873
+ v_int64x2, long,
1874
+ vint64m1, i64m1,
1875
+ 1, 2, 64)
1876
+ OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(
1877
+ v_float32x4,
1878
+ float,
1879
+ vfloat32m1,
1880
+ f32m1, 2, 4,
1881
+ 32)
1882
+ OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(
1883
+ v_float64x2,
1884
+ double,
1885
+ vfloat64m1,
1886
+ f64m1,
1887
+ 1, 2,
1888
+ 64)
1889
+
1890
+ #endif
1891
+
1892
+ ////////////// Lookup table access ////////////////////
1893
+
1894
+ inline v_int8x16 v_lut(const schar *tab, const int *idx) {
1895
+ #if 0
1896
+ schar CV_DECL_ALIGNED(32) elems[16] =
1897
+ {
1898
+ tab[idx[ 0]],
1899
+ tab[idx[ 1]],
1900
+ tab[idx[ 2]],
1901
+ tab[idx[ 3]],
1902
+ tab[idx[ 4]],
1903
+ tab[idx[ 5]],
1904
+ tab[idx[ 6]],
1905
+ tab[idx[ 7]],
1906
+ tab[idx[ 8]],
1907
+ tab[idx[ 9]],
1908
+ tab[idx[10]],
1909
+ tab[idx[11]],
1910
+ tab[idx[12]],
1911
+ tab[idx[13]],
1912
+ tab[idx[14]],
1913
+ tab[idx[15]]
1914
+ };
1915
+ return v_int8x16(vle8_v_i8m1(elems, 16));
1916
+ #else
1917
+ #if __riscv_v == 7000
1918
+ return v_int8x16(vnclip_wx_i8m1(
1919
+ vnclip_wx_i16m2(vlxb_v_i32m4((const int *)tab,
1920
+ vle32_v_u32m4((unsigned int *)idx, 16), 16),
1921
+ 0, 16),
1922
+ 0, 16));
1923
+ #else
1924
+ return v_int8x16(
1925
+ vloxei32_v_i8m1(tab, vle32_v_u32m4((unsigned int *)idx, 16), 16));
1926
+ #endif
1927
+ #endif
1928
+ }
1929
+
1930
+ inline v_int8x16 v_lut_pairs(const schar *tab, const int *idx) {
1931
+ #if 0
1932
+ schar CV_DECL_ALIGNED(32) elems[16] =
1933
+ {
1934
+ tab[idx[0]],
1935
+ tab[idx[0] + 1],
1936
+ tab[idx[1]],
1937
+ tab[idx[1] + 1],
1938
+ tab[idx[2]],
1939
+ tab[idx[2] + 1],
1940
+ tab[idx[3]],
1941
+ tab[idx[3] + 1],
1942
+ tab[idx[4]],
1943
+ tab[idx[4] + 1],
1944
+ tab[idx[5]],
1945
+ tab[idx[5] + 1],
1946
+ tab[idx[6]],
1947
+ tab[idx[6] + 1],
1948
+ tab[idx[7]],
1949
+ tab[idx[7] + 1]
1950
+ };
1951
+ return v_int8x16(vle8_v_i8m1(elems, 16));
1952
+ #else
1953
+ vuint32m4_t seq, index;
1954
+ vuint32m4_t vidx = vle32_v_u32m4((unsigned int *)idx, 8);
1955
+ seq = vid_v_u32m4(16);
1956
+ index = vsrl_vx_u32m4(seq, 1, 16);
1957
+ vidx = vrgather_vv_u32m4(vidx, index, 16);
1958
+ index = vadd_vv_u32m4(vand_vx_u32m4(seq, 1, 16), vidx, 16);
1959
+ #if __riscv_v == 7000
1960
+ return v_int8x16(vnclip_wx_i8m1(
1961
+ vnclip_wx_i16m2(vlxb_v_i32m4((const int *)tab, index, 16), 0, 16), 0,
1962
+ 16));
1963
+ #else
1964
+ return v_int8x16(vloxei32_v_i8m1(tab, index, 16));
1965
+ #endif
1966
+ #endif
1967
+ }
1968
+ inline v_int8x16 v_lut_quads(const schar *tab, const int *idx) {
1969
+ #if 0
1970
+ schar CV_DECL_ALIGNED(32) elems[16] =
1971
+ {
1972
+ tab[idx[0]],
1973
+ tab[idx[0] + 1],
1974
+ tab[idx[0] + 2],
1975
+ tab[idx[0] + 3],
1976
+ tab[idx[1]],
1977
+ tab[idx[1] + 1],
1978
+ tab[idx[1] + 2],
1979
+ tab[idx[1] + 3],
1980
+ tab[idx[2]],
1981
+ tab[idx[2] + 1],
1982
+ tab[idx[2] + 2],
1983
+ tab[idx[2] + 3],
1984
+ tab[idx[3]],
1985
+ tab[idx[3] + 1],
1986
+ tab[idx[3] + 2],
1987
+ tab[idx[3] + 3]
1988
+ };
1989
+ return v_int8x16(vle8_v_i8m1(elems, 16));
1990
+ #else
1991
+ vuint32m4_t seq, index;
1992
+ vuint32m4_t vidx = vle32_v_u32m4((unsigned int *)idx, 4);
1993
+ seq = vid_v_u32m4(16);
1994
+ index = vsrl_vx_u32m4(seq, 2, 16);
1995
+ vidx = vrgather_vv_u32m4(vidx, index, 16);
1996
+ seq = vset_v_u32m1_u32m4(seq, 1, vget_v_u32m4_u32m1(seq, 0));
1997
+ seq = vset_v_u32m1_u32m4(seq, 2, vget_v_u32m4_u32m1(seq, 0));
1998
+ seq = vset_v_u32m1_u32m4(seq, 3, vget_v_u32m4_u32m1(seq, 0));
1999
+ index = vadd_vv_u32m4(seq, vidx, 16);
2000
+ #if __riscv_v == 7000
2001
+ return v_int8x16(vnclip_wx_i8m1(
2002
+ vnclip_wx_i16m2(vlxb_v_i32m4((const int *)tab, index, 16), 0, 16), 0,
2003
+ 16));
2004
+ #else
2005
+ return v_int8x16(vloxei32_v_i8m1(tab, index, 16));
2006
+ #endif
2007
+ #endif
2008
+ }
2009
+
2010
+ inline v_uint8x16 v_lut(const uchar *tab, const int *idx) {
2011
+ return v_reinterpret_as_u8(v_lut((schar *)tab, idx));
2012
+ }
2013
+ inline v_uint8x16 v_lut_pairs(const uchar *tab, const int *idx) {
2014
+ return v_reinterpret_as_u8(v_lut_pairs((schar *)tab, idx));
2015
+ }
2016
+ inline v_uint8x16 v_lut_quads(const uchar *tab, const int *idx) {
2017
+ return v_reinterpret_as_u8(v_lut_quads((schar *)tab, idx));
2018
+ }
2019
+
2020
+ inline v_int16x8 v_lut(const short *tab, const int *idx) {
2021
+ #if 0
2022
+ short CV_DECL_ALIGNED(32) elems[8] =
2023
+ {
2024
+ tab[idx[0]],
2025
+ tab[idx[1]],
2026
+ tab[idx[2]],
2027
+ tab[idx[3]],
2028
+ tab[idx[4]],
2029
+ tab[idx[5]],
2030
+ tab[idx[6]],
2031
+ tab[idx[7]]
2032
+ };
2033
+ return v_int16x8(vle16_v_i16m1(elems, 8));
2034
+ #else
2035
+ #if __riscv_v == 7000
2036
+ return v_int16x8(vnclip_wx_i16m1(
2037
+ vlxh_v_i32m2((const int *)tab,
2038
+ vsll_vx_u32m2(vle32_v_u32m2((unsigned int *)idx, 8), 1, 8),
2039
+ 8),
2040
+ 0, 8));
2041
+ #else
2042
+ return v_int16x8(vloxei32_v_i16m1(
2043
+ tab, vsll_vx_u32m2(vle32_v_u32m2((unsigned int *)idx, 8), 1, 8), 8));
2044
+ #endif
2045
+ #endif
2046
+ }
2047
+ inline v_int16x8 v_lut_pairs(const short *tab, const int *idx) {
2048
+ #if 0
2049
+ short CV_DECL_ALIGNED(32) elems[8] =
2050
+ {
2051
+ tab[idx[0]],
2052
+ tab[idx[0] + 1],
2053
+ tab[idx[1]],
2054
+ tab[idx[1] + 1],
2055
+ tab[idx[2]],
2056
+ tab[idx[2] + 1],
2057
+ tab[idx[3]],
2058
+ tab[idx[3] + 1]
2059
+ };
2060
+ return v_int16x8(vle16_v_i16m1(elems, 8));
2061
+ #else
2062
+ vuint32m2_t seq, index;
2063
+ vuint32m2_t vidx = vle32_v_u32m2((unsigned int *)idx, 4);
2064
+ seq = vid_v_u32m2(8);
2065
+ index = vsrl_vx_u32m2(seq, 1, 8);
2066
+ vidx = vrgather_vv_u32m2(vidx, index, 8);
2067
+ index = vsll_vx_u32m2(vadd_vv_u32m2(vand_vx_u32m2(seq, 1, 8), vidx, 8), 1, 8);
2068
+ #if __riscv_v == 7000
2069
+ return v_int16x8(
2070
+ vnclip_wx_i16m1(vlxh_v_i32m2((const int *)tab, index, 8), 0, 8));
2071
+ #else
2072
+ return v_int16x8(vloxei32_v_i16m1(tab, index, 8));
2073
+ #endif
2074
+ #endif
2075
+ }
2076
+ inline v_int16x8 v_lut_quads(const short *tab, const int *idx) {
2077
+ #if 0
2078
+ short CV_DECL_ALIGNED(32) elems[8] =
2079
+ {
2080
+ tab[idx[0]],
2081
+ tab[idx[0] + 1],
2082
+ tab[idx[0] + 2],
2083
+ tab[idx[0] + 3],
2084
+ tab[idx[1]],
2085
+ tab[idx[1] + 1],
2086
+ tab[idx[1] + 2],
2087
+ tab[idx[1] + 3]
2088
+ };
2089
+ return v_int16x8(vle16_v_i16m1(elems, 8));
2090
+ #else
2091
+ vuint32m2_t seq, index;
2092
+ vuint32m2_t vidx = vle32_v_u32m2((unsigned int *)idx, 2);
2093
+ seq = vid_v_u32m2(8);
2094
+ index = vsrl_vx_u32m2(seq, 2, 8);
2095
+ vidx = vrgather_vv_u32m2(vidx, index, 8);
2096
+ seq = vset_v_u32m1_u32m2(seq, 1, vget_v_u32m2_u32m1(seq, 0));
2097
+ index = vsll_vx_u32m2(vadd_vv_u32m2(seq, vidx, 8), 1, 8);
2098
+ #if __riscv_v == 7000
2099
+ return v_int16x8(
2100
+ vnclip_wx_i16m1(vlxh_v_i32m2((const int *)tab, index, 8), 0, 8));
2101
+ #else
2102
+ return v_int16x8(vloxei32_v_i16m1(tab, index, 8));
2103
+ #endif
2104
+ #endif
2105
+ }
2106
+ inline v_uint16x8 v_lut(const ushort *tab, const int *idx) {
2107
+ return v_reinterpret_as_u16(v_lut((short *)tab, idx));
2108
+ }
2109
+ inline v_uint16x8 v_lut_pairs(const ushort *tab, const int *idx) {
2110
+ return v_reinterpret_as_u16(v_lut_pairs((short *)tab, idx));
2111
+ }
2112
+ inline v_uint16x8 v_lut_quads(const ushort *tab, const int *idx) {
2113
+ return v_reinterpret_as_u16(v_lut_quads((short *)tab, idx));
2114
+ }
2115
+
2116
+ inline v_int32x4 v_lut(const int *tab, const int *idx) {
2117
+ #if 0
2118
+ int CV_DECL_ALIGNED(32) elems[4] =
2119
+ {
2120
+ tab[idx[0]],
2121
+ tab[idx[1]],
2122
+ tab[idx[2]],
2123
+ tab[idx[3]]
2124
+ };
2125
+ return v_int32x4(vle32_v_i32m1(elems, 4));
2126
+ #else
2127
+ return v_int32x4(vloxei32_v_i32m1(
2128
+ tab, vsll_vx_u32m1(vle32_v_u32m1((unsigned int *)idx, 4), 2, 4), 4));
2129
+ #endif
2130
+ }
2131
+ inline v_int32x4 v_lut_pairs(const int *tab, const int *idx) {
2132
+ #if 0
2133
+ int CV_DECL_ALIGNED(32) elems[4] =
2134
+ {
2135
+ tab[idx[0]],
2136
+ tab[idx[0] + 1],
2137
+ tab[idx[1]],
2138
+ tab[idx[1] + 1]
2139
+ };
2140
+ return v_int32x4(vle32_v_i32m1(elems, 4));
2141
+ #else
2142
+ vuint32m1_t seq, index;
2143
+ vuint32m1_t vidx = vle32_v_u32m1((unsigned int *)idx, 2);
2144
+ seq = vid_v_u32m1(4);
2145
+ index = vsrl_vx_u32m1(seq, 1, 4);
2146
+ vidx = vrgather_vv_u32m1(vidx, index, 4);
2147
+ index = vsll_vx_u32m1(vadd_vv_u32m1(vand_vx_u32m1(seq, 1, 4), vidx, 4), 2, 4);
2148
+ return v_int32x4(vloxei32_v_i32m1(tab, index, 4));
2149
+ #endif
2150
+ }
2151
+ inline v_int32x4 v_lut_quads(const int *tab, const int *idx) {
2152
+ return v_int32x4(vle32_v_i32m1(tab + idx[0], 4));
2153
+ }
2154
+ inline v_uint32x4 v_lut(const unsigned *tab, const int *idx) {
2155
+ return v_reinterpret_as_u32(v_lut((int *)tab, idx));
2156
+ }
2157
+ inline v_uint32x4 v_lut_pairs(const unsigned *tab, const int *idx) {
2158
+ return v_reinterpret_as_u32(v_lut_pairs((int *)tab, idx));
2159
+ }
2160
+ inline v_uint32x4 v_lut_quads(const unsigned *tab, const int *idx) {
2161
+ return v_reinterpret_as_u32(v_lut_quads((int *)tab, idx));
2162
+ }
2163
+
2164
+ inline v_int64x2 v_lut(const int64_t *tab, const int *idx) {
2165
+ // vint64m1_t res = {tab[idx[0]], tab[idx[1]]};
2166
+ return v_int64x2(vloxei64_v_i64m1(
2167
+ tab,
2168
+ vsll_vx_u64m1(
2169
+ vget_v_u64m2_u64m1(
2170
+ vwaddu_vx_u64m2(vle32_v_u32m1((uint32_t *)idx, 2), 0, 2), 0),
2171
+ 3, 2),
2172
+ 2));
2173
+ }
2174
+ inline v_int64x2 v_lut_pairs(const int64_t *tab, const int *idx) {
2175
+ return v_int64x2(vle64_v_i64m1(tab + idx[0], 2));
2176
+ }
2177
+
2178
+ inline v_uint64x2 v_lut(const uint64_t *tab, const int *idx) {
2179
+ // vuint64m1_t res = {tab[idx[0]], tab[idx[1]]};
2180
+ return v_uint64x2(vloxei64_v_u64m1(
2181
+ tab,
2182
+ vsll_vx_u64m1(
2183
+ vget_v_u64m2_u64m1(
2184
+ vwaddu_vx_u64m2(vle32_v_u32m1((uint32_t *)idx, 2), 0, 2), 0),
2185
+ 3, 2),
2186
+ 2));
2187
+ }
2188
+ inline v_uint64x2 v_lut_pairs(const uint64_t *tab, const int *idx) {
2189
+ return v_uint64x2(vle64_v_u64m1(tab + idx[0], 2));
2190
+ }
2191
+
2192
+ inline v_float32x4 v_lut(const float *tab, const int *idx) {
2193
+ #if 0
2194
+ float CV_DECL_ALIGNED(32) elems[4] =
2195
+ {
2196
+ tab[idx[0]],
2197
+ tab[idx[1]],
2198
+ tab[idx[2]],
2199
+ tab[idx[3]]
2200
+ };
2201
+ return v_float32x4(vle32_v_f32m1(elems, 4));
2202
+ #else
2203
+ return v_float32x4(vloxei32_v_f32m1(
2204
+ tab, vsll_vx_u32m1(vle32_v_u32m1((unsigned int *)idx, 4), 2, 4), 4));
2205
+ #endif
2206
+ }
2207
+ inline v_float32x4 v_lut_pairs(const float *tab, const int *idx) {
2208
+ #if 0
2209
+ float CV_DECL_ALIGNED(32) elems[4] =
2210
+ {
2211
+ tab[idx[0]],
2212
+ tab[idx[0]+1],
2213
+ tab[idx[1]],
2214
+ tab[idx[1]+1]
2215
+ };
2216
+ return v_float32x4(vle32_v_f32m1(elems, 4));
2217
+ #else
2218
+ vuint32m1_t seq, index;
2219
+ vuint32m1_t vidx = vle32_v_u32m1((unsigned int *)idx, 2);
2220
+ seq = vid_v_u32m1(4);
2221
+ index = vsrl_vx_u32m1(seq, 1, 4);
2222
+ vidx = vrgather_vv_u32m1(vidx, index, 4);
2223
+ index = vsll_vx_u32m1(vadd_vv_u32m1(vand_vx_u32m1(seq, 1, 4), vidx, 4), 2, 4);
2224
+ return v_float32x4(vloxei32_v_f32m1(tab, index, 4));
2225
+ #endif
2226
+ }
2227
+ inline v_float32x4 v_lut_quads(const float *tab, const int *idx) {
2228
+ return v_float32x4(vle32_v_f32m1(tab + idx[0], 4));
2229
+ }
2230
+ inline v_float64x2 v_lut(const double *tab, const int *idx) {
2231
+ // vfloat64m1_t res = {tab[idx[0]], tab[idx[1]]};
2232
+ return v_float64x2(vloxei64_v_f64m1(
2233
+ tab,
2234
+ vsll_vx_u64m1(
2235
+ vget_v_u64m2_u64m1(
2236
+ vwaddu_vx_u64m2(vle32_v_u32m1((uint32_t *)idx, 2), 0, 2), 0),
2237
+ 3, 2),
2238
+ 2));
2239
+ }
2240
+ inline v_float64x2 v_lut_pairs(const double *tab, const int *idx) {
2241
+ return v_float64x2(vle64_v_f64m1(tab + idx[0], 2));
2242
+ }
2243
+
2244
+ inline v_int32x4 v_lut(const int *tab, const v_int32x4 &idxvec) {
2245
+ /*int CV_DECL_ALIGNED(32) elems[4] =
2246
+ {
2247
+ tab[idxvec.val[0]],
2248
+ tab[idxvec.val[1]],
2249
+ tab[idxvec.val[2]],
2250
+ tab[idxvec.val[3]]
2251
+ };*/
2252
+ return v_int32x4(vloxei32_v_i32m1(
2253
+ tab, vsll_vx_u32m1(vreinterpret_v_i32m1_u32m1(idxvec.val), 2, 4), 4));
2254
+ }
2255
+
2256
+ inline v_uint32x4 v_lut(const unsigned *tab, const v_int32x4 &idxvec) {
2257
+ /*unsigned CV_DECL_ALIGNED(32) elems[4] =
2258
+ {
2259
+ tab[idxvec.val[0]],
2260
+ tab[idxvec.val[1]],
2261
+ tab[idxvec.val[2]],
2262
+ tab[idxvec.val[3]]
2263
+ };*/
2264
+ return v_uint32x4(vloxei32_v_u32m1(
2265
+ tab, vsll_vx_u32m1(vreinterpret_v_i32m1_u32m1(idxvec.val), 2, 4), 4));
2266
+ }
2267
+
2268
+ inline v_float32x4 v_lut(const float *tab, const v_int32x4 &idxvec) {
2269
+ /*float CV_DECL_ALIGNED(32) elems[4] =
2270
+ {
2271
+ tab[idxvec.val[0]],
2272
+ tab[idxvec.val[1]],
2273
+ tab[idxvec.val[2]],
2274
+ tab[idxvec.val[3]]
2275
+ };*/
2276
+ return v_float32x4(vloxei32_v_f32m1(
2277
+ tab, vsll_vx_u32m1(vreinterpret_v_i32m1_u32m1(idxvec.val), 2, 4), 4));
2278
+ }
2279
+ inline v_float64x2 v_lut(const double *tab, const v_int32x4 &idxvec) {
2280
+ // vfloat64m1_t res = {tab[idxvec.val[0]], tab[idxvec.val[1]]};
2281
+ return v_float64x2(vloxei64_v_f64m1(
2282
+ tab,
2283
+ vsll_vx_u64m1(vreinterpret_v_i64m1_u64m1(vget_v_i64m2_i64m1(
2284
+ vwadd_vx_i64m2(idxvec.val, 0, 2), 0)),
2285
+ 3, 2),
2286
+ 2));
2287
+ }
2288
+ inline void v_lut_deinterleave(const float *tab, const v_int32x4 &idxvec,
2289
+ v_float32x4 &x, v_float32x4 &y) {
2290
+ vint32m1_t index = vmul_vx_i32m1(idxvec.val, 4, 4);
2291
+ // vint32m1_t index_y = vadd_vx_i32m1(index_x, 4, 4);
2292
+
2293
+ // x.val = vlxe_v_f32m1(tab, index_x, 4);
2294
+ // y.val = vlxe_v_f32m1(tab, index_y, 4);
2295
+ vloxseg2ei32_v_f32m1(&x.val, &y.val, tab, vreinterpret_v_i32m1_u32m1(index),
2296
+ 4);
2297
+ }
2298
+
2299
+ inline void v_lut_deinterleave(const double *tab, const v_int32x4 &idxvec,
2300
+ v_float64x2 &x, v_float64x2 &y) {
2301
+ int CV_DECL_ALIGNED(32) idx[4];
2302
+ v_store_aligned(idx, idxvec);
2303
+
2304
+ x = v_float64x2(tab[idx[0]], tab[idx[1]]);
2305
+ y = v_float64x2(tab[idx[0] + 1], tab[idx[1] + 1]);
2306
+ }
2307
+
2308
+ #define OPENCV_HAL_IMPL_RISCVV_PACKS(_Tp, _Tp2, _T2, num2, _T1, num, intrin, \
2309
+ shr, _Type, elemsize) \
2310
+ inline v_##_Tp##x##num v_pack(const v_##_Tp2##x##num2 &a, \
2311
+ const v_##_Tp2##x##num2 &b) { \
2312
+ v##_Tp2##m2_t tmp = vundefined_##_T2##m2(); \
2313
+ tmp = vset_v_##_T2##m1_##_T2##m2(tmp, 0, a.val); \
2314
+ tmp = vset_v_##_T2##m1_##_T2##m2(tmp, 1, b.val); \
2315
+ return v_##_Tp##x##num(shr##_##_T1##m1(tmp, 0, num)); \
2316
+ } \
2317
+ template <int n> \
2318
+ inline v_##_Tp##x##num v_rshr_pack(const v_##_Tp2##x##num2 &a, \
2319
+ const v_##_Tp2##x##num2 &b) { \
2320
+ v##_Tp2##m2_t tmp = vundefined_##_T2##m2(); \
2321
+ tmp = vset_v_##_T2##m1_##_T2##m2(tmp, 0, a.val); \
2322
+ tmp = vset_v_##_T2##m1_##_T2##m2(tmp, 1, b.val); \
2323
+ return v_##_Tp##x##num(intrin##_##_T1##m1(tmp, n, num)); \
2324
+ } \
2325
+ inline void v_pack_store(_Type *ptr, const v_##_Tp2##x##num2 &a) { \
2326
+ v##_Tp2##m2_t tmp = vundefined_##_T2##m2(); \
2327
+ tmp = vset_v_##_T2##m1_##_T2##m2(tmp, 0, a.val); \
2328
+ tmp = vset_v_##_T2##m1_##_T2##m2(tmp, 1, vmv_v_x_##_T2##m1(0, num2)); \
2329
+ asm("" ::: "memory"); \
2330
+ vse##elemsize##_v_##_T1##m1(ptr, shr##_##_T1##m1(tmp, 0, num), num2); \
2331
+ } \
2332
+ template <int n> \
2333
+ inline void v_rshr_pack_store(_Type *ptr, const v_##_Tp2##x##num2 &a) { \
2334
+ v##_Tp2##m2_t tmp = vundefined_##_T2##m2(); \
2335
+ tmp = vset_v_##_T2##m1_##_T2##m2(tmp, 0, a.val); \
2336
+ tmp = vset_v_##_T2##m1_##_T2##m2(tmp, 1, vmv_v_x_##_T2##m1(0, num2)); \
2337
+ vse##elemsize##_v_##_T1##m1(ptr, intrin##_##_T1##m1(tmp, n, num), num2); \
2338
+ }
2339
+ OPENCV_HAL_IMPL_RISCVV_PACKS(int8, int16, i16, 8, i8, 16, vnclip_wx, vnclip_wx,
2340
+ signed char, 8)
2341
+ OPENCV_HAL_IMPL_RISCVV_PACKS(int16, int32, i32, 4, i16, 8, vnclip_wx, vnclip_wx,
2342
+ signed short, 16)
2343
+ OPENCV_HAL_IMPL_RISCVV_PACKS(int32, int64, i64, 2, i32, 4, vnclip_wx, vnsra_wx,
2344
+ int, 32)
2345
+ OPENCV_HAL_IMPL_RISCVV_PACKS(uint8, uint16, u16, 8, u8, 16, vnclipu_wx,
2346
+ vnclipu_wx, unsigned char, 8)
2347
+ OPENCV_HAL_IMPL_RISCVV_PACKS(uint16, uint32, u32, 4, u16, 8, vnclipu_wx,
2348
+ vnclipu_wx, unsigned short, 16)
2349
+ OPENCV_HAL_IMPL_RISCVV_PACKS(uint32, uint64, u64, 2, u32, 4, vnclipu_wx,
2350
+ vnsrl_wx, unsigned int, 32)
2351
+
2352
+ // pack boolean
2353
+ inline v_uint8x16 v_pack_b(const v_uint16x8 &a, const v_uint16x8 &b) {
2354
+ vuint16m2_t tmp = vundefined_u16m2();
2355
+ tmp = vset_v_u16m1_u16m2(tmp, 0, a.val);
2356
+ tmp = vset_v_u16m1_u16m2(tmp, 1, b.val);
2357
+ return v_uint8x16(vnsrl_wx_u8m1(tmp, 0, 16));
2358
+ }
2359
+
2360
+ inline v_uint8x16 v_pack_b(const v_uint32x4 &a, const v_uint32x4 &b,
2361
+ const v_uint32x4 &c, const v_uint32x4 &d) {
2362
+ vuint32m4_t vabcd = vundefined_u32m4();
2363
+ vuint16m2_t v16 = vundefined_u16m2();
2364
+ vabcd = vset_v_u32m1_u32m4(vabcd, 0, a.val);
2365
+ vabcd = vset_v_u32m1_u32m4(vabcd, 1, b.val);
2366
+ vabcd = vset_v_u32m1_u32m4(vabcd, 2, c.val);
2367
+ vabcd = vset_v_u32m1_u32m4(vabcd, 3, d.val);
2368
+ v16 = vnsrl_wx_u16m2(vabcd, 0, 16);
2369
+ return v_uint8x16(vnsrl_wx_u8m1(v16, 0, 16));
2370
+ }
2371
+
2372
+ inline v_uint8x16 v_pack_b(const v_uint64x2 &a, const v_uint64x2 &b,
2373
+ const v_uint64x2 &c, const v_uint64x2 &d,
2374
+ const v_uint64x2 &e, const v_uint64x2 &f,
2375
+ const v_uint64x2 &g, const v_uint64x2 &h) {
2376
+ vuint64m8_t v64 = vundefined_u64m8();
2377
+ vuint32m4_t v32 = vundefined_u32m4();
2378
+ vuint16m2_t v16 = vundefined_u16m2();
2379
+ v64 = vset_v_u64m1_u64m8(v64, 0, a.val);
2380
+ v64 = vset_v_u64m1_u64m8(v64, 1, b.val);
2381
+ v64 = vset_v_u64m1_u64m8(v64, 2, c.val);
2382
+ v64 = vset_v_u64m1_u64m8(v64, 3, d.val);
2383
+ v64 = vset_v_u64m1_u64m8(v64, 4, e.val);
2384
+ v64 = vset_v_u64m1_u64m8(v64, 5, f.val);
2385
+ v64 = vset_v_u64m1_u64m8(v64, 6, g.val);
2386
+ v64 = vset_v_u64m1_u64m8(v64, 7, h.val);
2387
+ v32 = vnsrl_wx_u32m4(v64, 0, 16);
2388
+ v16 = vnsrl_wx_u16m2(v32, 0, 16);
2389
+ return v_uint8x16(vnsrl_wx_u8m1(v16, 0, 16));
2390
+ }
2391
+
2392
+ //inline v_uint8x16 v_pack_u(const v_int16x8& a, const v_int16x8& b) \
2393
+ //{ \
2394
+ // int16xm2_u tmp; \
2395
+ // tmp.m1[0] = (vint16m1_t)a.val; \
2396
+ // tmp.m1[1] = (vint16m1_t)b.val; \
2397
+ // e8xm1_t mask = (e8xm1_t)vmsge_vx_e16xm2_i16m2(tmp.v, 0, 16);\
2398
+ // return v_uint8x16(vnclipuvi_mask_u8m1_u16m2(vmv_v_x_u8m1(0, 16), (vuint16m2_t)tmp.v, 0, mask, 16));
2399
+ //}
2400
+
2401
+ #define OPENCV_HAL_IMPL_RISCVV_PACK_U(tp1, num1, tp2, num2, _Tp) \
2402
+ inline v_uint##tp1##x##num1 v_pack_u(const v_int##tp2##x##num2 &a, \
2403
+ const v_int##tp2##x##num2 &b) { \
2404
+ vint##tp2##m2_t tmp = vundefined_##i##tp2##m2(); \
2405
+ tmp = vset_v_##i##tp2##m1_##i##tp2##m2(tmp, 0, a.val); \
2406
+ tmp = vset_v_##i##tp2##m1_##i##tp2##m2(tmp, 1, b.val); \
2407
+ vint##tp2##m2_t val = vmax_vx_i##tp2##m2(tmp, 0, num1); \
2408
+ return v_uint##tp1##x##num1(vnclipu_wx_u##tp1##m1( \
2409
+ vreinterpret_v_i##tp2##m2_u##tp2##m2(val), 0, num1)); \
2410
+ } \
2411
+ inline void v_pack_u_store(_Tp *ptr, const v_int##tp2##x##num2 &a) { \
2412
+ vint##tp2##m2_t tmp = vundefined_##i##tp2##m2(); \
2413
+ tmp = vset_v_##i##tp2##m1_##i##tp2##m2(tmp, 0, a.val); \
2414
+ vint##tp2##m2_t val = vmax_vx_i##tp2##m2(tmp, 0, num1); \
2415
+ return vse##tp1##_v_u##tp1##m1( \
2416
+ ptr, \
2417
+ vnclipu_wx_u##tp1##m1(vreinterpret_v_i##tp2##m2_u##tp2##m2(val), 0, \
2418
+ num1), \
2419
+ num2); \
2420
+ } \
2421
+ template <int n> \
2422
+ inline v_uint##tp1##x##num1 v_rshr_pack_u(const v_int##tp2##x##num2 &a, \
2423
+ const v_int##tp2##x##num2 &b) { \
2424
+ vint##tp2##m2_t tmp = vundefined_##i##tp2##m2(); \
2425
+ tmp = vset_v_##i##tp2##m1_##i##tp2##m2(tmp, 0, a.val); \
2426
+ tmp = vset_v_##i##tp2##m1_##i##tp2##m2(tmp, 1, b.val); \
2427
+ vint##tp2##m2_t val = vmax_vx_i##tp2##m2(tmp, 0, num1); \
2428
+ return v_uint##tp1##x##num1(vnclipu_wx_u##tp1##m1( \
2429
+ vreinterpret_v_i##tp2##m2_u##tp2##m2(val), n, num1)); \
2430
+ } \
2431
+ template <int n> \
2432
+ inline void v_rshr_pack_u_store(_Tp *ptr, const v_int##tp2##x##num2 &a) { \
2433
+ vint##tp2##m2_t tmp = vundefined_##i##tp2##m2(); \
2434
+ tmp = vset_v_##i##tp2##m1_##i##tp2##m2(tmp, 0, a.val); \
2435
+ vint##tp2##m2_t val_ = vmax_vx_i##tp2##m2(tmp, 0, num1); \
2436
+ vuint##tp1##m1_t val = vnclipu_wx_u##tp1##m1( \
2437
+ vreinterpret_v_i##tp2##m2_u##tp2##m2(val_), n, num1); \
2438
+ return vse##tp1##_v_u##tp1##m1(ptr, val, num2); \
2439
+ }
2440
+ OPENCV_HAL_IMPL_RISCVV_PACK_U(8, 16, 16, 8, unsigned char)
2441
+ OPENCV_HAL_IMPL_RISCVV_PACK_U(16, 8, 32, 4, unsigned short)
2442
+
2443
+ // saturating multiply 8-bit, 16-bit
2444
+ #define OPENCV_HAL_IMPL_RISCVV_MUL_SAT(_Tpvec, num, mul, cvt) \
2445
+ inline _Tpvec v_mul(const _Tpvec &a, const _Tpvec &b) { \
2446
+ auto res = mul(a.val, b.val, num); \
2447
+ return _Tpvec(cvt(res, 0, num)); \
2448
+ }
2449
+
2450
+ OPENCV_HAL_IMPL_RISCVV_MUL_SAT(v_int8x16, 16, vwmul_vv_i16m2, vnclip_wx_i8m1)
2451
+ OPENCV_HAL_IMPL_RISCVV_MUL_SAT(v_uint8x16, 16, vwmulu_vv_u16m2, vnclipu_wx_u8m1)
2452
+ OPENCV_HAL_IMPL_RISCVV_MUL_SAT(v_int16x8, 32, vwmul_vv_i32m2, vnclip_wx_i16m1)
2453
+ OPENCV_HAL_IMPL_RISCVV_MUL_SAT(v_uint16x8, 32, vwmulu_vv_u32m2,
2454
+ vnclipu_wx_u16m1)
2455
+
2456
+ static const signed char popCountTable[256] = {
2457
+ 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4,
2458
+ 2, 3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2459
+ 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 1, 2, 2, 3, 2, 3, 3, 4,
2460
+ 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2461
+ 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6,
2462
+ 4, 5, 5, 6, 5, 6, 6, 7, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2463
+ 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5,
2464
+ 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
2465
+ 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6,
2466
+ 4, 5, 5, 6, 5, 6, 6, 7, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
2467
+ 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8,
2468
+ };
2469
+
2470
+ inline vuint8m1_t vcnt_u8(vuint8m1_t val) {
2471
+ #if __riscv_v == 7000
2472
+ vuint8m1_t v0 = vand_vx_u8m1(val, 1, 16);
2473
+ return vadd_vv_u8m1(vloxei8_v_u8m1((unsigned char *)popCountTable,
2474
+ vsrl_vx_u8m1(val, 1, 16), 16),
2475
+ v0, 16);
2476
+ #else
2477
+ return vloxei8_v_u8m1((unsigned char *)popCountTable, val, 16);
2478
+ #endif
2479
+ }
2480
+
2481
+ inline v_uint8x16 v_popcount(const v_uint8x16 &a) {
2482
+ return v_uint8x16(vcnt_u8(a.val));
2483
+ }
2484
+
2485
+ inline v_uint8x16 v_popcount(const v_int8x16 &a) {
2486
+ return v_uint8x16(vcnt_u8(vreinterpret_v_i8m1_u8m1(a.val)));
2487
+ }
2488
+
2489
+ inline v_uint16x8 v_popcount(const v_uint16x8 &a) {
2490
+ vuint8m1_t tmp = vcnt_u8(vreinterpret_v_u16m1_u8m1(a.val));
2491
+ vuint8m1_t seq = vid_v_u8m1(8);
2492
+ vuint8m1_t index = vsll_vx_u8m1(seq, 1, 8);
2493
+ return v_uint16x8(vget_v_u16m2_u16m1(
2494
+ vwaddu_vv_u16m2(vrgather_vv_u8m1(tmp, index, 8),
2495
+ vrgather_vv_u8m1(tmp, vadd_vx_u8m1(index, 1, 8), 8), 8),
2496
+ 0));
2497
+ }
2498
+
2499
+ inline v_uint16x8 v_popcount(const v_int16x8 &a) {
2500
+ vuint8m1_t tmp =
2501
+ vcnt_u8(vreinterpret_v_i8m1_u8m1(vreinterpret_v_i16m1_i8m1(a.val)));
2502
+ vuint8m1_t seq = vid_v_u8m1(8);
2503
+ vuint8m1_t index = vsll_vx_u8m1(seq, 1, 8);
2504
+ return v_uint16x8(vget_v_u16m2_u16m1(
2505
+ vwaddu_vv_u16m2(vrgather_vv_u8m1(tmp, index, 8),
2506
+ vrgather_vv_u8m1(tmp, vadd_vx_u8m1(index, 1, 8), 8), 8),
2507
+ 0));
2508
+ }
2509
+
2510
+ inline v_uint32x4 v_popcount(const v_uint32x4 &a) {
2511
+ vuint8m1_t tmp = vcnt_u8(vreinterpret_v_u32m1_u8m1(a.val));
2512
+ vuint8m1_t seq = vid_v_u8m1(8);
2513
+ vuint8m1_t index = vsll_vx_u8m1(seq, 1, 8);
2514
+ vuint8m1_t sum =
2515
+ vadd_vv_u8m1(vrgather_vv_u8m1(tmp, index, 8),
2516
+ vrgather_vv_u8m1(tmp, vadd_vx_u8m1(index, 1, 8), 8), 8);
2517
+ return v_uint32x4(vget_v_u32m4_u32m1(
2518
+ vwaddu_vx_u32m4(
2519
+ vwaddu_vv_u16m2(vrgather_vv_u8m1(sum, index, 4),
2520
+ vrgather_vv_u8m1(sum, vadd_vx_u8m1(index, 1, 4), 4),
2521
+ 4),
2522
+ 0, 4),
2523
+ 0));
2524
+ }
2525
+
2526
+ inline v_uint32x4 v_popcount(const v_int32x4 &a) {
2527
+ vuint8m1_t tmp =
2528
+ vcnt_u8(vreinterpret_v_i8m1_u8m1(vreinterpret_v_i32m1_i8m1(a.val)));
2529
+ vuint8m1_t seq = vid_v_u8m1(8);
2530
+ vuint8m1_t index = vsll_vx_u8m1(seq, 1, 8);
2531
+ vuint8m1_t sum =
2532
+ vadd_vv_u8m1(vrgather_vv_u8m1(tmp, index, 8),
2533
+ vrgather_vv_u8m1(tmp, vadd_vx_u8m1(index, 1, 8), 8), 8);
2534
+ return v_uint32x4(vget_v_u32m4_u32m1(
2535
+ vwaddu_vx_u32m4(
2536
+ vwaddu_vv_u16m2(vrgather_vv_u8m1(sum, index, 4),
2537
+ vrgather_vv_u8m1(sum, vadd_vx_u8m1(index, 1, 4), 4),
2538
+ 4),
2539
+ 0, 4),
2540
+ 0));
2541
+ }
2542
+
2543
+ inline v_uint64x2 v_popcount(const v_uint64x2 &a) {
2544
+ vuint8m1_t tmp = vcnt_u8(vreinterpret_v_u64m1_u8m1(a.val));
2545
+ vuint16m2_t tmp16 = vwaddu_vx_u16m2(tmp, 0, 16);
2546
+ vuint16m1_t res1 = vundefined_u16m1();
2547
+ vuint16m1_t res2 = vundefined_u16m1();
2548
+ res1 = vredsum_vs_u16m1_u16m1(res1, vget_v_u16m2_u16m1(tmp16, 0),
2549
+ vmv_v_x_u16m1(0, 8), 8);
2550
+ res2 = vredsum_vs_u16m1_u16m1(res2, vget_v_u16m2_u16m1(tmp16, 1),
2551
+ vmv_v_x_u16m1(0, 8), 8);
2552
+ return v_uint64x2((unsigned long)vmv_x_s_u16m1_u16(res1),
2553
+ (unsigned long)vmv_x_s_u16m1_u16(res2));
2554
+ }
2555
+
2556
+ inline v_uint64x2 v_popcount(const v_int64x2 &a) {
2557
+ vuint8m1_t tmp =
2558
+ vcnt_u8(vreinterpret_v_i8m1_u8m1(vreinterpret_v_i64m1_i8m1(a.val)));
2559
+ vuint16m2_t tmp16 = vwaddu_vx_u16m2(tmp, 0, 16);
2560
+ vuint16m1_t res1 = vundefined_u16m1(), res2 = vundefined_u16m1();
2561
+ res1 = vredsum_vs_u16m1_u16m1(res1, vget_v_u16m2_u16m1(tmp16, 0),
2562
+ vmv_v_x_u16m1(0, 8), 8);
2563
+ res2 = vredsum_vs_u16m1_u16m1(res2, vget_v_u16m2_u16m1(tmp16, 1),
2564
+ vmv_v_x_u16m1(0, 8), 8);
2565
+ return v_uint64x2((unsigned long)vmv_x_s_u16m1_u16(res1),
2566
+ (unsigned long)vmv_x_s_u16m1_u16(res2));
2567
+ }
2568
+
2569
+ #define SMASK 1, 2, 4, 8, 16, 32, 64, 128
2570
+ inline int v_signmask(const v_uint8x16 &a) {
2571
+ vuint16m1_t res = vundefined_u16m1();
2572
+ vuint8m1_t id = vid_v_u8m1(16);
2573
+ vuint16m2_t num =
2574
+ vsll_vv_u16m2(vmv_v_x_u16m2(1, 16), vwaddu_vx_u16m2(id, 0, 16), 16);
2575
+ vuint8m1_t t0 = vsrl_vx_u8m1(a.val, 7, 16);
2576
+ vbool8_t mask = vmseq_vx_u8m1_b8(t0, 1, 16);
2577
+ res = vredsum_vs_u16m2_u16m1_m(mask, res, num, vmv_v_x_u16m1(0, 8), 16);
2578
+ return vmv_x_s_u16m1_u16(res);
2579
+ }
2580
+ inline int v_signmask(const v_int8x16 &a) {
2581
+ vuint16m1_t res = vundefined_u16m1();
2582
+ vuint8m1_t id = vid_v_u8m1(16);
2583
+ vuint16m2_t num =
2584
+ vsll_vv_u16m2(vmv_v_x_u16m2(1, 16), vwaddu_vx_u16m2(id, 0, 16), 16);
2585
+ vbool8_t mask = vmslt_vx_i8m1_b8(a.val, 0, 16);
2586
+ res = vredsum_vs_u16m2_u16m1_m(mask, res, num, vmv_v_x_u16m1(0, 8), 16);
2587
+ return vmv_x_s_u16m1_u16(res);
2588
+ }
2589
+
2590
+ inline int v_signmask(const v_int16x8 &a) {
2591
+ vuint16m1_t res = vundefined_u16m1();
2592
+ vuint16m1_t id = vid_v_u16m1(8);
2593
+ vuint16m1_t num = vsll_vv_u16m1(vmv_v_x_u16m1(1, 8), id, 8);
2594
+ vbool16_t mask = vmslt_vx_i16m1_b16(a.val, 0, 8);
2595
+ res = vredsum_vs_u16m1_u16m1_m(mask, res, num, vmv_v_x_u16m1(0, 8), 16);
2596
+ return vmv_x_s_u16m1_u16(res);
2597
+ }
2598
+ inline int v_signmask(const v_uint16x8 &a) {
2599
+ vuint16m1_t res = vundefined_u16m1();
2600
+ vuint16m1_t id = vid_v_u16m1(8);
2601
+ vuint16m1_t num = vsll_vv_u16m1(vmv_v_x_u16m1(1, 8), id, 8);
2602
+ vuint16m1_t t0 = vsrl_vx_u16m1(a.val, 15, 8);
2603
+ vbool16_t mask = vmseq_vx_u16m1_b16(t0, 1, 8);
2604
+ res = vredsum_vs_u16m1_u16m1_m(mask, res, num, vmv_v_x_u16m1(0, 8), 8);
2605
+ return vmv_x_s_u16m1_u16(res);
2606
+ }
2607
+ inline int v_signmask(const v_int32x4 &a) {
2608
+ vuint32m1_t res = vundefined_u32m1();
2609
+ vuint32m1_t id = vid_v_u32m1(4);
2610
+ vuint32m1_t num = vsll_vv_u32m1(vmv_v_x_u32m1(1, 4), id, 4);
2611
+ vbool32_t mask = vmslt_vx_i32m1_b32(a.val, 0, 4);
2612
+ res = vredsum_vs_u32m1_u32m1_m(mask, res, num, vmv_v_x_u32m1(0, 4), 4);
2613
+ return vmv_x_s_u32m1_u32(res);
2614
+ }
2615
+ inline int v_signmask(const v_uint32x4 &a) {
2616
+ vuint32m1_t res = vundefined_u32m1();
2617
+ vuint32m1_t id = vid_v_u32m1(4);
2618
+ vuint32m1_t num = vsll_vv_u32m1(vmv_v_x_u32m1(1, 4), id, 4);
2619
+ vuint32m1_t t0 = vsrl_vx_u32m1(a.val, 31, 4);
2620
+ vbool32_t mask = vmseq_vx_u32m1_b32(t0, 1, 4);
2621
+ res = vredsum_vs_u32m1_u32m1_m(mask, res, num, vmv_v_x_u32m1(0, 4), 4);
2622
+ return vmv_x_s_u32m1_u32(res);
2623
+ }
2624
+ inline int v_signmask(const v_uint64x2 &a) {
2625
+ vuint64m1_t res = vundefined_u64m1();
2626
+ vuint64m1_t id = vid_v_u64m1(2);
2627
+ vuint64m1_t num = vsll_vv_u64m1(vmv_v_x_u64m1(1, 2), id, 2);
2628
+ vuint64m1_t t0 = vsrl_vx_u64m1(a.val, 63, 2);
2629
+ vbool64_t mask = vmseq_vx_u64m1_b64(t0, 1, 2);
2630
+ res = vredsum_vs_u64m1_u64m1_m(mask, res, num, vmv_v_x_u64m1(0, 2), 2);
2631
+ return vmv_x_s_u64m1_u64(res);
2632
+ }
2633
+ inline int v_signmask(const v_int64x2 &a) {
2634
+ return v_signmask(v_reinterpret_as_u64(a));
2635
+ }
2636
+ inline int v_signmask(const v_float64x2 &a) {
2637
+ return v_signmask(v_reinterpret_as_u64(a));
2638
+ }
2639
+ inline int v_signmask(const v_float32x4 &a) {
2640
+ return v_signmask(v_reinterpret_as_u32(a));
2641
+ /*
2642
+ vuint32m1_t res;
2643
+ vuint32m1_t id = vid_v_u32m1(4);
2644
+ vuint32m1_t num = vsll_vv_u32m1(vmv_v_x_u32m1(1, 4), id, 4);
2645
+ vbool32_t mask = vmflt_vf_f32m1_b32(a.val, 0, 4);
2646
+ res = vredsum_vs_u32m1_u32m1_m(mask, res, num, vmv_v_x_u32m1(0, 4), 4);
2647
+ return vmv_x_s_u32m1_u32(res);*/
2648
+ }
2649
+
2650
+ inline int v_scan_forward(const v_int8x16 &a) {
2651
+ int val = v_signmask(a);
2652
+ if (val == 0)
2653
+ return 0;
2654
+ else
2655
+ return trailingZeros32(val);
2656
+ }
2657
+ inline int v_scan_forward(const v_uint8x16 &a) {
2658
+ int val = v_signmask(a);
2659
+ if (val == 0)
2660
+ return 0;
2661
+ else
2662
+ return trailingZeros32(val);
2663
+ }
2664
+ inline int v_scan_forward(const v_int16x8 &a) {
2665
+ int val = v_signmask(a);
2666
+ if (val == 0)
2667
+ return 0;
2668
+ else
2669
+ return trailingZeros32(val);
2670
+ }
2671
+ inline int v_scan_forward(const v_uint16x8 &a) {
2672
+ int val = v_signmask(a);
2673
+ if (val == 0)
2674
+ return 0;
2675
+ else
2676
+ return trailingZeros32(val);
2677
+ }
2678
+ inline int v_scan_forward(const v_int32x4 &a) {
2679
+ int val = v_signmask(a);
2680
+ if (val == 0)
2681
+ return 0;
2682
+ else
2683
+ return trailingZeros32(val);
2684
+ }
2685
+ inline int v_scan_forward(const v_uint32x4 &a) {
2686
+ int val = v_signmask(a);
2687
+ if (val == 0)
2688
+ return 0;
2689
+ else
2690
+ return trailingZeros32(val);
2691
+ }
2692
+ inline int v_scan_forward(const v_float32x4 &a) {
2693
+ int val = v_signmask(a);
2694
+ if (val == 0)
2695
+ return 0;
2696
+ else
2697
+ return trailingZeros32(val);
2698
+ }
2699
+ inline int v_scan_forward(const v_int64x2 &a) {
2700
+ int val = v_signmask(a);
2701
+ if (val == 0)
2702
+ return 0;
2703
+ else
2704
+ return trailingZeros32(val);
2705
+ }
2706
+ inline int v_scan_forward(const v_uint64x2 &a) {
2707
+ int val = v_signmask(a);
2708
+ if (val == 0)
2709
+ return 0;
2710
+ else
2711
+ return trailingZeros32(val);
2712
+ }
2713
+
2714
+ #define OPENCV_HAL_IMPL_RISCVV_CHECK_ALLANY(_Tpvec, suffix, _T, shift, num, \
2715
+ mask_b) \
2716
+ inline bool v_check_all(const v_##_Tpvec &a) { \
2717
+ suffix##m1_t v0 = vsrl_vx_##_T(vnot_v_##_T(a.val, num), shift, num); \
2718
+ return (vcpop_m_##mask_b(vmseq_vx_##_T##_##mask_b(v0, 1, num), num)) == 0; \
2719
+ } \
2720
+ inline bool v_check_any(const v_##_Tpvec &a) { \
2721
+ suffix##m1_t v0 = vsrl_vx_##_T(a.val, shift, num); \
2722
+ return (vcpop_m_##mask_b(vmseq_vx_##_T##_##mask_b(v0, 1, num), num)) != 0; \
2723
+ }
2724
+
2725
+ OPENCV_HAL_IMPL_RISCVV_CHECK_ALLANY(uint8x16, vuint8, u8m1, 7, 16, b8)
2726
+ OPENCV_HAL_IMPL_RISCVV_CHECK_ALLANY(uint16x8, vuint16, u16m1, 15, 8, b16)
2727
+ OPENCV_HAL_IMPL_RISCVV_CHECK_ALLANY(uint32x4, vuint32, u32m1, 31, 4, b32)
2728
+ OPENCV_HAL_IMPL_RISCVV_CHECK_ALLANY(uint64x2, vuint64, u64m1, 63, 2, b64)
2729
+
2730
+ inline bool v_check_all(const v_int8x16 &a) {
2731
+ return v_check_all(v_reinterpret_as_u8(a));
2732
+ }
2733
+ inline bool v_check_all(const v_int16x8 &a) {
2734
+ return v_check_all(v_reinterpret_as_u16(a));
2735
+ }
2736
+ inline bool v_check_all(const v_int32x4 &a) {
2737
+ return v_check_all(v_reinterpret_as_u32(a));
2738
+ }
2739
+ inline bool v_check_all(const v_float32x4 &a) {
2740
+ return v_check_all(v_reinterpret_as_u32(a));
2741
+ }
2742
+ inline bool v_check_all(const v_int64x2 &a) {
2743
+ return v_check_all(v_reinterpret_as_u64(a));
2744
+ }
2745
+ inline bool v_check_all(const v_float64x2 &a) {
2746
+ return v_check_all(v_reinterpret_as_u64(a));
2747
+ }
2748
+
2749
+ inline bool v_check_any(const v_int8x16 &a) {
2750
+ return v_check_any(v_reinterpret_as_u8(a));
2751
+ }
2752
+ inline bool v_check_any(const v_int16x8 &a) {
2753
+ return v_check_any(v_reinterpret_as_u16(a));
2754
+ }
2755
+ inline bool v_check_any(const v_int32x4 &a) {
2756
+ return v_check_any(v_reinterpret_as_u32(a));
2757
+ }
2758
+ inline bool v_check_any(const v_float32x4 &a) {
2759
+ return v_check_any(v_reinterpret_as_u32(a));
2760
+ }
2761
+ inline bool v_check_any(const v_int64x2 &a) {
2762
+ return v_check_any(v_reinterpret_as_u64(a));
2763
+ }
2764
+ inline bool v_check_any(const v_float64x2 &a) {
2765
+ return v_check_any(v_reinterpret_as_u64(a));
2766
+ }
2767
+
2768
+ #define OPENCV_HAL_IMPL_RISCVV_SELECT(_Tpvec, suffix, _Tpvec2, num, mask_func) \
2769
+ inline _Tpvec v_select(const _Tpvec &mask, const _Tpvec &a, \
2770
+ const _Tpvec &b) { \
2771
+ return _Tpvec( \
2772
+ vmerge_vvm_##suffix(mask_func(mask.val, 0, num), b.val, a.val, num)); \
2773
+ }
2774
+
2775
+ OPENCV_HAL_IMPL_RISCVV_SELECT(v_int8x16, i8m1, vbool8_t, 16, vmsne_vx_i8m1_b8)
2776
+ OPENCV_HAL_IMPL_RISCVV_SELECT(v_int16x8, i16m1, vbool16_t, 8,
2777
+ vmsne_vx_i16m1_b16)
2778
+ OPENCV_HAL_IMPL_RISCVV_SELECT(v_int32x4, i32m1, vbool32_t, 4,
2779
+ vmsne_vx_i32m1_b32)
2780
+ OPENCV_HAL_IMPL_RISCVV_SELECT(v_uint8x16, u8m1, vbool8_t, 16, vmsne_vx_u8m1_b8)
2781
+ OPENCV_HAL_IMPL_RISCVV_SELECT(v_uint16x8, u16m1, vbool16_t, 8,
2782
+ vmsne_vx_u16m1_b16)
2783
+ OPENCV_HAL_IMPL_RISCVV_SELECT(v_uint32x4, u32m1, vbool32_t, 4,
2784
+ vmsne_vx_u32m1_b32)
2785
+ inline v_float32x4 v_select(const v_float32x4 &mask, const v_float32x4 &a,
2786
+ const v_float32x4 &b) {
2787
+ return v_float32x4(
2788
+ vmerge_vvm_f32m1(vmfne_vf_f32m1_b32(mask.val, 0, 4), b.val, a.val, 4));
2789
+ }
2790
+ inline v_float64x2 v_select(const v_float64x2 &mask, const v_float64x2 &a,
2791
+ const v_float64x2 &b) {
2792
+ return v_float64x2(
2793
+ vmerge_vvm_f64m1(vmfne_vf_f64m1_b64(mask.val, 0, 2), b.val, a.val, 2));
2794
+ }
2795
+
2796
+ #define OPENCV_HAL_IMPL_RISCVV_EXPAND(add, _Tpvec, _Tpwvec, _Tp, _Tp1, num1, \
2797
+ _Tp2, num2, _T1, _T2, num3) \
2798
+ inline void v_expand(const _Tpvec &a, v_##_Tpwvec &b0, v_##_Tpwvec &b1) { \
2799
+ _T1##_t b = vw##add##_vx_##_Tp2##m2(a.val, 0, num1); \
2800
+ b0.val = vget_v_##_Tp2##m2_##_Tp2##m1(b, 0); \
2801
+ b1.val = vget_v_##_Tp2##m2_##_Tp2##m1(b, 1); \
2802
+ } \
2803
+ inline v_##_Tpwvec v_expand_low(const _Tpvec &a) { \
2804
+ _T1##_t b = vw##add##_vx_##_Tp2##m2(a.val, 0, num2); \
2805
+ return v_##_Tpwvec(vget_v_##_Tp2##m2_##_Tp2##m1(b, 0)); \
2806
+ } \
2807
+ inline v_##_Tpwvec v_expand_high(const _Tpvec &a) { \
2808
+ _T1##_t b = vw##add##_vx_##_Tp2##m2(a.val, 0, num1); \
2809
+ return v_##_Tpwvec(vget_v_##_Tp2##m2_##_Tp2##m1(b, 1)); \
2810
+ } \
2811
+ inline v_##_Tpwvec v_load_expand(const _Tp *ptr) { \
2812
+ _T2##_t val = vle##num3##_v_##_Tp1(ptr, num2); \
2813
+ _T1##_t b = vw##add##_vx_##_Tp2##m2(val, 0, num2); \
2814
+ return v_##_Tpwvec(vget_v_##_Tp2##m2_##_Tp2##m1(b, 0)); \
2815
+ }
2816
+
2817
+ OPENCV_HAL_IMPL_RISCVV_EXPAND(addu, v_uint8x16, uint16x8, uchar, u8m1, 16, u16,
2818
+ 8, vuint16m2, vuint8m1, 8)
2819
+ OPENCV_HAL_IMPL_RISCVV_EXPAND(addu, v_uint16x8, uint32x4, ushort, u16m1, 8, u32,
2820
+ 4, vuint32m2, vuint16m1, 16)
2821
+ OPENCV_HAL_IMPL_RISCVV_EXPAND(addu, v_uint32x4, uint64x2, uint, u32m1, 4, u64,
2822
+ 2, vuint64m2, vuint32m1, 32)
2823
+ OPENCV_HAL_IMPL_RISCVV_EXPAND(add, v_int8x16, int16x8, schar, i8m1, 16, i16, 8,
2824
+ vint16m2, vint8m1, 8)
2825
+ OPENCV_HAL_IMPL_RISCVV_EXPAND(add, v_int16x8, int32x4, short, i16m1, 8, i32, 4,
2826
+ vint32m2, vint16m1, 16)
2827
+ OPENCV_HAL_IMPL_RISCVV_EXPAND(add, v_int32x4, int64x2, int, i32m1, 4, i64, 2,
2828
+ vint64m2, vint32m1, 32)
2829
+
2830
+ inline v_uint32x4 v_load_expand_q(const uchar *ptr) {
2831
+ vuint16m2_t b = vundefined_u16m2();
2832
+ vuint32m2_t c = vundefined_u32m2();
2833
+ vuint8m1_t val = vle8_v_u8m1(ptr, 4);
2834
+ b = vwaddu_vv_u16m2(val, vmv_v_x_u8m1(0, 4), 4);
2835
+ c = vwaddu_vv_u32m2(vget_v_u16m2_u16m1(b, 0), vmv_v_x_u16m1(0, 4), 4);
2836
+ return v_uint32x4(vget_v_u32m2_u32m1(c, 0));
2837
+ }
2838
+
2839
+ inline v_int32x4 v_load_expand_q(const schar *ptr) {
2840
+ vint16m2_t b = vundefined_i16m2();
2841
+ vint32m2_t c = vundefined_i32m2();
2842
+ vint8m1_t val = vle8_v_i8m1(ptr, 4);
2843
+ b = vwadd_vv_i16m2(val, vmv_v_x_i8m1(0, 4), 4);
2844
+ c = vwadd_vv_i32m2(vget_v_i16m2_i16m1(b, 0), vmv_v_x_i16m1(0, 4), 4);
2845
+ return v_int32x4(vget_v_i32m2_i32m1(c, 0));
2846
+ }
2847
+ #define VITL_16 \
2848
+ {0x11011000, 0x13031202, 0x15051404, 0x17071606, \
2849
+ 0x19091808, 0x1B0B1A0A, 0x1D0D1C0C, 0x1F0F1E0E}
2850
+ #define VITL_8 \
2851
+ {0x00080000, 0x00090001, 0x000A0002, 0x000B0003, \
2852
+ 0x000C0004, 0x000D0005, 0x000E0006, 0x000F0007}
2853
+ #define VITL_4 \
2854
+ {0x00000000, 0x00000004, 0x00000001, 0x00000005, \
2855
+ 0x00000002, 0x00000006, 0x00000003, 0x00000007}
2856
+ #define VITL_2 {0, 0, 2, 0, 1, 0, 3, 0}
2857
+
2858
+ #define OPENCV_HAL_IMPL_RISCVV_UNPACKS(_Tpvec, _Tp, _T, _UTp, _UT, num, num2, \
2859
+ len, numh, refunc) \
2860
+ inline void v_zip(const v_##_Tpvec &a0, const v_##_Tpvec &a1, \
2861
+ v_##_Tpvec &b0, v_##_Tpvec &b1) { \
2862
+ v##_Tp##m2_t tmp = vundefined_##_T##m2(); \
2863
+ tmp = vset_v_##_T##m1_##_T##m2(tmp, 0, a0.val); \
2864
+ tmp = vset_v_##_T##m1_##_T##m2(tmp, 1, a1.val); \
2865
+ unsigned mdata[] = VITL_##num; \
2866
+ vuint32m2_t mask = vle32_v_u32m2(mdata, 8); \
2867
+ tmp = (v##_Tp##m2_t)vrgather_vv_##_T##m2((v##_Tp##m2_t)tmp, refunc(mask), \
2868
+ num2); \
2869
+ b0.val = vget_v_##_T##m2_##_T##m1(tmp, 0); \
2870
+ b1.val = vget_v_##_T##m2_##_T##m1(tmp, 1); \
2871
+ } \
2872
+ inline v_##_Tpvec v_combine_low(const v_##_Tpvec &a, const v_##_Tpvec &b) { \
2873
+ v##_Tp##m1_t b0 = \
2874
+ vslideup_vx_##_T##m1_m(vmset_m_##len(num), a.val, b.val, numh, num); \
2875
+ return v_##_Tpvec(b0); \
2876
+ } \
2877
+ inline v_##_Tpvec v_combine_high(const v_##_Tpvec &a, const v_##_Tpvec &b) { \
2878
+ v##_Tp##m1_t b0 = vundefined_##_T##m1(); \
2879
+ v##_Tp##m1_t a0 = vundefined_##_T##m1(); \
2880
+ v##_Tp##m1_t b1 = vundefined_##_T##m1(); \
2881
+ b0 = vslidedown_vx_##_T##m1(b0, b.val, numh, num); \
2882
+ a0 = vslidedown_vx_##_T##m1(a0, a.val, numh, num); \
2883
+ b1 = vslideup_vx_##_T##m1_m(vmset_m_##len(num), a0, b0, numh, num); \
2884
+ return v_##_Tpvec(b1); \
2885
+ } \
2886
+ inline void v_recombine(const v_##_Tpvec &a, const v_##_Tpvec &b, \
2887
+ v_##_Tpvec &c, v_##_Tpvec &d) { \
2888
+ v##_Tp##m1_t b0 = vundefined_##_T##m1(); \
2889
+ v##_Tp##m1_t a0 = vundefined_##_T##m1(); \
2890
+ c.val = \
2891
+ vslideup_vx_##_T##m1_m(vmset_m_##len(num), a.val, b.val, numh, num); \
2892
+ b0 = vslidedown_vx_##_T##m1(b0, b.val, numh, num); \
2893
+ a0 = vslidedown_vx_##_T##m1(a0, a.val, numh, num); \
2894
+ d.val = vslideup_vx_##_T##m1_m(vmset_m_##len(num), a0, b0, numh, num); \
2895
+ }
2896
+
2897
+ OPENCV_HAL_IMPL_RISCVV_UNPACKS(uint8x16, uint8, u8, uint8, u8, 16, 32, b8, 8,
2898
+ vreinterpret_v_u32m2_u8m2)
2899
+ OPENCV_HAL_IMPL_RISCVV_UNPACKS(int8x16, int8, i8, uint8, u8, 16, 32, b8, 8,
2900
+ vreinterpret_v_u32m2_u8m2)
2901
+ OPENCV_HAL_IMPL_RISCVV_UNPACKS(uint16x8, uint16, u16, uint16, u16, 8, 16, b16,
2902
+ 4, vreinterpret_v_u32m2_u16m2)
2903
+ OPENCV_HAL_IMPL_RISCVV_UNPACKS(int16x8, int16, i16, uint16, u16, 8, 16, b16, 4,
2904
+ vreinterpret_v_u32m2_u16m2)
2905
+ OPENCV_HAL_IMPL_RISCVV_UNPACKS(uint32x4, uint32, u32, uint32, u32, 4, 8, b32,
2906
+ 2, )
2907
+ OPENCV_HAL_IMPL_RISCVV_UNPACKS(int32x4, int32, i32, uint32, u32, 4, 8, b32, 2, )
2908
+ OPENCV_HAL_IMPL_RISCVV_UNPACKS(float32x4, float32, f32, uint32, u32, 4, 8, b32,
2909
+ 2, )
2910
+ OPENCV_HAL_IMPL_RISCVV_UNPACKS(float64x2, float64, f64, uint64, u64, 2, 4, b64,
2911
+ 1, vreinterpret_v_u32m2_u64m2)
2912
+
2913
+ inline v_uint8x16 v_reverse(const v_uint8x16 &a) {
2914
+ return v_uint8x16(
2915
+ vrgather_vv_u8m1(a.val, vrsub_vx_u8m1(vid_v_u8m1(16), 15, 16), 16));
2916
+ }
2917
+ inline v_int8x16 v_reverse(const v_int8x16 &a) {
2918
+ return v_int8x16(
2919
+ vrgather_vv_i8m1(a.val, vrsub_vx_u8m1(vid_v_u8m1(16), 15, 16), 16));
2920
+ }
2921
+
2922
+ inline v_uint16x8 v_reverse(const v_uint16x8 &a) {
2923
+ return v_uint16x8(
2924
+ vrgather_vv_u16m1(a.val, vrsub_vx_u16m1(vid_v_u16m1(8), 7, 8), 8));
2925
+ }
2926
+
2927
+ inline v_int16x8 v_reverse(const v_int16x8 &a) {
2928
+ return v_int16x8(
2929
+ vrgather_vv_i16m1(a.val, vrsub_vx_u16m1(vid_v_u16m1(8), 7, 8), 8));
2930
+ }
2931
+ inline v_uint32x4 v_reverse(const v_uint32x4 &a) {
2932
+ return v_uint32x4(
2933
+ vrgather_vv_u32m1(a.val, vrsub_vx_u32m1(vid_v_u32m1(4), 3, 4), 4));
2934
+ }
2935
+
2936
+ inline v_int32x4 v_reverse(const v_int32x4 &a) {
2937
+ return v_int32x4(
2938
+ vrgather_vv_i32m1(a.val, vrsub_vx_u32m1(vid_v_u32m1(4), 3, 4), 4));
2939
+ }
2940
+
2941
+ inline v_float32x4 v_reverse(const v_float32x4 &a) {
2942
+ return v_reinterpret_as_f32(v_reverse(v_reinterpret_as_u32(a)));
2943
+ }
2944
+
2945
+ inline v_uint64x2 v_reverse(const v_uint64x2 &a) {
2946
+ return v_uint64x2(
2947
+ vrgather_vv_u64m1(a.val, vrsub_vx_u64m1(vid_v_u64m1(2), 1, 2), 2));
2948
+ }
2949
+
2950
+ inline v_int64x2 v_reverse(const v_int64x2 &a) {
2951
+ return v_int64x2(
2952
+ vrgather_vv_i64m1(a.val, vrsub_vx_u64m1(vid_v_u64m1(2), 1, 2), 2));
2953
+ }
2954
+
2955
+ inline v_float64x2 v_reverse(const v_float64x2 &a) {
2956
+ return v_float64x2(
2957
+ vrgather_vv_f64m1(a.val, vrsub_vx_u64m1(vid_v_u64m1(2), 1, 2), 2));
2958
+ }
2959
+
2960
+ #define OPENCV_HAL_IMPL_RISCVV_EXTRACT(_Tpvec, suffix, size) \
2961
+ template <int n> inline _Tpvec v_extract(const _Tpvec &a, const _Tpvec &b) { \
2962
+ return v_rotate_right<n>(a, b); \
2963
+ }
2964
+ OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_uint8x16, u8, 0)
2965
+ OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_int8x16, s8, 0)
2966
+ OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_uint16x8, u16, 1)
2967
+ OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_int16x8, s16, 1)
2968
+ OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_uint32x4, u32, 2)
2969
+ OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_int32x4, s32, 2)
2970
+ OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_uint64x2, u64, 3)
2971
+ OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_int64x2, s64, 3)
2972
+ OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_float32x4, f32, 2)
2973
+ OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_float64x2, f64, 3)
2974
+
2975
+ #define OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(_Tpvec, _Tp, suffix, vtype, _vtype, \
2976
+ num, mvfunc) \
2977
+ template <int i> inline _Tp v_extract_n(_Tpvec v) { \
2978
+ vtype tmp = vundefined_##_vtype(); \
2979
+ return mvfunc(vslidedown_vx_##_vtype(tmp, v.val, i, num)); \
2980
+ }
2981
+
2982
+ OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_uint8x16, uchar, u8, vuint8m1_t, u8m1, 16,
2983
+ vmv_x_s_u8m1_u8)
2984
+ OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_int8x16, schar, s8, vint8m1_t, i8m1, 16,
2985
+ vmv_x_s_i8m1_i8)
2986
+ OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_uint16x8, ushort, u16, vuint16m1_t, u16m1, 8,
2987
+ vmv_x_s_u16m1_u16)
2988
+ OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_int16x8, short, s16, vint16m1_t, i16m1, 8,
2989
+ vmv_x_s_i16m1_i16)
2990
+ OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_uint32x4, uint, u32, vuint32m1_t, u32m1, 4,
2991
+ vmv_x_s_u32m1_u32)
2992
+ OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_int32x4, int, s32, vint32m1_t, i32m1, 4,
2993
+ vmv_x_s_i32m1_i32)
2994
+ OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_uint64x2, uint64, u64, vuint64m1_t, u64m1, 2,
2995
+ vmv_x_s_u64m1_u64)
2996
+ OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_int64x2, int64, s64, vint64m1_t, i64m1, 2,
2997
+ vmv_x_s_i64m1_i64)
2998
+ OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_float32x4, float, f32, vfloat32m1_t, f32m1,
2999
+ 4, vfmv_f_s_f32m1_f32)
3000
+ OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_float64x2, double, f64, vfloat64m1_t, f64m1,
3001
+ 2, vfmv_f_s_f64m1_f64)
3002
+
3003
+ #define OPENCV_HAL_IMPL_RISCVV_BROADCAST(_Tpvec, _Tp, num) \
3004
+ template <int i> inline _Tpvec v_broadcast_element(_Tpvec v) { \
3005
+ return _Tpvec(vrgather_vx_##_Tp##m1(v.val, i, num)); \
3006
+ }
3007
+
3008
+ OPENCV_HAL_IMPL_RISCVV_BROADCAST(v_uint8x16, u8, 16)
3009
+ OPENCV_HAL_IMPL_RISCVV_BROADCAST(v_int8x16, i8, 16)
3010
+ OPENCV_HAL_IMPL_RISCVV_BROADCAST(v_uint16x8, u16, 8)
3011
+ OPENCV_HAL_IMPL_RISCVV_BROADCAST(v_int16x8, i16, 8)
3012
+ OPENCV_HAL_IMPL_RISCVV_BROADCAST(v_uint32x4, u32, 4)
3013
+ OPENCV_HAL_IMPL_RISCVV_BROADCAST(v_int32x4, i32, 4)
3014
+ OPENCV_HAL_IMPL_RISCVV_BROADCAST(v_uint64x2, u64, 2)
3015
+ OPENCV_HAL_IMPL_RISCVV_BROADCAST(v_int64x2, i64, 2)
3016
+ OPENCV_HAL_IMPL_RISCVV_BROADCAST(v_float32x4, f32, 4)
3017
+
3018
+ inline void __builtin_riscv_fsrm(int val) {
3019
+ asm("csrw frm, %0\n\t" : : "r"(val));
3020
+ return;
3021
+ }
3022
+
3023
+ inline void barrier1(void *arg) {
3024
+ __asm__ __volatile__("" : : "r"(arg) : "memory");
3025
+ }
3026
+
3027
+ inline v_int32x4 v_round(const v_float32x4 &a) {
3028
+ __builtin_riscv_fsrm(0);
3029
+ vint32m1_t nan =
3030
+ vand_vx_i32m1(vreinterpret_v_f32m1_i32m1(a.val), 0x7f800000, 4);
3031
+ barrier1(&nan);
3032
+ vbool32_t mask = vmsne_vx_i32m1_b32(nan, 0x7f800000, 4);
3033
+ vint32m1_t val = vfcvt_x_f_v_i32m1_m(mask, vmv_v_x_i32m1(0, 4), a.val, 4);
3034
+ __builtin_riscv_fsrm(0);
3035
+ return v_int32x4(val);
3036
+ }
3037
+ inline v_int32x4 v_floor(const v_float32x4 &a) {
3038
+ __builtin_riscv_fsrm(2);
3039
+ vint32m1_t nan =
3040
+ vand_vx_i32m1(vreinterpret_v_f32m1_i32m1(a.val), 0x7f800000, 4);
3041
+ barrier1(&nan);
3042
+ vbool32_t mask = vmsne_vx_i32m1_b32(nan, 0x7f800000, 4);
3043
+ vint32m1_t val = vfcvt_x_f_v_i32m1_m(mask, vmv_v_x_i32m1(0, 4), a.val, 4);
3044
+ __builtin_riscv_fsrm(0);
3045
+ return v_int32x4(val);
3046
+ }
3047
+
3048
+ inline v_int32x4 v_ceil(const v_float32x4 &a) {
3049
+ __builtin_riscv_fsrm(3);
3050
+ vint32m1_t nan =
3051
+ vand_vx_i32m1(vreinterpret_v_f32m1_i32m1(a.val), 0x7f800000, 4);
3052
+ barrier1(&nan);
3053
+ vbool32_t mask = vmsne_vx_i32m1_b32(nan, 0x7f800000, 4);
3054
+ vint32m1_t val = vfcvt_x_f_v_i32m1_m(mask, vmv_v_x_i32m1(0, 4), a.val, 4);
3055
+ __builtin_riscv_fsrm(0);
3056
+ return v_int32x4(val);
3057
+ }
3058
+
3059
+ inline v_int32x4 v_trunc(const v_float32x4 &a) {
3060
+ __builtin_riscv_fsrm(1);
3061
+ vint32m1_t nan =
3062
+ vand_vx_i32m1(vreinterpret_v_f32m1_i32m1(a.val), 0x7f800000, 4);
3063
+ barrier1(&nan);
3064
+ vbool32_t mask = vmsne_vx_i32m1_b32(nan, 0x7f800000, 4);
3065
+ vint32m1_t val = vfcvt_x_f_v_i32m1_m(mask, vmv_v_x_i32m1(0, 4), a.val, 4);
3066
+ __builtin_riscv_fsrm(0);
3067
+ return v_int32x4(val);
3068
+ }
3069
+
3070
+ inline v_int32x4 v_round(const v_float64x2 &a) {
3071
+ __builtin_riscv_fsrm(0);
3072
+ vfloat64m2_t _val = vundefined_f64m2();
3073
+ _val = vset_v_f64m1_f64m2(_val, 0, a.val);
3074
+ //_val = vset_f64m2(_val, 1, a.val);
3075
+ _val = vset_v_f64m1_f64m2(_val, 1, vfmv_v_f_f64m1(0, 2));
3076
+ barrier1(&_val);
3077
+ vint32m1_t val = vfncvt_x_f_w_i32m1(_val, 4);
3078
+ __builtin_riscv_fsrm(0);
3079
+ return v_int32x4(val);
3080
+ }
3081
+ inline v_int32x4 v_round(const v_float64x2 &a, const v_float64x2 &b) {
3082
+ __builtin_riscv_fsrm(0);
3083
+ vfloat64m2_t _val = vundefined_f64m2();
3084
+ _val = vset_v_f64m1_f64m2(_val, 0, a.val);
3085
+ _val = vset_v_f64m1_f64m2(_val, 1, b.val);
3086
+ barrier1(&_val);
3087
+ vint32m1_t val = vfncvt_x_f_w_i32m1(_val, 4);
3088
+ __builtin_riscv_fsrm(0);
3089
+ return v_int32x4(val);
3090
+ }
3091
+ inline v_int32x4 v_floor(const v_float64x2 &a) {
3092
+ __builtin_riscv_fsrm(2);
3093
+ vfloat64m2_t _val = vundefined_f64m2();
3094
+ _val = vset_v_f64m1_f64m2(_val, 0, a.val);
3095
+ vfloat32m1_t aval = vfncvt_f_f_w_f32m1(_val, 2);
3096
+ vint32m1_t nan =
3097
+ vand_vx_i32m1(vreinterpret_v_f32m1_i32m1(aval), 0x7f800000, 4);
3098
+ barrier1(&nan);
3099
+ vbool32_t mask = vmsne_vx_i32m1_b32(nan, 0x7f800000, 4);
3100
+ vint32m1_t val = vfcvt_x_f_v_i32m1_m(mask, vmv_v_x_i32m1(0, 4), aval, 4);
3101
+ __builtin_riscv_fsrm(0);
3102
+ return v_int32x4(val);
3103
+ }
3104
+
3105
+ inline v_int32x4 v_ceil(const v_float64x2 &a) {
3106
+ __builtin_riscv_fsrm(3);
3107
+ vfloat64m2_t _val = vundefined_f64m2();
3108
+ _val = vset_v_f64m1_f64m2(_val, 0, a.val);
3109
+ vfloat32m1_t aval = vfncvt_f_f_w_f32m1(_val, 2);
3110
+ vint32m1_t nan =
3111
+ vand_vx_i32m1(vreinterpret_v_f32m1_i32m1(aval), 0x7f800000, 4);
3112
+ barrier1(&nan);
3113
+ vbool32_t mask = vmsne_vx_i32m1_b32(nan, 0x7f800000, 4);
3114
+ vint32m1_t val = vfcvt_x_f_v_i32m1_m(mask, vmv_v_x_i32m1(0, 4), aval, 4);
3115
+ __builtin_riscv_fsrm(0);
3116
+ return v_int32x4(val);
3117
+ }
3118
+
3119
+ inline v_int32x4 v_trunc(const v_float64x2 &a) {
3120
+ __builtin_riscv_fsrm(1);
3121
+ vfloat64m2_t _val = vundefined_f64m2();
3122
+ _val = vset_v_f64m1_f64m2(_val, 0, a.val);
3123
+ vfloat32m1_t aval = vfncvt_f_f_w_f32m1(_val, 2);
3124
+ vint32m1_t nan =
3125
+ vand_vx_i32m1(vreinterpret_v_f32m1_i32m1(aval), 0x7f800000, 4);
3126
+ barrier1(&nan);
3127
+ vbool32_t mask = vmsne_vx_i32m1_b32(nan, 0x7f800000, 4);
3128
+ vint32m1_t val = vfcvt_x_f_v_i32m1_m(mask, vmv_v_x_i32m1(0, 4), aval, 4);
3129
+ __builtin_riscv_fsrm(0);
3130
+ return v_int32x4(val);
3131
+ }
3132
+
3133
+ #define OPENCV_HAL_IMPL_RISCVV_LOAD_DEINTERLEAVED(intrin, _Tpvec, num, _Tp, \
3134
+ _T, elemsize) \
3135
+ inline void v_load_deinterleave(const _Tp *ptr, v_##_Tpvec##x##num &a, \
3136
+ v_##_Tpvec##x##num &b) { \
3137
+ intrin##2e##elemsize##_v_##_T##m1(&a.val, &b.val, ptr, num); \
3138
+ } \
3139
+ inline void v_load_deinterleave(const _Tp *ptr, v_##_Tpvec##x##num &a, \
3140
+ v_##_Tpvec##x##num &b, \
3141
+ v_##_Tpvec##x##num &c) { \
3142
+ intrin##3e##elemsize##_v_##_T##m1(&a.val, &b.val, &c.val, ptr, num); \
3143
+ } \
3144
+ inline void v_load_deinterleave( \
3145
+ const _Tp *ptr, v_##_Tpvec##x##num &a, v_##_Tpvec##x##num &b, \
3146
+ v_##_Tpvec##x##num &c, v_##_Tpvec##x##num &d) { \
3147
+ intrin##4e##elemsize##_v_##_T##m1(&a.val, &b.val, &c.val, &d.val, ptr, \
3148
+ num); \
3149
+ }
3150
+
3151
+ #define OPENCV_HAL_IMPL_RISCVV_STORE_INTERLEAVED(intrin, _Tpvec, num, _Tp, _T, \
3152
+ elemsize) \
3153
+ inline void v_store_interleave( \
3154
+ _Tp *ptr, const v_##_Tpvec##x##num &a, const v_##_Tpvec##x##num &b, \
3155
+ hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) { \
3156
+ intrin##2e##elemsize##_v_##_T##m1(ptr, a.val, b.val, num); \
3157
+ } \
3158
+ inline void v_store_interleave( \
3159
+ _Tp *ptr, const v_##_Tpvec##x##num &a, const v_##_Tpvec##x##num &b, \
3160
+ const v_##_Tpvec##x##num &c, \
3161
+ hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) { \
3162
+ intrin##3e##elemsize##_v_##_T##m1(ptr, a.val, b.val, c.val, num); \
3163
+ } \
3164
+ inline void v_store_interleave( \
3165
+ _Tp *ptr, const v_##_Tpvec##x##num &a, const v_##_Tpvec##x##num &b, \
3166
+ const v_##_Tpvec##x##num &c, const v_##_Tpvec##x##num &d, \
3167
+ hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) { \
3168
+ intrin##4e##elemsize##_v_##_T##m1(ptr, a.val, b.val, c.val, d.val, num); \
3169
+ }
3170
+
3171
+ #define OPENCV_HAL_IMPL_RISCVV_INTERLEAVED(_Tpvec, _Tp, num, ld, st, _T, \
3172
+ elemsize) \
3173
+ OPENCV_HAL_IMPL_RISCVV_LOAD_DEINTERLEAVED(ld, _Tpvec, num, _Tp, _T, \
3174
+ elemsize) \
3175
+ OPENCV_HAL_IMPL_RISCVV_STORE_INTERLEAVED(st, _Tpvec, num, _Tp, _T, elemsize)
3176
+
3177
+ // OPENCV_HAL_IMPL_RISCVV_INTERLEAVED(uint8, uchar, )
3178
+ OPENCV_HAL_IMPL_RISCVV_INTERLEAVED(int8, schar, 16, vlseg, vsseg, i8, 8)
3179
+ OPENCV_HAL_IMPL_RISCVV_INTERLEAVED(int16, short, 8, vlseg, vsseg, i16, 16)
3180
+ OPENCV_HAL_IMPL_RISCVV_INTERLEAVED(int32, int, 4, vlseg, vsseg, i32, 32)
3181
+
3182
+ OPENCV_HAL_IMPL_RISCVV_INTERLEAVED(uint8, unsigned char, 16, vlseg, vsseg, u8,
3183
+ 8)
3184
+ OPENCV_HAL_IMPL_RISCVV_INTERLEAVED(uint16, unsigned short, 8, vlseg, vsseg, u16,
3185
+ 16)
3186
+ OPENCV_HAL_IMPL_RISCVV_INTERLEAVED(uint32, unsigned int, 4, vlseg, vsseg, u32,
3187
+ 32)
3188
+
3189
+ #define OPENCV_HAL_IMPL_RISCVV_INTERLEAVED_(_Tpvec, _Tp, num, _T, _esize) \
3190
+ inline void v_load_deinterleave(const _Tp *ptr, v_##_Tpvec##x##num &a, \
3191
+ v_##_Tpvec##x##num &b) { \
3192
+ vlseg2e##_esize##_v_##_T##m1(&a.val, &b.val, ptr, num); \
3193
+ } \
3194
+ inline void v_load_deinterleave(const _Tp *ptr, v_##_Tpvec##x##num &a, \
3195
+ v_##_Tpvec##x##num &b, \
3196
+ v_##_Tpvec##x##num &c) { \
3197
+ vlseg3e##_esize##_v_##_T##m1(&a.val, &b.val, &c.val, ptr, num); \
3198
+ } \
3199
+ inline void v_load_deinterleave( \
3200
+ const _Tp *ptr, v_##_Tpvec##x##num &a, v_##_Tpvec##x##num &b, \
3201
+ v_##_Tpvec##x##num &c, v_##_Tpvec##x##num &d) { \
3202
+ vlseg4e##_esize##_v_##_T##m1(&a.val, &b.val, &c.val, &d.val, ptr, num); \
3203
+ } \
3204
+ inline void v_store_interleave( \
3205
+ _Tp *ptr, const v_##_Tpvec##x##num &a, const v_##_Tpvec##x##num &b, \
3206
+ hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) { \
3207
+ vsseg2e##_esize##_v_##_T##m1(ptr, a.val, b.val, num); \
3208
+ } \
3209
+ inline void v_store_interleave( \
3210
+ _Tp *ptr, const v_##_Tpvec##x##num &a, const v_##_Tpvec##x##num &b, \
3211
+ const v_##_Tpvec##x##num &c, \
3212
+ hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) { \
3213
+ vsseg3e##_esize##_v_##_T##m1(ptr, a.val, b.val, c.val, num); \
3214
+ } \
3215
+ inline void v_store_interleave( \
3216
+ _Tp *ptr, const v_##_Tpvec##x##num &a, const v_##_Tpvec##x##num &b, \
3217
+ const v_##_Tpvec##x##num &c, const v_##_Tpvec##x##num &d, \
3218
+ hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) { \
3219
+ vsseg4e##_esize##_v_##_T##m1(ptr, a.val, b.val, c.val, d.val, num); \
3220
+ }
3221
+
3222
+ OPENCV_HAL_IMPL_RISCVV_INTERLEAVED_(float32, float, 4, f32, 32)
3223
+ OPENCV_HAL_IMPL_RISCVV_INTERLEAVED_(float64, double, 2, f64, 64)
3224
+
3225
+ OPENCV_HAL_IMPL_RISCVV_INTERLEAVED_(uint64, unsigned long, 2, u64, 64)
3226
+ OPENCV_HAL_IMPL_RISCVV_INTERLEAVED_(int64, long, 2, i64, 64)
3227
+
3228
+ inline v_float32x4 v_cvt_f32(const v_int32x4 &a) {
3229
+ return v_float32x4(vfcvt_f_x_v_f32m1(a.val, 4));
3230
+ }
3231
+
3232
+ #if CV_SIMD128_64F
3233
+ inline v_float32x4 v_cvt_f32(const v_float64x2 &a) {
3234
+ vfloat64m2_t _val = vundefined_f64m2();
3235
+ _val = vset_v_f64m1_f64m2(_val, 0, a.val);
3236
+ vfloat32m1_t aval = vfncvt_f_f_w_f32m1(_val, 2);
3237
+ return v_float32x4(aval);
3238
+ }
3239
+
3240
+ inline v_float32x4 v_cvt_f32(const v_float64x2 &a, const v_float64x2 &b) {
3241
+ vfloat64m2_t _val = vundefined_f64m2();
3242
+ _val = vset_v_f64m1_f64m2(_val, 0, a.val);
3243
+ _val = vset_v_f64m1_f64m2(_val, 1, b.val);
3244
+ vfloat32m1_t aval = vfncvt_f_f_w_f32m1(_val, 4);
3245
+ return v_float32x4(aval);
3246
+ }
3247
+
3248
+ inline v_float64x2 v_cvt_f64(const v_int32x4 &a) {
3249
+ vfloat32m1_t val = vfcvt_f_x_v_f32m1(a.val, 4);
3250
+ vfloat64m2_t _val = vfwcvt_f_f_v_f64m2(val, 4);
3251
+ return v_float64x2(vget_v_f64m2_f64m1(_val, 0));
3252
+ }
3253
+
3254
+ inline v_float64x2 v_cvt_f64_high(const v_int32x4 &a) {
3255
+ vfloat32m1_t val = vfcvt_f_x_v_f32m1(a.val, 4);
3256
+ vfloat64m2_t _val = vfwcvt_f_f_v_f64m2(val, 4);
3257
+ return v_float64x2(vget_v_f64m2_f64m1(_val, 1));
3258
+ }
3259
+
3260
+ inline v_float64x2 v_cvt_f64(const v_float32x4 &a) {
3261
+ vfloat64m2_t _val = vfwcvt_f_f_v_f64m2(a.val, 4);
3262
+ return v_float64x2(vget_v_f64m2_f64m1(_val, 0));
3263
+ }
3264
+
3265
+ inline v_float64x2 v_cvt_f64_high(const v_float32x4 &a) {
3266
+ vfloat64m2_t _val = vfwcvt_f_f_v_f64m2(a.val, 4);
3267
+ return v_float64x2(vget_v_f64m2_f64m1(_val, 1));
3268
+ }
3269
+
3270
+ inline v_float64x2 v_cvt_f64(const v_int64x2 &a) {
3271
+ return v_float64x2(vfcvt_f_x_v_f64m1(a.val, 2));
3272
+ }
3273
+
3274
+ #endif
3275
+ inline v_int8x16 v_interleave_pairs(const v_int8x16 &vec) {
3276
+ uint64 mdata[2] = {0x0705060403010200, 0x0F0D0E0C0B090A08};
3277
+ vuint64m1_t m0 = vle64_v_u64m1(mdata, 2);
3278
+ return v_int8x16(
3279
+ vrgather_vv_i8m1(vec.val, vreinterpret_v_u64m1_u8m1(m0), 16));
3280
+ }
3281
+ inline v_uint8x16 v_interleave_pairs(const v_uint8x16 &vec) {
3282
+ return v_reinterpret_as_u8(v_interleave_pairs(v_reinterpret_as_s8(vec)));
3283
+ }
3284
+
3285
+ inline v_int8x16 v_interleave_quads(const v_int8x16 &vec) {
3286
+ uint64 mdata[2] = {0x0703060205010400, 0x0F0B0E0A0D090C08};
3287
+ vuint64m1_t m0 = vle64_v_u64m1(mdata, 2);
3288
+ return v_int8x16(
3289
+ vrgather_vv_i8m1(vec.val, vreinterpret_v_u64m1_u8m1(m0), 16));
3290
+ }
3291
+ inline v_uint8x16 v_interleave_quads(const v_uint8x16 &vec) {
3292
+ return v_reinterpret_as_u8(v_interleave_quads(v_reinterpret_as_s8(vec)));
3293
+ }
3294
+
3295
+ inline v_int16x8 v_interleave_pairs(const v_int16x8 &vec) {
3296
+ uint64 mdata[2] = {0x0706030205040100, 0x0F0E0B0A0D0C0908};
3297
+ vuint64m1_t m0 = vle64_v_u64m1(mdata, 2);
3298
+ return v_int16x8(
3299
+ vreinterpret_v_i8m1_i16m1(vreinterpret_v_u8m1_i8m1(vrgather_vv_u8m1(
3300
+ vreinterpret_v_i8m1_u8m1(vreinterpret_v_i16m1_i8m1(vec.val)),
3301
+ vreinterpret_v_u64m1_u8m1(m0), 16))));
3302
+ }
3303
+ inline v_uint16x8 v_interleave_pairs(const v_uint16x8 &vec) {
3304
+ return v_reinterpret_as_u16(v_interleave_pairs(v_reinterpret_as_s16(vec)));
3305
+ }
3306
+ inline v_int16x8 v_interleave_quads(const v_int16x8 &vec) {
3307
+ uint64 mdata[2] = {0x0B0A030209080100, 0x0F0E07060D0C0504};
3308
+ vuint64m1_t m0 = vle64_v_u64m1(mdata, 2);
3309
+ return v_int16x8(
3310
+ vreinterpret_v_i8m1_i16m1(vreinterpret_v_u8m1_i8m1(vrgather_vv_u8m1(
3311
+ vreinterpret_v_i8m1_u8m1(vreinterpret_v_i16m1_i8m1(vec.val)),
3312
+ vreinterpret_v_u64m1_u8m1(m0), 16))));
3313
+ }
3314
+ inline v_uint16x8 v_interleave_quads(const v_uint16x8 &vec) {
3315
+ return v_reinterpret_as_u16(v_interleave_quads(v_reinterpret_as_s16(vec)));
3316
+ }
3317
+
3318
+ inline v_int32x4 v_interleave_pairs(const v_int32x4 &vec) {
3319
+ uint64 mdata[2] = {0x0B0A090803020100, 0x0F0E0D0C07060504};
3320
+ vuint64m1_t m0 = vle64_v_u64m1(mdata, 2);
3321
+ return v_int32x4(
3322
+ vreinterpret_v_i8m1_i32m1(vreinterpret_v_u8m1_i8m1(vrgather_vv_u8m1(
3323
+ vreinterpret_v_i8m1_u8m1(vreinterpret_v_i32m1_i8m1(vec.val)),
3324
+ vreinterpret_v_u64m1_u8m1(m0), 16))));
3325
+ }
3326
+ inline v_uint32x4 v_interleave_pairs(const v_uint32x4 &vec) {
3327
+ return v_reinterpret_as_u32(v_interleave_pairs(v_reinterpret_as_s32(vec)));
3328
+ }
3329
+ inline v_float32x4 v_interleave_pairs(const v_float32x4 &vec) {
3330
+ return v_reinterpret_as_f32(v_interleave_pairs(v_reinterpret_as_s32(vec)));
3331
+ }
3332
+ inline v_int8x16 v_pack_triplets(const v_int8x16 &vec) {
3333
+ uint64 mdata[2] = {0x0908060504020100, 0xFFFFFFFF0E0D0C0A};
3334
+ vuint64m1_t m0 = vle64_v_u64m1(mdata, 2);
3335
+ return v_int8x16(vreinterpret_v_u8m1_i8m1(vrgather_vv_u8m1(
3336
+ vreinterpret_v_i8m1_u8m1(vec.val), vreinterpret_v_u64m1_u8m1(m0), 16)));
3337
+ }
3338
+ inline v_uint8x16 v_pack_triplets(const v_uint8x16 &vec) {
3339
+ return v_reinterpret_as_u8(v_pack_triplets(v_reinterpret_as_s8(vec)));
3340
+ }
3341
+
3342
+ inline v_int16x8 v_pack_triplets(const v_int16x8 &vec) {
3343
+ uint64 mdata[2] = {0x0908050403020100, 0xFFFFFFFF0D0C0B0A};
3344
+ vuint64m1_t m0 = vle64_v_u64m1(mdata, 2);
3345
+ return v_int16x8(
3346
+ vreinterpret_v_i8m1_i16m1(vreinterpret_v_u8m1_i8m1(vrgather_vv_u8m1(
3347
+ vreinterpret_v_i8m1_u8m1(vreinterpret_v_i16m1_i8m1(vec.val)),
3348
+ vreinterpret_v_u64m1_u8m1(m0), 16))));
3349
+ }
3350
+ inline v_uint16x8 v_pack_triplets(const v_uint16x8 &vec) {
3351
+ return v_reinterpret_as_u16(v_pack_triplets(v_reinterpret_as_s16(vec)));
3352
+ }
3353
+
3354
+ inline v_int32x4 v_pack_triplets(const v_int32x4 &vec) { return vec; }
3355
+ inline v_uint32x4 v_pack_triplets(const v_uint32x4 &vec) { return vec; }
3356
+ inline v_float32x4 v_pack_triplets(const v_float32x4 &vec) { return vec; }
3357
+
3358
+ #if CV_SIMD128_64F
3359
+ inline v_float64x2 v_dotprod_expand(const v_int32x4 &a, const v_int32x4 &b) {
3360
+ return v_cvt_f64(v_dotprod(a, b));
3361
+ }
3362
+ inline v_float64x2 v_dotprod_expand(const v_int32x4 &a, const v_int32x4 &b,
3363
+ const v_float64x2 &c) {
3364
+ return v_add(v_dotprod_expand(a, b), c);
3365
+ }
3366
+ inline v_float64x2 v_dotprod_expand_fast(const v_int32x4 &a,
3367
+ const v_int32x4 &b) {
3368
+ vint64m2_t v1 = vwmul_vv_i64m2(a.val, b.val, 4);
3369
+ vfloat64m1_t res = vfcvt_f_x_v_f64m1(
3370
+ vadd_vv_i64m1(vget_v_i64m2_i64m1(v1, 0), vget_v_i64m2_i64m1(v1, 1), 2),
3371
+ 2);
3372
+ return v_float64x2(res);
3373
+ }
3374
+ inline v_float64x2 v_dotprod_expand_fast(const v_int32x4 &a, const v_int32x4 &b,
3375
+ const v_float64x2 &c) {
3376
+ v_float64x2 res = v_dotprod_expand_fast(a, b);
3377
+ return v_add(res, c);
3378
+ }
3379
+ #endif
3380
+ ////// FP16 support ///////
3381
+ #if __riscv_v == 7000
3382
+ inline v_float32x4 v_load_expand(const hfloat *ptr) {
3383
+ vfloat16m1_t v = vle16_v_f16m1((__fp16 *)ptr, 4);
3384
+ vfloat32m2_t v32 = vfwcvt_f_f_v_f32m2(v, 4);
3385
+ return v_float32x4(vget_v_f32m2_f32m1(v32, 0));
3386
+ }
3387
+
3388
+ inline void v_pack_store(hfloat *ptr, const v_float32x4 &v) {
3389
+ vfloat32m2_t v32 = vundefined_f32m2();
3390
+ v32 = vset_v_f32m1_f32m2(v32, 0, v.val);
3391
+ vfloat16m1_t hv = vfncvt_f_f_w_f16m1(v32, 4);
3392
+ vse16_v_f16m1((__fp16 *)ptr, hv, 4);
3393
+ }
3394
+ #else
3395
+ inline v_float32x4 v_load_expand(const hfloat *ptr) {
3396
+ vfloat16mf2_t v = vle16_v_f16mf2((__fp16 *)ptr, 4);
3397
+ vfloat32m1_t v32 = vfwcvt_f_f_v_f32m1(v, 4);
3398
+ return v_float32x4(v32);
3399
+ }
3400
+
3401
+ inline void v_pack_store(hfloat *ptr, const v_float32x4 &v) {
3402
+ // vfloat32m2_t v32 = vundefined_f32m2();
3403
+ // v32 = vset_f32m2(v32, 0, v.val);
3404
+ vfloat16mf2_t hv = vfncvt_f_f_w_f16mf2(v.val, 4);
3405
+ vse16_v_f16mf2((__fp16 *)ptr, hv, 4);
3406
+ }
3407
+ #endif
3408
+
3409
+ inline void v_cleanup() {}
3410
+
3411
+ #include "intrin_math.hpp"
3412
+ inline v_float32x4 v_exp(const v_float32x4 &x) {
3413
+ return v_exp_default_32f<v_float32x4, v_int32x4>(x);
3414
+ }
3415
+ inline v_float32x4 v_log(const v_float32x4 &x) {
3416
+ return v_log_default_32f<v_float32x4, v_int32x4>(x);
3417
+ }
3418
+ inline void v_sincos(const v_float32x4 &x, v_float32x4 &s, v_float32x4 &c) {
3419
+ v_sincos_default_32f<v_float32x4, v_int32x4>(x, s, c);
3420
+ }
3421
+ inline v_float32x4 v_sin(const v_float32x4 &x) {
3422
+ return v_sin_default_32f<v_float32x4, v_int32x4>(x);
3423
+ }
3424
+ inline v_float32x4 v_cos(const v_float32x4 &x) {
3425
+ return v_cos_default_32f<v_float32x4, v_int32x4>(x);
3426
+ }
3427
+ inline v_float32x4 v_erf(const v_float32x4 &x) {
3428
+ return v_erf_default_32f<v_float32x4, v_int32x4>(x);
3429
+ }
3430
+
3431
+ inline v_float64x2 v_exp(const v_float64x2 &x) {
3432
+ return v_exp_default_64f<v_float64x2, v_int64x2>(x);
3433
+ }
3434
+ inline v_float64x2 v_log(const v_float64x2 &x) {
3435
+ return v_log_default_64f<v_float64x2, v_int64x2>(x);
3436
+ }
3437
+ inline void v_sincos(const v_float64x2 &x, v_float64x2 &s, v_float64x2 &c) {
3438
+ v_sincos_default_64f<v_float64x2, v_int64x2>(x, s, c);
3439
+ }
3440
+ inline v_float64x2 v_sin(const v_float64x2 &x) {
3441
+ return v_sin_default_64f<v_float64x2, v_int64x2>(x);
3442
+ }
3443
+ inline v_float64x2 v_cos(const v_float64x2 &x) {
3444
+ return v_cos_default_64f<v_float64x2, v_int64x2>(x);
3445
+ }
3446
+
3447
+ CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
3448
+
3449
+ //! @endcond
3450
+
3451
+ } // namespace cv
3452
+ #endif