react-native-executorch 0.5.1 → 0.5.3

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 (595) hide show
  1. package/android/CMakeLists.txt +24 -0
  2. package/android/build.gradle +1 -0
  3. package/android/src/main/cpp/CMakeLists.txt +25 -0
  4. package/android/src/main/java/com/swmansion/rnexecutorch/RnExecutorchPackage.kt +1 -13
  5. package/common/rnexecutorch/RnExecutorchInstaller.cpp +52 -18
  6. package/common/rnexecutorch/RnExecutorchInstaller.h +0 -25
  7. package/common/rnexecutorch/TokenizerModule.cpp +1 -1
  8. package/common/rnexecutorch/TokenizerModule.h +4 -1
  9. package/common/rnexecutorch/data_processing/FileUtils.h +2 -2
  10. package/common/rnexecutorch/data_processing/ImageProcessing.cpp +5 -5
  11. package/common/rnexecutorch/data_processing/ImageProcessing.h +2 -2
  12. package/common/rnexecutorch/data_processing/Numerical.cpp +13 -0
  13. package/common/rnexecutorch/host_objects/JsiConversions.h +43 -62
  14. package/common/rnexecutorch/host_objects/ModelHostObject.h +43 -24
  15. package/common/rnexecutorch/metaprogramming/ConstructorHelpers.h +8 -6
  16. package/common/rnexecutorch/metaprogramming/FunctionHelpers.h +1 -1
  17. package/common/rnexecutorch/models/BaseModel.cpp +2 -2
  18. package/common/rnexecutorch/models/BaseModel.h +5 -0
  19. package/common/rnexecutorch/models/EncoderDecoderBase.cpp +2 -2
  20. package/common/rnexecutorch/models/EncoderDecoderBase.h +2 -2
  21. package/common/rnexecutorch/models/classification/Classification.cpp +6 -6
  22. package/common/rnexecutorch/models/classification/Classification.h +5 -0
  23. package/common/rnexecutorch/models/classification/Constants.h +3 -3
  24. package/common/rnexecutorch/models/embeddings/BaseEmbeddings.cpp +2 -2
  25. package/common/rnexecutorch/models/embeddings/BaseEmbeddings.h +2 -2
  26. package/common/rnexecutorch/models/embeddings/image/ImageEmbeddings.cpp +3 -3
  27. package/common/rnexecutorch/models/embeddings/image/ImageEmbeddings.h +5 -0
  28. package/common/rnexecutorch/models/embeddings/text/TextEmbeddings.cpp +2 -2
  29. package/common/rnexecutorch/models/embeddings/text/TextEmbeddings.h +6 -1
  30. package/common/rnexecutorch/models/image_segmentation/Constants.h +3 -3
  31. package/common/rnexecutorch/models/image_segmentation/ImageSegmentation.cpp +6 -5
  32. package/common/rnexecutorch/models/image_segmentation/ImageSegmentation.h +8 -1
  33. package/common/rnexecutorch/models/llm/LLM.cpp +58 -0
  34. package/common/rnexecutorch/models/llm/LLM.h +35 -0
  35. package/common/rnexecutorch/models/object_detection/Constants.h +3 -3
  36. package/common/rnexecutorch/models/object_detection/ObjectDetection.cpp +8 -8
  37. package/common/rnexecutorch/models/object_detection/ObjectDetection.h +11 -5
  38. package/common/rnexecutorch/models/object_detection/Types.h +13 -0
  39. package/common/rnexecutorch/models/object_detection/Utils.cpp +13 -11
  40. package/common/rnexecutorch/models/object_detection/Utils.h +7 -13
  41. package/common/rnexecutorch/models/ocr/CTCLabelConverter.cpp +2 -2
  42. package/common/rnexecutorch/models/ocr/CTCLabelConverter.h +2 -2
  43. package/common/rnexecutorch/models/ocr/Constants.h +33 -26
  44. package/common/rnexecutorch/models/ocr/Detector.cpp +20 -22
  45. package/common/rnexecutorch/models/ocr/Detector.h +4 -4
  46. package/common/rnexecutorch/models/ocr/OCR.cpp +9 -8
  47. package/common/rnexecutorch/models/ocr/OCR.h +11 -3
  48. package/common/rnexecutorch/models/ocr/RecognitionHandler.cpp +20 -19
  49. package/common/rnexecutorch/models/ocr/RecognitionHandler.h +9 -7
  50. package/common/rnexecutorch/models/ocr/Recognizer.cpp +7 -7
  51. package/common/rnexecutorch/models/ocr/Recognizer.h +2 -2
  52. package/common/rnexecutorch/models/ocr/Types.h +4 -6
  53. package/common/rnexecutorch/models/ocr/{DetectorUtils.cpp → utils/DetectorUtils.cpp} +70 -63
  54. package/common/rnexecutorch/models/ocr/{DetectorUtils.h → utils/DetectorUtils.h} +12 -11
  55. package/common/rnexecutorch/models/ocr/{RecognitionHandlerUtils.cpp → utils/RecognitionHandlerUtils.cpp} +14 -11
  56. package/common/rnexecutorch/models/ocr/{RecognitionHandlerUtils.h → utils/RecognitionHandlerUtils.h} +5 -5
  57. package/common/rnexecutorch/models/ocr/{RecognizerUtils.cpp → utils/RecognizerUtils.cpp} +28 -26
  58. package/common/rnexecutorch/models/ocr/{RecognizerUtils.h → utils/RecognizerUtils.h} +15 -14
  59. package/common/rnexecutorch/models/speech_to_text/SpeechToText.cpp +2 -2
  60. package/common/rnexecutorch/models/speech_to_text/SpeechToText.h +9 -2
  61. package/common/rnexecutorch/models/speech_to_text/SpeechToTextStrategy.h +2 -2
  62. package/common/rnexecutorch/models/speech_to_text/WhisperStrategy.cpp +2 -2
  63. package/common/rnexecutorch/models/speech_to_text/WhisperStrategy.h +2 -2
  64. package/common/rnexecutorch/models/style_transfer/StyleTransfer.cpp +5 -5
  65. package/common/rnexecutorch/models/style_transfer/StyleTransfer.h +6 -0
  66. package/common/rnexecutorch/models/vertical_ocr/VerticalDetector.cpp +23 -22
  67. package/common/rnexecutorch/models/vertical_ocr/VerticalDetector.h +4 -4
  68. package/common/rnexecutorch/models/vertical_ocr/VerticalOCR.cpp +34 -34
  69. package/common/rnexecutorch/models/vertical_ocr/VerticalOCR.h +27 -20
  70. package/{third-party/ios/ExecutorchLib/ExecutorchLib/sampler → common/runner}/sampler.cpp +3 -2
  71. package/{third-party/ios/ExecutorchLib/ExecutorchLib/sampler → common/runner}/sampler.h +3 -2
  72. package/ios/libs/executorch/libbackend_coreml_ios.a +0 -0
  73. package/ios/libs/executorch/libbackend_coreml_simulator.a +0 -0
  74. package/{third-party/ios/ExecutorchLib/frameworks/backend_mps.xcframework/ios-arm64 → ios/libs/executorch}/libbackend_mps_ios.a +0 -0
  75. package/{third-party/ios/ExecutorchLib/frameworks/backend_mps.xcframework/ios-arm64-simulator → ios/libs/executorch}/libbackend_mps_simulator.a +0 -0
  76. package/ios/libs/executorch/libbackend_xnnpack_ios.a +0 -0
  77. package/ios/libs/executorch/libbackend_xnnpack_simulator.a +0 -0
  78. package/ios/libs/executorch/libexecutorch_ios.a +0 -0
  79. package/ios/libs/executorch/libexecutorch_simulator.a +0 -0
  80. package/ios/libs/executorch/libkernels_custom_ios.a +0 -0
  81. package/ios/libs/executorch/libkernels_custom_simulator.a +0 -0
  82. package/ios/libs/executorch/libkernels_optimized_ios.a +0 -0
  83. package/ios/libs/executorch/libkernels_optimized_simulator.a +0 -0
  84. package/ios/libs/executorch/libkernels_portable_ios.a +0 -0
  85. package/ios/libs/executorch/libkernels_portable_simulator.a +0 -0
  86. package/ios/libs/executorch/libkernels_quantized_ios.a +0 -0
  87. package/ios/libs/executorch/libkernels_quantized_simulator.a +0 -0
  88. package/ios/libs/tokenizers-cpp/physical-arm64-release/libsentencepiece.a +0 -0
  89. package/ios/{ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/ExecutorchLib → libs/tokenizers-cpp/physical-arm64-release/libtokenizers_c.a} +0 -0
  90. package/ios/libs/tokenizers-cpp/physical-arm64-release/libtokenizers_cpp.a +0 -0
  91. package/ios/libs/tokenizers-cpp/simulator-arm64-debug/libsentencepiece.a +0 -0
  92. package/ios/{ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/ExecutorchLib → libs/tokenizers-cpp/simulator-arm64-debug/libtokenizers_c.a} +0 -0
  93. package/ios/libs/tokenizers-cpp/simulator-arm64-debug/libtokenizers_cpp.a +0 -0
  94. package/lib/Error.js +53 -0
  95. package/lib/ThreadPool.d.ts +10 -0
  96. package/lib/ThreadPool.js +28 -0
  97. package/lib/common/Logger.d.ts +8 -0
  98. package/lib/common/Logger.js +19 -0
  99. package/lib/constants/directories.js +2 -0
  100. package/lib/constants/llmDefaults.d.ts +6 -0
  101. package/lib/constants/llmDefaults.js +16 -0
  102. package/lib/constants/modelUrls.d.ts +223 -0
  103. package/lib/constants/modelUrls.js +322 -0
  104. package/lib/constants/ocr/models.d.ts +882 -0
  105. package/lib/constants/ocr/models.js +182 -0
  106. package/lib/constants/ocr/symbols.js +139 -0
  107. package/lib/constants/sttDefaults.d.ts +28 -0
  108. package/lib/constants/sttDefaults.js +68 -0
  109. package/lib/controllers/LLMController.d.ts +47 -0
  110. package/lib/controllers/LLMController.js +213 -0
  111. package/lib/controllers/OCRController.js +67 -0
  112. package/lib/controllers/SpeechToTextController.d.ts +56 -0
  113. package/lib/controllers/SpeechToTextController.js +349 -0
  114. package/lib/controllers/VerticalOCRController.js +70 -0
  115. package/lib/hooks/computer_vision/useClassification.d.ts +15 -0
  116. package/lib/hooks/computer_vision/useClassification.js +7 -0
  117. package/lib/hooks/computer_vision/useImageEmbeddings.d.ts +15 -0
  118. package/lib/hooks/computer_vision/useImageEmbeddings.js +7 -0
  119. package/lib/hooks/computer_vision/useImageSegmentation.d.ts +38 -0
  120. package/lib/hooks/computer_vision/useImageSegmentation.js +7 -0
  121. package/lib/hooks/computer_vision/useOCR.d.ts +20 -0
  122. package/lib/hooks/computer_vision/useOCR.js +41 -0
  123. package/lib/hooks/computer_vision/useObjectDetection.d.ts +15 -0
  124. package/lib/hooks/computer_vision/useObjectDetection.js +7 -0
  125. package/lib/hooks/computer_vision/useStyleTransfer.d.ts +15 -0
  126. package/lib/hooks/computer_vision/useStyleTransfer.js +7 -0
  127. package/lib/hooks/computer_vision/useVerticalOCR.d.ts +21 -0
  128. package/lib/hooks/computer_vision/useVerticalOCR.js +43 -0
  129. package/lib/hooks/general/useExecutorchModule.d.ts +13 -0
  130. package/lib/hooks/general/useExecutorchModule.js +7 -0
  131. package/lib/hooks/natural_language_processing/useLLM.d.ts +10 -0
  132. package/lib/hooks/natural_language_processing/useLLM.js +78 -0
  133. package/lib/hooks/natural_language_processing/useSpeechToText.d.ts +27 -0
  134. package/lib/hooks/natural_language_processing/useSpeechToText.js +49 -0
  135. package/lib/hooks/natural_language_processing/useTextEmbeddings.d.ts +16 -0
  136. package/lib/hooks/natural_language_processing/useTextEmbeddings.js +7 -0
  137. package/lib/hooks/natural_language_processing/useTokenizer.d.ts +17 -0
  138. package/lib/hooks/natural_language_processing/useTokenizer.js +52 -0
  139. package/lib/hooks/useModule.js +45 -0
  140. package/lib/hooks/useNonStaticModule.d.ts +20 -0
  141. package/lib/hooks/useNonStaticModule.js +49 -0
  142. package/lib/index.d.ts +48 -0
  143. package/lib/index.js +58 -0
  144. package/lib/module/controllers/LLMController.js +6 -10
  145. package/lib/module/controllers/LLMController.js.map +1 -1
  146. package/lib/module/hooks/computer_vision/useClassification.js +2 -2
  147. package/lib/module/hooks/computer_vision/useClassification.js.map +1 -1
  148. package/lib/module/hooks/computer_vision/useImageEmbeddings.js +2 -2
  149. package/lib/module/hooks/computer_vision/useImageEmbeddings.js.map +1 -1
  150. package/lib/module/hooks/computer_vision/useImageSegmentation.js +2 -2
  151. package/lib/module/hooks/computer_vision/useImageSegmentation.js.map +1 -1
  152. package/lib/module/hooks/computer_vision/useObjectDetection.js +2 -2
  153. package/lib/module/hooks/computer_vision/useObjectDetection.js.map +1 -1
  154. package/lib/module/hooks/computer_vision/useStyleTransfer.js +2 -2
  155. package/lib/module/hooks/computer_vision/useStyleTransfer.js.map +1 -1
  156. package/lib/module/hooks/general/useExecutorchModule.js +2 -2
  157. package/lib/module/hooks/general/useExecutorchModule.js.map +1 -1
  158. package/lib/module/hooks/natural_language_processing/useTextEmbeddings.js +2 -2
  159. package/lib/module/hooks/natural_language_processing/useTextEmbeddings.js.map +1 -1
  160. package/lib/module/hooks/useModule.js +13 -9
  161. package/lib/module/hooks/useModule.js.map +1 -1
  162. package/lib/module/index.js +1 -1
  163. package/lib/module/index.js.map +1 -1
  164. package/lib/module/modules/BaseModule.js +9 -17
  165. package/lib/module/modules/BaseModule.js.map +1 -1
  166. package/lib/module/modules/computer_vision/ClassificationModule.js +2 -2
  167. package/lib/module/modules/computer_vision/ClassificationModule.js.map +1 -1
  168. package/lib/module/modules/computer_vision/ImageEmbeddingsModule.js +2 -2
  169. package/lib/module/modules/computer_vision/ImageEmbeddingsModule.js.map +1 -1
  170. package/lib/module/modules/computer_vision/ImageSegmentationModule.js +2 -2
  171. package/lib/module/modules/computer_vision/ImageSegmentationModule.js.map +1 -1
  172. package/lib/module/modules/computer_vision/ObjectDetectionModule.js +2 -2
  173. package/lib/module/modules/computer_vision/ObjectDetectionModule.js.map +1 -1
  174. package/lib/module/modules/computer_vision/StyleTransferModule.js +2 -2
  175. package/lib/module/modules/computer_vision/StyleTransferModule.js.map +1 -1
  176. package/lib/module/modules/general/ExecutorchModule.js +2 -2
  177. package/lib/module/modules/general/ExecutorchModule.js.map +1 -1
  178. package/lib/module/modules/natural_language_processing/TextEmbeddingsModule.js +2 -2
  179. package/lib/module/modules/natural_language_processing/TextEmbeddingsModule.js.map +1 -1
  180. package/lib/module/native/RnExecutorchModules.js +1 -2
  181. package/lib/module/native/RnExecutorchModules.js.map +1 -1
  182. package/lib/module/utils/ResourceFetcher.js +6 -8
  183. package/lib/module/utils/ResourceFetcher.js.map +1 -1
  184. package/lib/module/utils/ResourceFetcherUtils.js +20 -20
  185. package/lib/module/utils/ResourceFetcherUtils.js.map +1 -1
  186. package/lib/module/utils/SpeechToTextModule/ASR.js +3 -3
  187. package/lib/module/utils/SpeechToTextModule/ASR.js.map +1 -1
  188. package/lib/modules/BaseModule.js +25 -0
  189. package/lib/modules/BaseNonStaticModule.js +14 -0
  190. package/lib/modules/computer_vision/ClassificationModule.d.ts +8 -0
  191. package/lib/modules/computer_vision/ClassificationModule.js +17 -0
  192. package/lib/modules/computer_vision/ImageEmbeddingsModule.d.ts +8 -0
  193. package/lib/modules/computer_vision/ImageEmbeddingsModule.js +17 -0
  194. package/lib/modules/computer_vision/ImageSegmentationModule.d.ts +11 -0
  195. package/lib/modules/computer_vision/ImageSegmentationModule.js +27 -0
  196. package/lib/modules/computer_vision/OCRModule.d.ts +14 -0
  197. package/lib/modules/computer_vision/OCRModule.js +17 -0
  198. package/lib/modules/computer_vision/ObjectDetectionModule.d.ts +9 -0
  199. package/lib/modules/computer_vision/ObjectDetectionModule.js +17 -0
  200. package/lib/modules/computer_vision/StyleTransferModule.d.ts +8 -0
  201. package/lib/modules/computer_vision/StyleTransferModule.js +17 -0
  202. package/lib/modules/computer_vision/VerticalOCRModule.d.ts +14 -0
  203. package/lib/modules/computer_vision/VerticalOCRModule.js +19 -0
  204. package/lib/modules/general/ExecutorchModule.d.ts +7 -0
  205. package/lib/modules/general/ExecutorchModule.js +14 -0
  206. package/lib/modules/natural_language_processing/LLMModule.d.ts +28 -0
  207. package/lib/modules/natural_language_processing/LLMModule.js +45 -0
  208. package/lib/modules/natural_language_processing/SpeechToTextModule.d.ts +24 -0
  209. package/lib/modules/natural_language_processing/SpeechToTextModule.js +36 -0
  210. package/lib/modules/natural_language_processing/TextEmbeddingsModule.d.ts +9 -0
  211. package/lib/modules/natural_language_processing/TextEmbeddingsModule.js +21 -0
  212. package/lib/modules/natural_language_processing/TokenizerModule.d.ts +12 -0
  213. package/lib/modules/natural_language_processing/TokenizerModule.js +30 -0
  214. package/lib/native/NativeETInstaller.js +2 -0
  215. package/lib/native/NativeOCR.js +2 -0
  216. package/lib/native/NativeVerticalOCR.js +2 -0
  217. package/lib/native/RnExecutorchModules.d.ts +7 -0
  218. package/lib/native/RnExecutorchModules.js +18 -0
  219. package/lib/tsconfig.tsbuildinfo +1 -1
  220. package/lib/types/common.d.ts +32 -0
  221. package/lib/types/common.js +25 -0
  222. package/lib/types/imageSegmentation.js +26 -0
  223. package/lib/types/llm.d.ts +46 -0
  224. package/lib/types/llm.js +9 -0
  225. package/lib/types/objectDetection.js +94 -0
  226. package/lib/types/ocr.js +1 -0
  227. package/lib/types/stt.d.ts +94 -0
  228. package/lib/types/stt.js +85 -0
  229. package/lib/typescript/controllers/LLMController.d.ts +1 -1
  230. package/lib/typescript/controllers/LLMController.d.ts.map +1 -1
  231. package/lib/typescript/hooks/useModule.d.ts +8 -5
  232. package/lib/typescript/hooks/useModule.d.ts.map +1 -1
  233. package/lib/typescript/index.d.ts +1 -0
  234. package/lib/typescript/index.d.ts.map +1 -1
  235. package/lib/typescript/modules/BaseModule.d.ts +7 -6
  236. package/lib/typescript/modules/BaseModule.d.ts.map +1 -1
  237. package/lib/typescript/modules/computer_vision/ClassificationModule.d.ts +2 -2
  238. package/lib/typescript/modules/computer_vision/ClassificationModule.d.ts.map +1 -1
  239. package/lib/typescript/modules/computer_vision/ImageEmbeddingsModule.d.ts +2 -2
  240. package/lib/typescript/modules/computer_vision/ImageEmbeddingsModule.d.ts.map +1 -1
  241. package/lib/typescript/modules/computer_vision/ImageSegmentationModule.d.ts +2 -2
  242. package/lib/typescript/modules/computer_vision/ImageSegmentationModule.d.ts.map +1 -1
  243. package/lib/typescript/modules/computer_vision/ObjectDetectionModule.d.ts +2 -2
  244. package/lib/typescript/modules/computer_vision/ObjectDetectionModule.d.ts.map +1 -1
  245. package/lib/typescript/modules/computer_vision/StyleTransferModule.d.ts +2 -2
  246. package/lib/typescript/modules/computer_vision/StyleTransferModule.d.ts.map +1 -1
  247. package/lib/typescript/modules/general/ExecutorchModule.d.ts +2 -2
  248. package/lib/typescript/modules/general/ExecutorchModule.d.ts.map +1 -1
  249. package/lib/typescript/modules/natural_language_processing/TextEmbeddingsModule.d.ts +2 -2
  250. package/lib/typescript/modules/natural_language_processing/TextEmbeddingsModule.d.ts.map +1 -1
  251. package/lib/typescript/native/RnExecutorchModules.d.ts +1 -3
  252. package/lib/typescript/native/RnExecutorchModules.d.ts.map +1 -1
  253. package/lib/typescript/utils/ResourceFetcher.d.ts.map +1 -1
  254. package/lib/typescript/utils/ResourceFetcherUtils.d.ts.map +1 -1
  255. package/lib/utils/ResourceFetcher.d.ts +24 -0
  256. package/lib/utils/ResourceFetcher.js +305 -0
  257. package/lib/utils/ResourceFetcherUtils.d.ts +54 -0
  258. package/lib/utils/ResourceFetcherUtils.js +127 -0
  259. package/lib/utils/llm.d.ts +6 -0
  260. package/lib/utils/llm.js +72 -0
  261. package/lib/utils/stt.js +21 -0
  262. package/package.json +1 -2
  263. package/react-native-executorch.podspec +47 -44
  264. package/src/controllers/LLMController.ts +8 -13
  265. package/src/hooks/computer_vision/useClassification.ts +2 -2
  266. package/src/hooks/computer_vision/useImageEmbeddings.ts +2 -2
  267. package/src/hooks/computer_vision/useImageSegmentation.ts +2 -2
  268. package/src/hooks/computer_vision/useObjectDetection.ts +2 -2
  269. package/src/hooks/computer_vision/useStyleTransfer.ts +2 -2
  270. package/src/hooks/general/useExecutorchModule.ts +2 -2
  271. package/src/hooks/natural_language_processing/useTextEmbeddings.ts +2 -2
  272. package/src/hooks/useModule.ts +23 -13
  273. package/src/index.ts +3 -2
  274. package/src/modules/BaseModule.ts +17 -28
  275. package/src/modules/computer_vision/ClassificationModule.ts +2 -2
  276. package/src/modules/computer_vision/ImageEmbeddingsModule.ts +2 -2
  277. package/src/modules/computer_vision/ImageSegmentationModule.ts +2 -2
  278. package/src/modules/computer_vision/ObjectDetectionModule.ts +2 -2
  279. package/src/modules/computer_vision/StyleTransferModule.ts +2 -2
  280. package/src/modules/general/ExecutorchModule.ts +2 -2
  281. package/src/modules/natural_language_processing/TextEmbeddingsModule.ts +2 -2
  282. package/src/native/RnExecutorchModules.ts +1 -5
  283. package/src/utils/ResourceFetcher.ts +9 -7
  284. package/src/utils/ResourceFetcherUtils.ts +15 -17
  285. package/src/utils/SpeechToTextModule/ASR.ts +4 -4
  286. package/third-party/android/libs/cpuinfo/arm64-v8a/libcpuinfo.so +0 -0
  287. package/third-party/android/libs/pthreadpool/arm64-v8a/libpthreadpool.so +0 -0
  288. package/third-party/include/cpuinfo/cpuinfo.h +2305 -0
  289. package/third-party/include/executorch/extension/threadpool/cpuinfo_utils.h +26 -0
  290. package/third-party/include/executorch/extension/threadpool/threadpool.h +94 -0
  291. package/third-party/include/pthreadpool/pthreadpool.h +2236 -0
  292. package/android/src/main/java/com/swmansion/rnexecutorch/LLM.kt +0 -63
  293. package/ios/ExecutorchLib.xcframework/Info.plist +0 -43
  294. package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Headers/ETModel.h +0 -27
  295. package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Headers/HuggingFaceTokenizer.h +0 -14
  296. package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Headers/LLaMARunner.h +0 -32
  297. package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Info.plist +0 -0
  298. package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Headers/ETModel.h +0 -27
  299. package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Headers/HuggingFaceTokenizer.h +0 -14
  300. package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Headers/LLaMARunner.h +0 -32
  301. package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Info.plist +0 -0
  302. package/ios/RnExecutorch/LLM.h +0 -5
  303. package/ios/RnExecutorch/LLM.mm +0 -78
  304. package/ios/RnExecutorch.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  305. package/ios/RnExecutorch.xcodeproj/project.xcworkspace/xcuserdata/jakubchmura.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  306. package/ios/RnExecutorch.xcodeproj/xcuserdata/jakubchmura.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
  307. package/lib/module/modules/BaseNonStaticModule.js +0 -17
  308. package/lib/module/modules/BaseNonStaticModule.js.map +0 -1
  309. package/lib/module/native/NativeLLM.js +0 -5
  310. package/lib/module/native/NativeLLM.js.map +0 -1
  311. package/lib/typescript/modules/BaseNonStaticModule.d.ts +0 -10
  312. package/lib/typescript/modules/BaseNonStaticModule.d.ts.map +0 -1
  313. package/lib/typescript/native/NativeLLM.d.ts +0 -12
  314. package/lib/typescript/native/NativeLLM.d.ts.map +0 -1
  315. package/src/modules/BaseNonStaticModule.ts +0 -26
  316. package/src/native/NativeLLM.ts +0 -14
  317. package/third-party/include/tokenizers-cpp/tokenizers_c.h +0 -61
  318. package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/ETModel.h +0 -27
  319. package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/ETModel.mm +0 -249
  320. package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/HuggingFaceTokenizer.h +0 -14
  321. package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/HuggingFaceTokenizer.mm +0 -80
  322. package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/LLaMARunner.h +0 -32
  323. package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/LLaMARunner.mm +0 -95
  324. package/third-party/ios/ExecutorchLib/ExecutorchLib/InputType.h +0 -12
  325. package/third-party/ios/ExecutorchLib/ExecutorchLib/Utils.hpp +0 -217
  326. package/third-party/ios/ExecutorchLib/ExecutorchLib/model/Model.cpp +0 -11
  327. package/third-party/ios/ExecutorchLib/ExecutorchLib/model/Model.h +0 -11
  328. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/base64.h +0 -202
  329. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/bpe_tokenizer.cpp +0 -313
  330. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/bpe_tokenizer.h +0 -57
  331. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/llama_tiktoken.cpp +0 -78
  332. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/llama_tiktoken.h +0 -23
  333. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/tiktoken.cpp +0 -427
  334. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/tiktoken.h +0 -87
  335. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/tokenizer.h +0 -76
  336. package/third-party/ios/ExecutorchLib/ExecutorchLib.xcodeproj/project.pbxproj +0 -683
  337. package/third-party/ios/ExecutorchLib/ExecutorchLib.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  338. package/third-party/ios/ExecutorchLib/ExecutorchLib.xcodeproj/project.xcworkspace/xcuserdata/jakubchmura.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  339. package/third-party/ios/ExecutorchLib/ExecutorchLib.xcodeproj/xcuserdata/jakubchmura.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
  340. package/third-party/ios/ExecutorchLib/build.sh +0 -44
  341. package/third-party/ios/ExecutorchLib/frameworks/backend_coreml.xcframework/Info.plist +0 -43
  342. package/third-party/ios/ExecutorchLib/frameworks/backend_coreml.xcframework/ios-arm64/libbackend_coreml_ios.a +0 -0
  343. package/third-party/ios/ExecutorchLib/frameworks/backend_coreml.xcframework/ios-arm64-simulator/libbackend_coreml_simulator.a +0 -0
  344. package/third-party/ios/ExecutorchLib/frameworks/backend_mps.xcframework/Info.plist +0 -43
  345. package/third-party/ios/ExecutorchLib/frameworks/backend_xnnpack.xcframework/Info.plist +0 -43
  346. package/third-party/ios/ExecutorchLib/frameworks/backend_xnnpack.xcframework/ios-arm64/libbackend_xnnpack_ios.a +0 -0
  347. package/third-party/ios/ExecutorchLib/frameworks/backend_xnnpack.xcframework/ios-arm64-simulator/libbackend_xnnpack_simulator.a +0 -0
  348. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/Info.plist +0 -47
  349. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/macros/Export.h +0 -163
  350. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/macros/Macros.h +0 -497
  351. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/BFloat16-inl.h +0 -342
  352. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/BFloat16-math.h +0 -266
  353. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/BFloat16.h +0 -125
  354. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/Half-inl.h +0 -347
  355. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/Half.h +0 -416
  356. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/TypeSafeSignMath.h +0 -133
  357. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/bit_cast.h +0 -43
  358. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/floating_point_utils.h +0 -33
  359. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/irange.h +0 -107
  360. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorch.h +0 -13
  361. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchError.h +0 -16
  362. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchLog.h +0 -76
  363. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchModule.h +0 -286
  364. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchTensor.h +0 -742
  365. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchValue.h +0 -219
  366. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/module/module.h +0 -492
  367. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/tensor/tensor.h +0 -13
  368. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/tensor/tensor_accessor.h +0 -190
  369. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/tensor/tensor_ptr.h +0 -347
  370. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/tensor/tensor_ptr_maker.h +0 -653
  371. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/backend/backend_execution_context.h +0 -71
  372. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/backend/backend_init_context.h +0 -72
  373. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/backend/interface.h +0 -166
  374. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/array_ref.h +0 -235
  375. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/data_loader.h +0 -136
  376. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/defines.h +0 -20
  377. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/error.h +0 -229
  378. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/evalue.h +0 -521
  379. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/event_tracer.h +0 -565
  380. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/event_tracer_hooks.h +0 -323
  381. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/event_tracer_hooks_delegate.h +0 -197
  382. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/exec_aten.h +0 -147
  383. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/util/dim_order_util.h +0 -263
  384. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/util/scalar_type_util.h +0 -1331
  385. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/util/tensor_dimension_limit.h +0 -21
  386. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/util/tensor_shape_to_c_string.h +0 -69
  387. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/util/tensor_util.h +0 -1250
  388. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/freeable_buffer.h +0 -107
  389. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/hierarchical_allocator.h +0 -107
  390. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/memory_allocator.h +0 -198
  391. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/named_data_map.h +0 -86
  392. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/bfloat16.h +0 -27
  393. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/bfloat16_math.h +0 -14
  394. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/bits_types.h +0 -83
  395. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/macros/Export.h +0 -163
  396. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/macros/Macros.h +0 -497
  397. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-inl.h +0 -342
  398. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-math.h +0 -266
  399. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16.h +0 -125
  400. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/Half-inl.h +0 -347
  401. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/Half.h +0 -416
  402. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/TypeSafeSignMath.h +0 -133
  403. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/bit_cast.h +0 -43
  404. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/floating_point_utils.h +0 -33
  405. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/irange.h +0 -107
  406. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/complex.h +0 -44
  407. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/device.h +0 -70
  408. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/half.h +0 -27
  409. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/optional.h +0 -36
  410. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/qint_types.h +0 -83
  411. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/scalar.h +0 -110
  412. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/scalar_type.h +0 -154
  413. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/string_view.h +0 -29
  414. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/tensor.h +0 -142
  415. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/tensor_impl.h +0 -261
  416. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/tensor_options.h +0 -60
  417. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/result.h +0 -258
  418. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/span.h +0 -93
  419. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/tag.h +0 -71
  420. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/tensor_layout.h +0 -79
  421. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/tensor_shape_dynamism.h +0 -39
  422. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/memory_manager.h +0 -113
  423. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/method.h +0 -387
  424. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/method_meta.h +0 -251
  425. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/program.h +0 -320
  426. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/pte_data_map.h +0 -144
  427. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/tensor_parser.h +0 -156
  428. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/kernel/kernel_runtime_context.h +0 -122
  429. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/kernel/operator_registry.h +0 -278
  430. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/abort.h +0 -36
  431. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/assert.h +0 -119
  432. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/clock.h +0 -43
  433. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/compat_unistd.h +0 -75
  434. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/compiler.h +0 -191
  435. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/log.h +0 -177
  436. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/platform.h +0 -133
  437. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/profiler.h +0 -292
  438. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/runtime.h +0 -35
  439. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/system.h +0 -49
  440. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/types.h +0 -24
  441. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/schema/extended_header.h +0 -76
  442. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/module.modulemap +0 -5
  443. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/libexecutorch_ios.a +0 -0
  444. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/macros/Export.h +0 -163
  445. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/macros/Macros.h +0 -497
  446. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/BFloat16-inl.h +0 -342
  447. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/BFloat16-math.h +0 -266
  448. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/BFloat16.h +0 -125
  449. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/Half-inl.h +0 -347
  450. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/Half.h +0 -416
  451. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/TypeSafeSignMath.h +0 -133
  452. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/bit_cast.h +0 -43
  453. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/floating_point_utils.h +0 -33
  454. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/irange.h +0 -107
  455. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorch.h +0 -13
  456. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchError.h +0 -16
  457. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchLog.h +0 -76
  458. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchModule.h +0 -286
  459. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchTensor.h +0 -742
  460. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchValue.h +0 -219
  461. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/module/module.h +0 -492
  462. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/tensor/tensor.h +0 -13
  463. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/tensor/tensor_accessor.h +0 -190
  464. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/tensor/tensor_ptr.h +0 -347
  465. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/tensor/tensor_ptr_maker.h +0 -653
  466. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/backend/backend_execution_context.h +0 -71
  467. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/backend/backend_init_context.h +0 -72
  468. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/backend/interface.h +0 -166
  469. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/array_ref.h +0 -235
  470. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/data_loader.h +0 -136
  471. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/defines.h +0 -20
  472. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/error.h +0 -229
  473. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/evalue.h +0 -521
  474. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/event_tracer.h +0 -565
  475. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/event_tracer_hooks.h +0 -323
  476. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/event_tracer_hooks_delegate.h +0 -197
  477. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/exec_aten.h +0 -147
  478. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/util/dim_order_util.h +0 -263
  479. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/util/scalar_type_util.h +0 -1331
  480. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/util/tensor_dimension_limit.h +0 -21
  481. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/util/tensor_shape_to_c_string.h +0 -69
  482. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/util/tensor_util.h +0 -1250
  483. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/freeable_buffer.h +0 -107
  484. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/hierarchical_allocator.h +0 -107
  485. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/memory_allocator.h +0 -198
  486. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/named_data_map.h +0 -86
  487. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/bfloat16.h +0 -27
  488. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/bfloat16_math.h +0 -14
  489. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/bits_types.h +0 -83
  490. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/macros/Export.h +0 -163
  491. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/macros/Macros.h +0 -497
  492. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-inl.h +0 -342
  493. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-math.h +0 -266
  494. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16.h +0 -125
  495. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/Half-inl.h +0 -347
  496. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/Half.h +0 -416
  497. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/TypeSafeSignMath.h +0 -133
  498. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/bit_cast.h +0 -43
  499. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/floating_point_utils.h +0 -33
  500. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/irange.h +0 -107
  501. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/complex.h +0 -44
  502. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/device.h +0 -70
  503. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/half.h +0 -27
  504. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/optional.h +0 -36
  505. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/qint_types.h +0 -83
  506. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/scalar.h +0 -110
  507. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/scalar_type.h +0 -154
  508. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/string_view.h +0 -29
  509. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/tensor.h +0 -142
  510. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/tensor_impl.h +0 -261
  511. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/tensor_options.h +0 -60
  512. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/result.h +0 -258
  513. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/span.h +0 -93
  514. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/tag.h +0 -71
  515. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/tensor_layout.h +0 -79
  516. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/tensor_shape_dynamism.h +0 -39
  517. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/memory_manager.h +0 -113
  518. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/method.h +0 -387
  519. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/method_meta.h +0 -251
  520. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/program.h +0 -320
  521. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/pte_data_map.h +0 -144
  522. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/tensor_parser.h +0 -156
  523. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/kernel/kernel_runtime_context.h +0 -122
  524. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/kernel/operator_registry.h +0 -278
  525. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/abort.h +0 -36
  526. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/assert.h +0 -119
  527. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/clock.h +0 -43
  528. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/compat_unistd.h +0 -75
  529. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/compiler.h +0 -191
  530. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/log.h +0 -177
  531. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/platform.h +0 -133
  532. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/profiler.h +0 -292
  533. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/runtime.h +0 -35
  534. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/system.h +0 -49
  535. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/types.h +0 -24
  536. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/schema/extended_header.h +0 -76
  537. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/module.modulemap +0 -5
  538. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/libexecutorch_simulator.a +0 -0
  539. package/third-party/ios/ExecutorchLib/frameworks/kernels_custom.xcframework/Info.plist +0 -43
  540. package/third-party/ios/ExecutorchLib/frameworks/kernels_custom.xcframework/ios-arm64/libkernels_custom_ios.a +0 -0
  541. package/third-party/ios/ExecutorchLib/frameworks/kernels_custom.xcframework/ios-arm64-simulator/libkernels_custom_simulator.a +0 -0
  542. package/third-party/ios/ExecutorchLib/frameworks/kernels_optimized.xcframework/Info.plist +0 -43
  543. package/third-party/ios/ExecutorchLib/frameworks/kernels_optimized.xcframework/ios-arm64/libkernels_optimized_ios.a +0 -0
  544. package/third-party/ios/ExecutorchLib/frameworks/kernels_optimized.xcframework/ios-arm64-simulator/libkernels_optimized_simulator.a +0 -0
  545. package/third-party/ios/ExecutorchLib/frameworks/kernels_portable.xcframework/Info.plist +0 -43
  546. package/third-party/ios/ExecutorchLib/frameworks/kernels_portable.xcframework/ios-arm64/libkernels_portable_ios.a +0 -0
  547. package/third-party/ios/ExecutorchLib/frameworks/kernels_portable.xcframework/ios-arm64-simulator/libkernels_portable_simulator.a +0 -0
  548. package/third-party/ios/ExecutorchLib/frameworks/kernels_quantized.xcframework/Info.plist +0 -43
  549. package/third-party/ios/ExecutorchLib/frameworks/kernels_quantized.xcframework/ios-arm64/libkernels_quantized_ios.a +0 -0
  550. package/third-party/ios/ExecutorchLib/frameworks/kernels_quantized.xcframework/ios-arm64-simulator/libkernels_quantized_simulator.a +0 -0
  551. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/Info.plist +0 -43
  552. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/bitmap256.h +0 -82
  553. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/filtered_re2.h +0 -111
  554. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/pod_array.h +0 -43
  555. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/prefilter.h +0 -130
  556. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/prefilter_tree.h +0 -139
  557. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/prog.h +0 -483
  558. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/re2.h +0 -994
  559. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/regexp.h +0 -692
  560. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/set.h +0 -85
  561. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/sparse_array.h +0 -367
  562. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/sparse_set.h +0 -241
  563. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/stringpiece.h +0 -205
  564. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/unicode_casefold.h +0 -78
  565. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/unicode_groups.h +0 -64
  566. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/walker-inl.h +0 -235
  567. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Info.plist +0 -26
  568. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/re2 +0 -0
  569. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/bitmap256.h +0 -82
  570. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/filtered_re2.h +0 -111
  571. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/pod_array.h +0 -43
  572. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/prefilter.h +0 -130
  573. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/prefilter_tree.h +0 -139
  574. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/prog.h +0 -483
  575. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/re2.h +0 -994
  576. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/regexp.h +0 -692
  577. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/set.h +0 -85
  578. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/sparse_array.h +0 -367
  579. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/sparse_set.h +0 -241
  580. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/stringpiece.h +0 -205
  581. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/unicode_casefold.h +0 -78
  582. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/unicode_groups.h +0 -64
  583. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/walker-inl.h +0 -235
  584. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Info.plist +0 -26
  585. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/re2 +0 -0
  586. /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/irunner.h +0 -0
  587. /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/runner.cpp +0 -0
  588. /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/runner.h +0 -0
  589. /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/stats.h +0 -0
  590. /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/text_decoder_runner.cpp +0 -0
  591. /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/text_decoder_runner.h +0 -0
  592. /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/text_prefiller.cpp +0 -0
  593. /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/text_prefiller.h +0 -0
  594. /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/text_token_generator.h +0 -0
  595. /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/util.h +0 -0
@@ -1,1250 +0,0 @@
1
- /*
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- * All rights reserved.
4
- *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
-
9
- #pragma once
10
-
11
- #include <algorithm>
12
- #include <array> // std::array
13
- #include <c10/util/irange.h>
14
- #include <cinttypes> // PRId64
15
- #include <cmath>
16
- #include <cstddef> // size_t
17
-
18
- #include <limits>
19
-
20
- #include <executorch/runtime/core/array_ref.h>
21
- #include <executorch/runtime/core/error.h>
22
- #include <executorch/runtime/core/exec_aten/exec_aten.h>
23
- #include <executorch/runtime/core/exec_aten/util/dim_order_util.h>
24
- #include <executorch/runtime/core/exec_aten/util/scalar_type_util.h>
25
- #include <executorch/runtime/core/exec_aten/util/tensor_dimension_limit.h>
26
- #include <executorch/runtime/core/span.h>
27
- #include <executorch/runtime/platform/assert.h>
28
- #include <executorch/runtime/platform/compiler.h>
29
-
30
- /// All assertion messages should begin with this prefix.
31
- #define ET_TENSOR_CHECK_PREFIX__ "Tensors do not match"
32
- #define ET_MIN2(a, b) (std::min(a, b))
33
- #define ET_MIN3(a, b, c) (std::min(a, std::min(b, c)))
34
-
35
- #define ET_NORMALIZE_IX(IX, UPPER_BOUND) IX < 0 ? IX + UPPER_BOUND : IX
36
-
37
- #define ET_CHECK_VALID_IX(IX, UPPER_BOUND) \
38
- ET_CHECK_MSG(IX >= -static_cast<int64_t>(UPPER_BOUND) && \
39
- IX < static_cast<int64_t>(UPPER_BOUND), \
40
- "index %" PRId64 " must be within range [-%zd, %zd)", IX, \
41
- UPPER_BOUND, UPPER_BOUND)
42
-
43
- #define ET_CHECK_VALID_DIM(DIM, UPPER_BOUND) \
44
- ET_CHECK_MSG(DIM >= -static_cast<int64_t>(UPPER_BOUND) && \
45
- DIM < static_cast<int64_t>(UPPER_BOUND), \
46
- "dim %" PRId64 " must be within range [-%zd, %zd)", DIM, \
47
- UPPER_BOUND, UPPER_BOUND)
48
-
49
- #define ET_CHECK_NON_ZERO_DIM_SIZE(DIM, T) \
50
- const size_t udim = ET_NORMALIZE_IX(DIM, T.dim()); \
51
- ET_CHECK_MSG(T.size(udim) != 0, "Expected dim %zd to have non-zero size.", \
52
- udim);
53
-
54
- /**
55
- * Asserts that all tensors have the same shape.
56
- * This also handles a edge case where there is only one element in all the
57
- * tensors being compared but the number of dimensions >= 0. In the for loop
58
- * iterating over the dimensions we make sure that we pick the smallest
59
- * dimension of all the tensors as the upper bound for the for loop.
60
- */
61
- #define ET_CHECK_SAME_SHAPE2(a__, b__) \
62
- ({ \
63
- const size_t a_numel__ = (a__).numel(); \
64
- const size_t b_numel__ = (b__).numel(); \
65
- const size_t a_dim__ = (a__).dim(); \
66
- const size_t b_dim__ = (b__).dim(); \
67
- ET_CHECK_MSG( \
68
- a_numel__ == b_numel__ && \
69
- ((a_numel__ == 1 && b_numel__ == 1) || (a_dim__ == b_dim__)), \
70
- ET_TENSOR_CHECK_PREFIX__ ": numel={%zu, %zu}, dim={%zu, %zu}", \
71
- a_numel__, b_numel__, a_dim__, b_dim__); \
72
- for (size_t dim__ = 0; dim__ < ET_MIN2(a_dim__, b_dim__); ++dim__) { \
73
- size_t a_size__ = (a__).size(dim__); \
74
- size_t b_size__ = (b__).size(dim__); \
75
- ET_CHECK_MSG(a_size__ == b_size__, \
76
- ET_TENSOR_CHECK_PREFIX__ " at size(%zu): {%zu, %zu}", \
77
- dim__, a_size__, b_size__); \
78
- } \
79
- })
80
-
81
- #define ET_CHECK_SAME_SHAPE3(a__, b__, c__) \
82
- ({ \
83
- const size_t a_numel__ = (a__).numel(); \
84
- const size_t b_numel__ = (b__).numel(); \
85
- const size_t c_numel__ = (c__).numel(); \
86
- const size_t a_dim__ = (a__).dim(); \
87
- const size_t b_dim__ = (b__).dim(); \
88
- const size_t c_dim__ = (c__).dim(); \
89
- ET_CHECK_MSG(a_numel__ == b_numel__ && b_numel__ == c_numel__ && \
90
- ((a_numel__ == 1 && b_numel__ == 1 && c_numel__ == 1) || \
91
- a_dim__ == b_dim__ && b_dim__ == c_dim__), \
92
- ET_TENSOR_CHECK_PREFIX__ \
93
- ": numel={%zu, %zu, %zu}, dim={%zu, %zu, %zu}", \
94
- a_numel__, b_numel__, c_numel__, a_dim__, b_dim__, c_dim__); \
95
- for (size_t dim__ = 0; dim__ < ET_MIN3(a_dim__, b_dim__, c_dim__); \
96
- ++dim__) { \
97
- size_t a_size__ = (a__).size(dim__); \
98
- size_t b_size__ = (b__).size(dim__); \
99
- size_t c_size__ = (c__).size(dim__); \
100
- ET_CHECK_MSG(a_size__ == b_size__ && b_size__ == c_size__, \
101
- ET_TENSOR_CHECK_PREFIX__ " at size(%zu): {%zu, %zu, %zu}", \
102
- dim__, a_size__, b_size__, c_size__); \
103
- } \
104
- })
105
-
106
- /// Asserts that all tensors have the same dtype.
107
- #define ET_CHECK_SAME_DTYPE2(a__, b__) \
108
- ({ \
109
- const ::executorch::aten::ScalarType a_type__ = (a__).scalar_type(); \
110
- const ::executorch::aten::ScalarType b_type__ = (b__).scalar_type(); \
111
- ET_CHECK_MSG(a_type__ == b_type__, \
112
- ET_TENSOR_CHECK_PREFIX__ ": dtype={%" PRId8 ", %" PRId8 "}", \
113
- static_cast<int8_t>(a_type__), \
114
- static_cast<int8_t>(b_type__)); \
115
- })
116
-
117
- #define ET_CHECK_SAME_DTYPE3(a__, b__, c__) \
118
- ({ \
119
- const ::executorch::aten::ScalarType a_type__ = (a__).scalar_type(); \
120
- const ::executorch::aten::ScalarType b_type__ = (b__).scalar_type(); \
121
- const ::executorch::aten::ScalarType c_type__ = (c__).scalar_type(); \
122
- ET_CHECK_MSG(a_type__ == b_type__ && b_type__ == c_type__, \
123
- ET_TENSOR_CHECK_PREFIX__ ": dtype={%" PRId8 ", %" PRId8 \
124
- ", %" PRId8 "}", \
125
- static_cast<int8_t>(a_type__), static_cast<int8_t>(b_type__), \
126
- static_cast<int8_t>(c_type__)); \
127
- })
128
-
129
- /**
130
- * Asserts that all tensors have the same shape and dtype.
131
- *
132
- * This macro should produce less code/data than calling the SHAPE and DTYPE
133
- * macros independently, because it only calls ET_CHECK_MSG once.
134
- */
135
- #define ET_CHECK_SAME_SHAPE_AND_DTYPE2(a__, b__) \
136
- ({ \
137
- const size_t a_numel__ = (a__).numel(); \
138
- const size_t b_numel__ = (b__).numel(); \
139
- const size_t a_dim__ = (a__).dim(); \
140
- const size_t b_dim__ = (b__).dim(); \
141
- const ::executorch::aten::ScalarType a_type__ = (a__).scalar_type(); \
142
- const ::executorch::aten::ScalarType b_type__ = (b__).scalar_type(); \
143
- \
144
- ET_CHECK_MSG( \
145
- a_numel__ == b_numel__ && \
146
- ((a_numel__ == 1 && b_numel__ == 1) || a_dim__ == b_dim__) && \
147
- a_type__ == b_type__, \
148
- ET_TENSOR_CHECK_PREFIX__ \
149
- ": numel={%zu, %zu}, dim={%zu, %zu}, dtype={%" PRId8 ", %" PRId8 "}", \
150
- a_numel__, b_numel__, a_dim__, b_dim__, static_cast<int8_t>(a_type__), \
151
- static_cast<int8_t>(b_type__)); \
152
- for (size_t dim__ = 0; dim__ < ET_MIN2(a_dim__, b_dim__); ++dim__) { \
153
- size_t a_size__ = (a__).size(dim__); \
154
- size_t b_size__ = (b__).size(dim__); \
155
- ET_CHECK_MSG(a_size__ == b_size__, \
156
- ET_TENSOR_CHECK_PREFIX__ " at size(%zu): {%zu, %zu}", \
157
- dim__, a_size__, b_size__); \
158
- } \
159
- })
160
-
161
- #define ET_CHECK_SAME_SHAPE_AND_DTYPE3(a__, b__, c__) \
162
- ({ \
163
- const size_t a_numel__ = (a__).numel(); \
164
- const size_t b_numel__ = (b__).numel(); \
165
- const size_t c_numel__ = (c__).numel(); \
166
- const size_t a_dim__ = (a__).dim(); \
167
- const size_t b_dim__ = (b__).dim(); \
168
- const size_t c_dim__ = (c__).dim(); \
169
- const ::executorch::aten::ScalarType a_type__ = (a__).scalar_type(); \
170
- const ::executorch::aten::ScalarType b_type__ = (b__).scalar_type(); \
171
- const ::executorch::aten::ScalarType c_type__ = (c__).scalar_type(); \
172
- \
173
- ET_CHECK_MSG(a_numel__ == b_numel__ && b_numel__ == c_numel__ && \
174
- ((a_numel__ == 1 && b_numel__ == 1 && c_numel__ == 1) || \
175
- (a_dim__ == b_dim__ && b_dim__ == c_dim__)) && \
176
- a_type__ == b_type__ && b_type__ == c_type__, \
177
- ET_TENSOR_CHECK_PREFIX__ \
178
- ": numel={%zu, %zu, %zu}, dim={%zu, %zu, %zu}, " \
179
- "dtype={%" PRId8 ", %" PRId8 ", %" PRId8 "}", \
180
- a_numel__, b_numel__, c_numel__, a_dim__, b_dim__, c_dim__, \
181
- static_cast<int8_t>(a_type__), static_cast<int8_t>(b_type__), \
182
- static_cast<int8_t>(c_type__)); \
183
- for (size_t dim__ = 0; dim__ < ET_MIN3(a_dim__, b_dim__, c_dim__); \
184
- ++dim__) { \
185
- size_t a_size__ = (a__).size(dim__); \
186
- size_t b_size__ = (b__).size(dim__); \
187
- size_t c_size__ = (c__).size(dim__); \
188
- ET_CHECK_MSG(a_size__ == b_size__ && b_size__ == c_size__, \
189
- ET_TENSOR_CHECK_PREFIX__ " at size(%zu): {%zu, %zu, %zu}", \
190
- dim__, a_size__, b_size__, c_size__); \
191
- } \
192
- })
193
-
194
- /**
195
- * Assert that the input tensor is contiguous tensor.
196
- */
197
- #define ET_CHECK_CONTIGUOUS(a__) \
198
- ({ \
199
- const ::executorch::aten::ArrayRef<executorch::aten::StridesType> \
200
- strides = a__.strides(); \
201
- const ::executorch::aten::ArrayRef<executorch::aten::StridesType> sizes = \
202
- a__.sizes(); \
203
- ET_CHECK_MSG( \
204
- strides[strides.size() - 1] == 1, \
205
- "The stride of the last dimension shall be 1 for contiguous tensor, " \
206
- "not %d", \
207
- strides[strides.size() - 1]); \
208
- for (size_t i = strides.size() - 1; i > 0; i--) { \
209
- ET_CHECK_MSG(strides[i - 1] == strides[i] * sizes[i], \
210
- "The stride of the %zu-th dimension shall equal to " \
211
- "strides[%zu] * sizes[%zu], now is %d and %d", \
212
- i - 1, i, i, strides[i - 1], strides[i] * sizes[i]); \
213
- } \
214
- })
215
-
216
- /**
217
- * Assert the input two tensors share same strides.
218
- * Noted that this function does not make any check or promise on the contiguity
219
- * of any input tensors.
220
- */
221
- #define ET_CHECK_SAME_STRIDES2(a__, b__) \
222
- ({ \
223
- ET_CHECK_MSG( \
224
- a__.dim() == b__.dim(), \
225
- "Two tensors shall have same number of strides, but not %zu and %zu.", \
226
- a__.dim(), b__.dim()); \
227
- const ::executorch::aten::ArrayRef<executorch::aten::StridesType> \
228
- a_strides = a__.strides(); \
229
- const ::executorch::aten::ArrayRef<executorch::aten::StridesType> \
230
- b_strides = b__.strides(); \
231
- for (size_t i = 0; i < a__.dim(); i++) { \
232
- ET_CHECK_MSG(a_strides[i] == b_strides[i], \
233
- "a.strides()[%zu] shall equal to b.strides()[%zu], " \
234
- "but now is %d and %d.", \
235
- i, i, (int32_t)a_strides[i], (int32_t)b_strides[i]); \
236
- } \
237
- })
238
-
239
- /**
240
- * Assert the input three tensors share same strides.
241
- * Noted that this function does not make any check or promise on the contiguity
242
- * of any input tensors.
243
- */
244
- #define ET_CHECK_SAME_STRIDES3(a__, b__, c__) \
245
- ({ \
246
- ET_CHECK_MSG(a__.dim() == b__.dim() && b__.dim() == c__.dim(), \
247
- "Three tensors shall have same number of strides, " \
248
- "but not %zu, %zu and %zu.", \
249
- a__.dim(), b__.dim(), c__.dim()); \
250
- const ::executorch::aten::ArrayRef<executorch::aten::StridesType> \
251
- a_strides = a__.strides(); \
252
- const ::executorch::aten::ArrayRef<executorch::aten::StridesType> \
253
- b_strides = b__.strides(); \
254
- const ::executorch::aten::ArrayRef<executorch::aten::StridesType> \
255
- c_strides = c__.strides(); \
256
- for (size_t i = 0; i < a__.dim(); i++) { \
257
- ET_CHECK_MSG(a_strides[i] == b_strides[i] && \
258
- b_strides[i] == c_strides[i], \
259
- "a_strides[%zu], b_strides[%zu] and c_strides[%zu] " \
260
- "shall share same value, but now is %d, %d and %d", \
261
- i, i, i, (int32_t)a_strides[i], (int32_t)b_strides[i], \
262
- (int32_t)c_strides[i]); \
263
- } \
264
- })
265
-
266
- #define ET_CHECK_DEFAULT_OR_CHANNELSLAST_DIMORDER(t__) \
267
- ({ \
268
- ET_CHECK_MSG(is_contiguous_dim_order(t__.dim_order().data(), \
269
- t__.dim_order().size()) || \
270
- is_channels_last_dim_order(t__.dim_order().data(), \
271
- t__.dim_order().size()), \
272
- "Tensor must have default or channels last dim order"); \
273
- })
274
-
275
- /**
276
- * DEPRECATED: Please use ET_CHECK_OR_RETURN_FALSE instead and provide
277
- * an informative message. (For example, the values of any variables used in
278
- * `cond` would not be reported automatically by this macro.)
279
- *
280
- * A convenience macro to be used in utility functions that check whether input
281
- * tensor(s) are valid, which are expected to return a boolean. Checks whether
282
- * `cond` is true; if not, log the failed check and return false.
283
- *
284
- * @param[in] cond the condition to check
285
- */
286
- #define ET_LOG_AND_RETURN_IF_FALSE(cond) ET_CHECK_OR_RETURN_FALSE(cond, "")
287
-
288
- /**
289
- * DEPRECATED: Please use ET_CHECK_OR_RETURN_FALSE instead.
290
- */
291
- #define ET_LOG_MSG_AND_RETURN_IF_FALSE ET_CHECK_OR_RETURN_FALSE
292
-
293
- /**
294
- * If `cond` is false, log `cond` and return from the kernel with a failure
295
- * state set.
296
- *
297
- * @param[in] context the runtime context
298
- * @param[in] cond the condition to check
299
- * @param[in] error torch::executor::Error enum value (e.g `InvalidArgument`)
300
- * @param[in] retval return value of the kernel to allow for early exit
301
- */
302
- #define ET_KERNEL_CHECK(context, cond, error, retval) \
303
- do { \
304
- if (!(cond)) { \
305
- ET_LOG(Error, "Check failed (%s): ", #cond); \
306
- context.fail(torch::executor::Error::error); \
307
- return retval; \
308
- } \
309
- } while (false)
310
-
311
- /**
312
- * If `cond` is false, log `message` and return from the kernel with a failure
313
- * state set.
314
- *
315
- * @param[in] context the runtime context
316
- * @param[in] cond the condition to check
317
- * @param[in] error torch::executor::Error enum value (e.g `InvalidArgument`)
318
- * @param[in] retval return value of the kernel to allow for early exit
319
- */
320
- #define ET_KERNEL_CHECK_MSG(context, cond, error, retval, message, ...) \
321
- do { \
322
- if (!(cond)) { \
323
- ET_LOG(Error, "Check failed (%s): " message, #cond, ##__VA_ARGS__); \
324
- context.fail(torch::executor::Error::error); \
325
- return retval; \
326
- } \
327
- } while (false)
328
-
329
- /**
330
- * Convenience macro to extract a scalar tensor into a value
331
- */
332
- #define ET_EXTRACT_SCALAR_TENSOR(scalar_tensor, out_val) \
333
- ET_CHECK_MSG(extract_scalar_tensor(scalar_tensor, &out_val), #scalar_tensor \
334
- " could not be extracted: wrong type or out of range");
335
-
336
- namespace executorch {
337
- namespace runtime {
338
-
339
- //
340
- // Utility functions for checking tensor attributes
341
- //
342
- //
343
-
344
- /*
345
- * Returns true if the given dimension value is between -upper_bound and
346
- * upper_bound - 1, inclusive.
347
- */
348
- inline bool dim_is_valid(int64_t dim, int64_t upper_bound) {
349
- ET_CHECK_OR_RETURN_FALSE(
350
- dim >= -upper_bound && dim < upper_bound,
351
- "Dimension %" PRId64
352
- " is out of range. Dimension should be between %" PRId64 " and %" PRId64
353
- ", inclusive.",
354
- dim, -upper_bound, upper_bound - 1);
355
-
356
- return true;
357
- }
358
-
359
- /*
360
- * Returns the tensor's number of dimensions, except when the tensor is zero
361
- * dimensional. In this case, it returns 1. This is used to properly handle
362
- * the zero dimensional tensors in some kernels, that treat them as 1D tensors
363
- * with a single element.
364
- */
365
- inline ssize_t nonzero_dim(const executorch::aten::Tensor &tensor) {
366
- return tensor.dim() == 0 ? 1 : tensor.dim();
367
- }
368
-
369
- /*
370
- * Returns the size along a dimension dim, except when the tensor is zero
371
- * dimensional. In this case, it returns 1. This is used to properly handle
372
- * the zero dimensional tensors in some kernels, that treat them as 1D tensors
373
- * with a single element.
374
- */
375
- inline ssize_t nonempty_size(const executorch::aten::Tensor &tensor,
376
- ssize_t dim) {
377
- return tensor.dim() == 0 ? 1 : tensor.size(dim);
378
- }
379
-
380
- inline bool tensor_can_cast_to(executorch::aten::Tensor a,
381
- executorch::aten::ScalarType dtype) {
382
- ET_CHECK_OR_RETURN_FALSE(torch::executor::canCast(a.scalar_type(), dtype),
383
- "Tensor of dtype %s cannot cast to dtype %s",
384
- torch::executor::toString(a.scalar_type()),
385
- torch::executor::toString(dtype));
386
-
387
- return true;
388
- }
389
-
390
- inline bool tensor_is_bool_type(executorch::aten::Tensor t) {
391
- ET_CHECK_OR_RETURN_FALSE(t.scalar_type() ==
392
- executorch::aten::ScalarType::Bool,
393
- "Expected to find bool type, but tensor has type %s",
394
- torch::executor::toString(t.scalar_type()));
395
-
396
- return true;
397
- }
398
-
399
- inline bool tensor_is_type(executorch::aten::Tensor t,
400
- executorch::aten::ScalarType dtype) {
401
- ET_CHECK_OR_RETURN_FALSE(t.scalar_type() == dtype,
402
- "Expected to find %s type, but tensor has type %s",
403
- torch::executor::toString(dtype),
404
- torch::executor::toString(t.scalar_type()));
405
-
406
- return true;
407
- }
408
-
409
- inline bool tensor_is_type(executorch::aten::Tensor t,
410
- executorch::aten::ScalarType dtype,
411
- executorch::aten::ScalarType dtype2) {
412
- ET_LOG_MSG_AND_RETURN_IF_FALSE(
413
- t.scalar_type() == dtype || t.scalar_type() == dtype2,
414
- "Expected to find %s or %s type, but tensor has type %s",
415
- torch::executor::toString(dtype), torch::executor::toString(dtype2),
416
- torch::executor::toString(t.scalar_type()));
417
-
418
- return true;
419
- }
420
-
421
- inline bool tensor_is_type(executorch::aten::Tensor t,
422
- executorch::aten::ScalarType dtype,
423
- executorch::aten::ScalarType dtype2,
424
- executorch::aten::ScalarType dtype3) {
425
- ET_LOG_MSG_AND_RETURN_IF_FALSE(
426
- t.scalar_type() == dtype || t.scalar_type() == dtype2 ||
427
- t.scalar_type() == dtype3,
428
- "Expected to find %s, %s, or %s type, but tensor has type %s",
429
- torch::executor::toString(dtype), torch::executor::toString(dtype2),
430
- torch::executor::toString(dtype3),
431
- torch::executor::toString(t.scalar_type()));
432
-
433
- return true;
434
- }
435
-
436
- inline bool tensor_is_integral_type(executorch::aten::Tensor t,
437
- bool includeBool = false) {
438
- ET_CHECK_OR_RETURN_FALSE(
439
- torch::executor::isIntegralType(t.scalar_type(), includeBool),
440
- "Expected to find a integral type, but tensor has type %s",
441
- torch::executor::toString(t.scalar_type()));
442
-
443
- return true;
444
- }
445
-
446
- inline bool tensor_is_floating_type(executorch::aten::Tensor t) {
447
- ET_CHECK_OR_RETURN_FALSE(
448
- torch::executor::isFloatingType(t.scalar_type()),
449
- "Expected to find a floating type, but tensor has type %s",
450
- torch::executor::toString(t.scalar_type()));
451
-
452
- return true;
453
- }
454
-
455
- inline bool tensor_is_real_type(executorch::aten::Tensor t) {
456
- ET_CHECK_OR_RETURN_FALSE(
457
- torch::executor::isRealType(t.scalar_type()),
458
- "Expected to find a real type, but tensor has type %s",
459
- torch::executor::toString(t.scalar_type()));
460
-
461
- return true;
462
- }
463
-
464
- inline bool tensor_is_realh_type(executorch::aten::Tensor t) {
465
- ET_CHECK_OR_RETURN_FALSE(
466
- torch::executor::isRealHType(t.scalar_type()),
467
- "Expected to find a real type, but tensor has type %s",
468
- torch::executor::toString(t.scalar_type()));
469
-
470
- return true;
471
- }
472
-
473
- inline bool tensor_is_realhbf16_type(executorch::aten::Tensor t) {
474
- ET_CHECK_OR_RETURN_FALSE(
475
- executorch::runtime::isRealHBF16Type(t.scalar_type()),
476
- "Expected to find a real type, but tensor has type %s",
477
- torch::executor::toString(t.scalar_type()));
478
-
479
- return true;
480
- }
481
-
482
- inline bool tensor_is_realhb_type(executorch::aten::Tensor t) {
483
- ET_CHECK_OR_RETURN_FALSE(
484
- torch::executor::isRealHBType(t.scalar_type()),
485
- "Expected to find a real type, but tensor has type %s",
486
- torch::executor::toString(t.scalar_type()));
487
-
488
- return true;
489
- }
490
-
491
- inline bool tensor_is_realhbbf16_type(executorch::aten::Tensor t) {
492
- ET_CHECK_OR_RETURN_FALSE(
493
- executorch::runtime::isRealHBBF16Type(t.scalar_type()),
494
- "Expected to find a real type, but tensor has type %s",
495
- torch::executor::toString(t.scalar_type()));
496
-
497
- return true;
498
- }
499
-
500
- inline bool tensor_is_complex_type(executorch::aten::Tensor t) {
501
- ET_CHECK_OR_RETURN_FALSE(
502
- torch::executor::isComplexType(t.scalar_type()),
503
- "Expected to find a complex type, but tensor has type %s",
504
- torch::executor::toString(t.scalar_type()));
505
-
506
- return true;
507
- }
508
-
509
- inline bool tensor_is_bits_type(executorch::aten::Tensor t) {
510
- ET_CHECK_OR_RETURN_FALSE(
511
- torch::executor::isBitsType(t.scalar_type()),
512
- "Expected to find a bits type, but tensor has type %s",
513
- torch::executor::toString(t.scalar_type()));
514
-
515
- return true;
516
- }
517
-
518
- inline bool tensors_have_same_dtype(executorch::aten::Tensor a,
519
- executorch::aten::Tensor b) {
520
- ET_CHECK_OR_RETURN_FALSE(a.scalar_type() == b.scalar_type(),
521
- ET_TENSOR_CHECK_PREFIX__ ": dtype={%s, %s}",
522
- torch::executor::toString(a.scalar_type()),
523
- torch::executor::toString(b.scalar_type()));
524
- return true;
525
- }
526
-
527
- inline bool tensors_have_same_dtype(executorch::aten::Tensor a,
528
- executorch::aten::Tensor b,
529
- executorch::aten::Tensor c) {
530
- ET_CHECK_OR_RETURN_FALSE(a.scalar_type() == b.scalar_type() &&
531
- b.scalar_type() == c.scalar_type(),
532
- ET_TENSOR_CHECK_PREFIX__ ": dtype={%s, %s, %s}",
533
- torch::executor::toString(a.scalar_type()),
534
- torch::executor::toString(b.scalar_type()),
535
- torch::executor::toString(c.scalar_type()));
536
- return true;
537
- }
538
-
539
- inline bool tensor_is_rank(executorch::aten::Tensor t, size_t rank) {
540
- ET_CHECK_OR_RETURN_FALSE(static_cast<size_t>(t.dim()) == rank,
541
- "Expected tensor.dim() to be %zu, but got %zu",
542
- static_cast<size_t>(rank),
543
- static_cast<size_t>(t.dim()));
544
-
545
- return true;
546
- }
547
-
548
- inline bool tensor_has_rank_greater_or_equal_to(executorch::aten::Tensor t,
549
- size_t rank) {
550
- ET_CHECK_OR_RETURN_FALSE(static_cast<size_t>(t.dim()) >= rank,
551
- "Expected tensor.dim() to be >= %zu, but got %zu",
552
- static_cast<size_t>(rank),
553
- static_cast<size_t>(t.dim()));
554
-
555
- return true;
556
- }
557
-
558
- inline bool tensor_has_rank_smaller_or_equal_to(executorch::aten::Tensor t,
559
- size_t rank) {
560
- ET_CHECK_OR_RETURN_FALSE(static_cast<size_t>(t.dim()) <= rank,
561
- "Expected tensor.dim() to be <= %zu, but got %zu",
562
- static_cast<size_t>(rank),
563
- static_cast<size_t>(t.dim()));
564
-
565
- return true;
566
- }
567
-
568
- inline bool tensor_has_dim(executorch::aten::Tensor t, int64_t d) {
569
- if (t.dim() == 0) {
570
- ET_CHECK_OR_RETURN_FALSE(
571
- d == 0 || d == -1, "dim must be 0 or -1 for 0-dim tensor, got %" PRId64,
572
- d);
573
- } else {
574
- ET_CHECK_OR_RETURN_FALSE(d > 0 ? d < t.dim() : t.dim() + d >= 0,
575
- "%zu-dim tensor does not have dim at index %zu",
576
- static_cast<size_t>(t.dim()),
577
- static_cast<size_t>(d));
578
- }
579
- return true;
580
- }
581
-
582
- inline bool tensor_has_non_empty_dim(executorch::aten::Tensor t, int64_t d) {
583
- const size_t udim = ET_NORMALIZE_IX(d, t.dim());
584
- ET_LOG_AND_RETURN_IF_FALSE(tensor_has_dim(t, d));
585
- ET_LOG_AND_RETURN_IF_FALSE(t.size(udim) != 0);
586
- return true;
587
- }
588
-
589
- inline bool tensor_dim_has_index(executorch::aten::Tensor t, int64_t d,
590
- int64_t ix) {
591
- // Indexing ops don't support zero-dim tensors
592
- ET_CHECK(t.dim() != 0);
593
- if (d < 0) {
594
- d += t.dim();
595
- }
596
- // Dimension must have been already checked by tensor_has_dim
597
- ET_CHECK(d >= 0 && d < t.dim());
598
-
599
- ET_CHECK_OR_RETURN_FALSE(
600
- ix >= -t.size(d) && ix < t.size(d),
601
- "index %" PRId64 " out of range [-%zu,%zu) at dimension %" PRId64 ")", ix,
602
- static_cast<size_t>(t.size(d)), static_cast<size_t>(t.size(d)), d);
603
- return true;
604
- }
605
-
606
- inline bool tensors_have_same_size_at_dims(executorch::aten::Tensor a,
607
- size_t dim_a,
608
- executorch::aten::Tensor b,
609
- size_t dim_b) {
610
- ET_CHECK_OR_RETURN_FALSE(dim_a < static_cast<size_t>(a.dim()),
611
- "Cannot retrieve dim %zu from tensor with dim %zu",
612
- static_cast<size_t>(dim_a),
613
- static_cast<size_t>(a.dim()));
614
- ET_CHECK_OR_RETURN_FALSE(dim_b < static_cast<size_t>(b.dim()),
615
- "Cannot retrieve dim %zu from tensor with dim %zu",
616
- static_cast<size_t>(dim_b),
617
- static_cast<size_t>(b.dim()));
618
- ET_CHECK_OR_RETURN_FALSE(
619
- a.size(dim_a) == b.size(dim_b),
620
- ET_TENSOR_CHECK_PREFIX__
621
- ": a.size(%zu) = %zu does not match b.size(%zu) = %zu",
622
- static_cast<size_t>(dim_a), static_cast<size_t>(a.size(dim_a)),
623
- static_cast<size_t>(dim_b), static_cast<size_t>(b.size(dim_b)));
624
-
625
- return true;
626
- }
627
-
628
- inline bool tensors_have_same_shape(executorch::aten::Tensor a,
629
- executorch::aten::Tensor b) {
630
- if (a.numel() == 1 && b.numel() == 1) {
631
- // PyTorch operators treat all scalar tensors as the same shape even if
632
- // they have different dims.
633
- return true;
634
- }
635
- if (!(a.sizes() == b.sizes() && a.numel() == b.numel())) {
636
- ET_LOG(Error,
637
- ET_TENSOR_CHECK_PREFIX__ ": numel=(%zu, %zu), dim=(%zu, %zu)",
638
- static_cast<size_t>(a.numel()), static_cast<size_t>(b.numel()),
639
- static_cast<size_t>(a.dim()), static_cast<size_t>(b.dim()));
640
- // Using [[maybe_unused]] as ET_LOG may not trigger based on verbosity
641
- for ([[maybe_unused]] const auto d :
642
- c10::irange(ET_MIN2(a.dim(), b.dim()))) {
643
- ET_LOG(Error, " size(%zu): (%zu, %zu)", static_cast<size_t>(d),
644
- static_cast<size_t>(a.size(d)), static_cast<size_t>(b.size(d)));
645
- }
646
-
647
- return false;
648
- }
649
-
650
- return true;
651
- }
652
-
653
- inline bool tensors_have_same_shape(executorch::aten::Tensor a,
654
- executorch::aten::Tensor b,
655
- executorch::aten::Tensor c) {
656
- if (a.numel() == 1 && b.numel() == 1 && c.numel() == 1) {
657
- // PyTorch operators treat all scalar tensors as the same shape even if
658
- // they have different dims.
659
- return true;
660
- }
661
- bool cond1 = (a.sizes() == b.sizes()) && (a.numel() == b.numel());
662
- bool cond2 = (b.sizes() == c.sizes()) && (b.numel() == c.numel());
663
-
664
- if (!(cond1 && cond2)) {
665
- ET_LOG(Error,
666
- ET_TENSOR_CHECK_PREFIX__
667
- ": numel=(%zu, %zu, %zu), dim=(%zu, %zu, %zu)",
668
- static_cast<size_t>(a.numel()), static_cast<size_t>(b.numel()),
669
- static_cast<size_t>(c.numel()), static_cast<size_t>(a.dim()),
670
- static_cast<size_t>(b.dim()), static_cast<size_t>(c.dim()));
671
- for ([[maybe_unused]] const auto d :
672
- c10::irange(ET_MIN3(a.dim(), b.dim(), c.dim()))) {
673
- ET_LOG(Error, " size(%zu): (%zu, %zu, %zu)", static_cast<size_t>(d),
674
- static_cast<size_t>(a.size(d)), static_cast<size_t>(b.size(d)),
675
- static_cast<size_t>(c.size(d)));
676
- }
677
-
678
- return false;
679
- }
680
-
681
- return true;
682
- }
683
-
684
- inline bool tensors_have_same_shape_and_dtype(executorch::aten::Tensor a,
685
- executorch::aten::Tensor b) {
686
- return tensors_have_same_shape(a, b) && tensors_have_same_dtype(a, b);
687
- }
688
-
689
- inline bool tensors_have_same_shape_and_dtype(executorch::aten::Tensor a,
690
- executorch::aten::Tensor b,
691
- executorch::aten::Tensor c) {
692
- return tensors_have_same_shape(a, b, c) && tensors_have_same_dtype(a, b, c);
693
- }
694
-
695
- inline bool tensor_has_expected_size(
696
- executorch::aten::Tensor a,
697
- executorch::aten::ArrayRef<executorch::aten::SizesType> expected_sizes) {
698
- if (!(a.sizes() == expected_sizes)) {
699
- ET_LOG(Error, ET_TENSOR_CHECK_PREFIX__ ": dim=(%zu, %zu)",
700
- static_cast<size_t>(a.dim()),
701
- static_cast<size_t>(expected_sizes.size()));
702
- size_t a_dim = static_cast<size_t>(a.dim());
703
- size_t expected_dim = static_cast<size_t>(expected_sizes.size());
704
- for ([[maybe_unused]] const auto d :
705
- c10::irange(ET_MIN2(a_dim, expected_dim))) {
706
- ET_LOG(Error, " size(%zu): (%zu, %zu)", static_cast<size_t>(d),
707
- static_cast<size_t>(a.size(d)),
708
- static_cast<size_t>(expected_sizes[d]));
709
- }
710
-
711
- return false;
712
- }
713
- return true;
714
- }
715
-
716
- inline bool tensors_have_same_strides(executorch::aten::Tensor a,
717
- executorch::aten::Tensor b) {
718
- if (a.strides() != b.strides()) {
719
- ET_LOG(Error, ET_TENSOR_CHECK_PREFIX__ ": dim=(%zu, %zu)",
720
- static_cast<size_t>(a.dim()), static_cast<size_t>(b.dim()));
721
- for ([[maybe_unused]] const auto d :
722
- c10::irange(ET_MIN2(a.dim(), b.dim()))) {
723
- ET_LOG(Error, " stride(%zu): (%zu, %zu)", static_cast<size_t>(d),
724
- static_cast<size_t>(a.strides()[d]),
725
- static_cast<size_t>(b.strides()[d]));
726
- }
727
-
728
- return false;
729
- }
730
- return true;
731
- }
732
-
733
- inline bool tensors_have_same_strides(executorch::aten::Tensor a,
734
- executorch::aten::Tensor b,
735
- executorch::aten::Tensor c) {
736
- if (!(a.strides() == b.strides() && b.strides() == c.strides())) {
737
- ET_LOG(Error, ET_TENSOR_CHECK_PREFIX__ ": dim=(%zu, %zu, %zu)",
738
- static_cast<size_t>(a.dim()), static_cast<size_t>(b.dim()),
739
- static_cast<size_t>(c.dim()));
740
- for ([[maybe_unused]] const auto d :
741
- c10::irange(ET_MIN3(a.dim(), b.dim(), c.dim()))) {
742
- ET_LOG(Error, " stride(%zu): (%zu, %zu, %zu)", static_cast<size_t>(d),
743
- static_cast<size_t>(a.strides()[d]),
744
- static_cast<size_t>(b.strides()[d]),
745
- static_cast<size_t>(c.strides()[d]));
746
- }
747
-
748
- return false;
749
- }
750
- return true;
751
- }
752
-
753
- inline bool tensor_is_contiguous(executorch::aten::Tensor t) {
754
- const auto strides = t.strides();
755
- const auto sizes = t.sizes();
756
- // If tensor is 0-dim (i.e. a scalar tensor) it is contiguous
757
- if (strides.size() == 0) {
758
- return true;
759
- }
760
- ET_CHECK_OR_RETURN_FALSE(
761
- strides[strides.size() - 1] == 1,
762
- "Tensor is not contiguous; the stride of the last dimension must be 1, "
763
- "but got %zu",
764
- static_cast<size_t>(strides[strides.size() - 1]));
765
- for (int i = strides.size() - 1; i > 0; --i) {
766
- ET_CHECK_OR_RETURN_FALSE(
767
- strides[i - 1] == strides[i] * sizes[i],
768
- "Tensor is not contiguous; the stride of dim %zu should be equal to "
769
- "strides[%zu] * sizes[%zu] = %zu, but found %zu",
770
- static_cast<size_t>(i - 1), static_cast<size_t>(i),
771
- static_cast<size_t>(i), static_cast<size_t>(strides[i] * sizes[i]),
772
- static_cast<size_t>(strides[i - 1]));
773
- }
774
- return true;
775
- }
776
-
777
- inline bool tensors_have_same_rank(executorch::aten::Tensor a,
778
- executorch::aten::Tensor b) {
779
- ET_CHECK_OR_RETURN_FALSE(a.dim() == b.dim(),
780
- ET_TENSOR_CHECK_PREFIX__ ": rank={%zd, %zd}",
781
- ssize_t(a.dim()), ssize_t(b.dim()));
782
- return true;
783
- }
784
-
785
- inline bool tensor_is_scalar(executorch::aten::Tensor t) {
786
- return t.dim() == 0 && t.numel() == 1;
787
- }
788
-
789
- /// Returns the product of dim[0:dim), not including dim.
790
- inline size_t getLeadingDims(const executorch::aten::Tensor &tensor,
791
- int64_t dim) {
792
- ET_CHECK_MSG(dim >= 0 && dim <= tensor.dim(),
793
- "Ending dimension %" PRId64
794
- " should be in the range [0, tensor.dim() %zd].",
795
- dim, ssize_t(tensor.dim()));
796
- size_t dims = 1;
797
- for (const auto i : c10::irange(dim)) {
798
- dims *= static_cast<size_t>(tensor.size(i));
799
- }
800
- return dims;
801
- }
802
-
803
- /// Returns the product of dim[dim+1:].
804
- inline size_t getTrailingDims(const executorch::aten::Tensor &tensor,
805
- int64_t dim) {
806
- ET_CHECK_MSG(dim >= -1 && dim < tensor.dim(),
807
- "Starting dimension %" PRId64
808
- " should be in the range [-1, tensor.dim() -1 %zd).",
809
- dim, ssize_t(tensor.dim()));
810
- size_t dims = 1;
811
- for (size_t i = dim + 1; i < static_cast<size_t>(tensor.dim()); ++i) {
812
- dims *= static_cast<size_t>(tensor.size(i));
813
- }
814
- return dims;
815
- }
816
-
817
- /**
818
- * Given a N-dimensional tensor coordinate, return a linear index that can be
819
- * used to access the corresponding element in the tensor's data buffer.
820
- *
821
- * @param[in] tensor The tensor that will be indexed
822
- * @param[in] coordinate A n-dimensional array representing the coordinate to
823
- * index. It is assumed that the array has kTensorDimensionLimit elements.
824
- * @param[out] index The linear index to element at the specified coordinate
825
- * in the tensor.
826
- */
827
- inline size_t coordinateToIndex(const executorch::aten::Tensor &tensor,
828
- const size_t *const coordinate) {
829
- size_t index = 0;
830
- for (int d = 0; d < tensor.dim(); ++d) {
831
- index += coordinate[d] * getTrailingDims(tensor, d);
832
- }
833
- return index;
834
- }
835
-
836
- /**
837
- * Produce a memoized array for use with repeated calls to
838
- * coordinateToIndexWithTrailingDimsMemo, which will be faster than
839
- * repeated calls to coordinateToIndex.
840
- */
841
- inline void
842
- memoizeTrailingDims(const executorch::aten::Tensor &tensor,
843
- size_t trailing_dims_memo[kTensorDimensionLimit]) {
844
- const auto tensorDim = tensor.dim();
845
- size_t dims = 1;
846
- for (int ii = tensorDim - 1; ii >= 0; --ii) {
847
- trailing_dims_memo[ii] = dims;
848
- dims *= static_cast<size_t>(tensor.size(ii));
849
- }
850
- }
851
-
852
- /**
853
- * Like coordinateToIndex, but faster for repeated calls with the same
854
- * tensor. trailing_dims_memo must be produced by a call to
855
- * memoizeTrailingDims.
856
- */
857
- inline size_t coordinateToIndexWithTrailingDimsMemo(
858
- const executorch::aten::Tensor &tensor, const size_t *const coordinate,
859
- const size_t trailing_dims_memo[kTensorDimensionLimit]) {
860
- size_t index = 0;
861
- for (int d = 0; d < tensor.dim(); ++d) {
862
- index += coordinate[d] * trailing_dims_memo[d];
863
- }
864
- return index;
865
- }
866
-
867
- /**
868
- * Given the linear index return the N-dimensional tensor coordinate. This is
869
- * the inverse operation of coordinateToIndex.
870
- *
871
- * @param[in] tensor The tensor that will be indexed
872
- * @param[in] index The linear index to element at the specified coordinate in
873
- * the tensor.
874
- * @param[out] coordinate A n-dimensional array representing the coordinate to
875
- * index. It is assumed that the array has kTensorDimensionLimit elements.
876
- * @returns void
877
- */
878
- inline void indexToCoordinate(const executorch::aten::Tensor &tensor,
879
- size_t index, size_t *coordinate) {
880
- ET_CHECK(index < static_cast<size_t>(tensor.numel()));
881
- for (auto i = 0; i < tensor.dim(); ++i) {
882
- auto dim = tensor.dim() - 1 - i;
883
- size_t dim_size = tensor.size(dim);
884
- coordinate[dim] = index % dim_size;
885
- index /= dim_size;
886
- }
887
- }
888
-
889
- /**
890
- * Extracts an integer value from a scalar Tensor.
891
- *
892
- * @param[in] tensor The source of the value to extract.
893
- * @param[out] out_val The extracted value, on success.
894
- * @returns `true` if a value was extracted, and sets `*out_val` to that
895
- * value. `false` if a value could not be extracted: either it was not an
896
- * integer Scalar Tensor, or the value of that Scalar Tensor could not be
897
- * represented by INT_T.
898
- */
899
- template <typename INT_T,
900
- typename std::enable_if<std::is_integral<INT_T>::value &&
901
- !std::is_same<INT_T, bool>::value,
902
- bool>::type = true>
903
- bool extract_scalar_tensor(executorch::aten::Tensor tensor, INT_T *out_val) {
904
- if (tensor.numel() != 1) {
905
- return false;
906
- }
907
- #define CASE_INT_DTYPE(TENSOR_CTYPE, TENSOR_DTYPE) \
908
- case executorch::aten::ScalarType::TENSOR_DTYPE: { \
909
- const TENSOR_CTYPE val = tensor.const_data_ptr<TENSOR_CTYPE>()[0]; \
910
- if (val < std::numeric_limits<INT_T>::lowest() || \
911
- val > std::numeric_limits<INT_T>::max()) { \
912
- return false; \
913
- } \
914
- *out_val = static_cast<INT_T>(val); \
915
- return true; \
916
- }
917
-
918
- switch (tensor.scalar_type()) {
919
- ET_FORALL_INT_TYPES(CASE_INT_DTYPE);
920
- default:
921
- return false;
922
- }
923
- #undef CASE_INT_DTYPE
924
- }
925
-
926
- /**
927
- * Extracts a floating point value from a scalar Tensor.
928
- *
929
- * @param[in] tensor The source of the value to extract.
930
- * @param[out] out_val The extracted value, on success.
931
- * @returns `true` if a value was extracted, and sets `*out_val` to that
932
- * value. `false` if a value could not be extracted: either it was not a
933
- * floating point Scalar Tensor, or the value of that Scalar Tensor could not
934
- * be represented by FLOAT_T.
935
- */
936
- template <typename FLOAT_T,
937
- typename std::enable_if<
938
- std::is_floating_point_v<FLOAT_T> ||
939
- std::is_same_v<FLOAT_T, executorch::aten::BFloat16> ||
940
- std::is_same_v<FLOAT_T, executorch::aten::Half>,
941
- bool>::type = true>
942
- bool extract_scalar_tensor(executorch::aten::Tensor tensor, FLOAT_T *out_val) {
943
- if (tensor.numel() != 1) {
944
- return false;
945
- }
946
- #define CASE_REAL_DTYPE(TENSOR_CTYPE, TENSOR_DTYPE) \
947
- case executorch::aten::ScalarType::TENSOR_DTYPE: { \
948
- /* ET_FORALL_REAL_TYPES guarantees TENSOR_CTYPE is a real type. */ \
949
- double val = \
950
- static_cast<double>(tensor.const_data_ptr<TENSOR_CTYPE>()[0]); \
951
- if (std::isfinite(val) && (val < std::numeric_limits<FLOAT_T>::lowest() || \
952
- val > std::numeric_limits<FLOAT_T>::max())) { \
953
- return false; \
954
- } \
955
- *out_val = static_cast<FLOAT_T>(val); \
956
- return true; \
957
- }
958
-
959
- switch (tensor.scalar_type()) {
960
- ET_FORALL_REALHBF16_TYPES(CASE_REAL_DTYPE);
961
- default:
962
- return false;
963
- }
964
- #undef CASE_REAL_DTYPE
965
- }
966
-
967
- /**
968
- * Extracts a boolean value from a Scalar.
969
- *
970
- * @param[in] scalar The source of the value to extract.
971
- * @param[out] out_val The extracted value, on success.
972
- * @returns `true` if a value was extracted, and sets `*out_val` to that
973
- * value. `false` if a value could not be extracted, i.e. not a boolean
974
- */
975
- template <typename BOOL_T,
976
- typename std::enable_if<std::is_same<BOOL_T, bool>::value,
977
- bool>::type = true>
978
- bool extract_scalar_tensor(executorch::aten::Tensor tensor, BOOL_T *out_val) {
979
- if (tensor.scalar_type() != executorch::aten::ScalarType::Bool) {
980
- return false;
981
- }
982
- if (tensor.numel() != 1) {
983
- return false;
984
- }
985
-
986
- bool val = tensor.const_data_ptr<bool>()[0];
987
-
988
- *out_val = static_cast<BOOL_T>(val);
989
-
990
- return true;
991
- }
992
-
993
- /// These APIs should not be used outside of Executor.cpp.
994
- namespace internal {
995
- /**
996
- * Share t_src's data_ptr with t_dst.
997
- */
998
- ET_NODISCARD Error share_tensor_data(const executorch::aten::Tensor &t_dst,
999
- const executorch::aten::Tensor &t_src);
1000
-
1001
- /**
1002
- * Copy t_src's data_ptr to t_dst.
1003
- */
1004
- ET_NODISCARD Error copy_tensor_data(const executorch::aten::Tensor &t_dst,
1005
- const executorch::aten::Tensor &t_src);
1006
-
1007
- /**
1008
- * Set the data_ptr of t to buffer.
1009
- */
1010
- ET_NODISCARD Error set_tensor_data(const executorch::aten::Tensor &t,
1011
- void *buffer, size_t buffer_size);
1012
-
1013
- /**
1014
- * Reset tensor's data_ptr, clear all the storage for at::Tensor.
1015
- */
1016
- void reset_data_ptr(const executorch::aten::Tensor &tensor);
1017
-
1018
- /**
1019
- * Resize tensor impl
1020
- */
1021
- ET_NODISCARD Error resize_tensor_impl(
1022
- executorch::aten::TensorImpl *impl,
1023
- executorch::aten::ArrayRef<executorch::aten::SizesType> new_sizes);
1024
-
1025
- } // namespace internal
1026
-
1027
- /**
1028
- * Resize a tensor to new_sizes, rank must stay the same. Currently does not
1029
- * expand the tensor if new size exceeds the current capacity. Currently
1030
- * fails an ET_CHECK if the tensor cannot be resized.
1031
- *
1032
- * WARNING: Placeholder API until discussion around runtime context is
1033
- * settled, will likely move to be a class method on a TensorResizer object
1034
- * passed in through runtimeContext.
1035
- */
1036
- ET_NODISCARD inline Error resize_tensor(
1037
- executorch::aten::Tensor t,
1038
- executorch::aten::ArrayRef<executorch::aten::SizesType> new_sizes) {
1039
- return internal::resize_tensor_impl(t.unsafeGetTensorImpl(), new_sizes);
1040
- }
1041
-
1042
- /**
1043
- * Resize a tensor to new_sizes, rank must stay the same. Currently does not
1044
- * expand the tensor if new size exceeds the current capacity. Currently
1045
- * fails an ET_CHECK if the tensor cannot be resized.
1046
- *
1047
- * WARNING: Placeholder API until discussion around runtime context is
1048
- * settled, will likely move to be a class method on a TensorResizer object
1049
- * passed in through runtimeContext.
1050
- */
1051
- template <typename T, typename std::enable_if<
1052
- !std::is_same<executorch::aten::SizesType, T>::value,
1053
- int>::type = 0>
1054
- ET_NODISCARD inline Error
1055
- resize_tensor(executorch::aten::Tensor t,
1056
- executorch::aten::ArrayRef<T> new_sizes) {
1057
- // Need to cast the input array to an array of Tensor::SizesType
1058
- std::array<executorch::aten::SizesType, kTensorDimensionLimit>
1059
- new_sizes_casted{};
1060
- size_t new_sizes_ndim = new_sizes.size();
1061
- for (size_t i = 0; i < new_sizes_ndim; ++i) {
1062
- new_sizes_casted[i] =
1063
- static_cast<executorch::aten::SizesType>(new_sizes[i]);
1064
- }
1065
-
1066
- return internal::resize_tensor_impl(
1067
- t.unsafeGetTensorImpl(), {new_sizes_casted.data(), new_sizes_ndim});
1068
- }
1069
-
1070
- /// DEPRECATED: Use `resize_tensor()` instead, which can fail non-fatally.
1071
- ET_DEPRECATED inline void
1072
- resize(executorch::aten::Tensor t,
1073
- executorch::aten::ArrayRef<executorch::aten::SizesType> new_sizes) {
1074
- Error err = resize_tensor(t, new_sizes);
1075
- ET_CHECK_MSG(err == Error::Ok,
1076
- "Could not resize Tensor; see logs for details");
1077
- }
1078
- /**
1079
- * Get dim_order of a Tensor and write it to out_dim_order.
1080
- * @param tensor The tensor where we want to get dim order from.
1081
- * @param out_dim_order Pointing to an array of DimOrderType where we write
1082
- * dim order into it.
1083
- * @param out_dim_order_size Size of the DimOrderType array.
1084
- */
1085
- ET_NODISCARD Error get_dim_order(const executorch::aten::Tensor &tensor,
1086
- executorch::aten::DimOrderType *out_dim_order,
1087
- size_t out_dim_order_size);
1088
-
1089
- /**
1090
- * Checks whether a tensor has a valid dim order. If the dim order could not
1091
- * be determined, then this function returns false by default.
1092
- */
1093
- bool tensor_has_valid_dim_order(executorch::aten::Tensor t);
1094
-
1095
- /**
1096
- * Checks whether a tensor has either the default of channels last dim order.
1097
- * If the dim order could not be determined, then this function returns false
1098
- * by default.
1099
- */
1100
- bool tensor_is_default_or_channels_last_dim_order(executorch::aten::Tensor t);
1101
-
1102
- /**
1103
- * Checks whether a tensor has the default dimension order.
1104
- * Logs an error message if the tensor does not meet the expected criteria.
1105
- *
1106
- * @param t The tensor to check the dimension order of.
1107
- * @return True if the tensor has the default dimension order, false otherwise.
1108
- */
1109
- bool tensor_is_default_dim_order(executorch::aten::Tensor t);
1110
-
1111
- /**
1112
- * Checks whether a tensor has the channels last dimension order.
1113
- * Logs an error message if the tensor does not meet the expected criteria.
1114
- *
1115
- * @param t The tensor to check the dimension order of.
1116
- * @return True if the tensor has the channels last dimension order, false
1117
- * otherwise.
1118
- */
1119
- bool tensor_is_channels_last_dim_order(executorch::aten::Tensor t);
1120
-
1121
- /**
1122
- * Asserts that four tensors have the same dim_order
1123
- *
1124
- * Note that this macro only tests dim order, but not others like actual data,
1125
- * sizes, etc.
1126
- *
1127
- */
1128
- bool tensors_have_same_dim_order(
1129
- const executorch::aten::ArrayRef<executorch::aten::Tensor> tensor_list);
1130
-
1131
- /**
1132
- * Asserts that two tensors have the same dim_order
1133
- *
1134
- * Note that this macro only tests dim order, but not others like actual data,
1135
- * sizes, etc.
1136
- */
1137
-
1138
- inline bool tensors_have_same_dim_order(const executorch::aten::Tensor &a,
1139
- const executorch::aten::Tensor &b) {
1140
- executorch::aten::Tensor tensor_list[2] = {a, b};
1141
- return tensors_have_same_dim_order(tensor_list);
1142
- }
1143
-
1144
- /**
1145
- * Asserts that three tensors have the same dim_order
1146
- *
1147
- * Note that this macro only tests dim order, but not others like actual data,
1148
- * sizes, etc.
1149
- *
1150
- */
1151
-
1152
- inline bool tensors_have_same_dim_order(const executorch::aten::Tensor &a,
1153
- const executorch::aten::Tensor &b,
1154
- const executorch::aten::Tensor &c) {
1155
- executorch::aten::Tensor tensor_list[3] = {a, b, c};
1156
- return tensors_have_same_dim_order(tensor_list);
1157
- }
1158
-
1159
- /**
1160
- * Asserts that four tensors have the same dim_order
1161
- *
1162
- * Note that this macro only tests dim order, but not others like actual data,
1163
- * sizes, etc.
1164
- *
1165
- */
1166
-
1167
- inline bool tensors_have_same_dim_order(const executorch::aten::Tensor &a,
1168
- const executorch::aten::Tensor &b,
1169
- const executorch::aten::Tensor &c,
1170
- const executorch::aten::Tensor &d) {
1171
- executorch::aten::Tensor tensor_list[4] = {a, b, c, d};
1172
- return tensors_have_same_dim_order(tensor_list);
1173
- }
1174
-
1175
- /**
1176
- * Given an n-dimensional coordinate array and an array of tensor strides,
1177
- * calculates the linear index that can be used to retrieve the value at the
1178
- * given coordinates.
1179
- * @param coordinate Pointer to the array of coordinates.
1180
- * @param strides Pointer to the array of strides.
1181
- * @param ndim Number of dimensions in the tensor.
1182
- */
1183
- inline size_t
1184
- calculate_linear_index(const executorch::aten::SizesType *coordinate,
1185
- const executorch::aten::StridesType *strides,
1186
- const size_t ndim) {
1187
- size_t index = 0;
1188
- for (size_t i = 0; i < ndim; i++) {
1189
- index += coordinate[i] * strides[i];
1190
- }
1191
- return index;
1192
- }
1193
-
1194
- } // namespace runtime
1195
- } // namespace executorch
1196
-
1197
- namespace torch {
1198
- namespace executor {
1199
- // TODO(T197294990): Remove these deprecated aliases once all users have moved
1200
- // to the new `::executorch` namespaces.
1201
- using ::executorch::runtime::calculate_linear_index;
1202
- using ::executorch::runtime::coordinateToIndex;
1203
- using ::executorch::runtime::dim_is_valid;
1204
- using ::executorch::runtime::extract_scalar_tensor;
1205
- using ::executorch::runtime::get_dim_order;
1206
- using ::executorch::runtime::getLeadingDims;
1207
- using ::executorch::runtime::getTrailingDims;
1208
- using ::executorch::runtime::indexToCoordinate;
1209
- using ::executorch::runtime::kTensorDimensionLimit;
1210
- using ::executorch::runtime::nonempty_size;
1211
- using ::executorch::runtime::nonzero_dim;
1212
- using ::executorch::runtime::resize;
1213
- using ::executorch::runtime::resize_tensor;
1214
- using ::executorch::runtime::tensor_can_cast_to;
1215
- using ::executorch::runtime::tensor_dim_has_index;
1216
- using ::executorch::runtime::tensor_has_dim;
1217
- using ::executorch::runtime::tensor_has_expected_size;
1218
- using ::executorch::runtime::tensor_has_non_empty_dim;
1219
- using ::executorch::runtime::tensor_has_rank_greater_or_equal_to;
1220
- using ::executorch::runtime::tensor_has_rank_smaller_or_equal_to;
1221
- using ::executorch::runtime::tensor_has_valid_dim_order;
1222
- using ::executorch::runtime::tensor_is_bits_type;
1223
- using ::executorch::runtime::tensor_is_bool_type;
1224
- using ::executorch::runtime::tensor_is_complex_type;
1225
- using ::executorch::runtime::tensor_is_contiguous;
1226
- using ::executorch::runtime::tensor_is_default_dim_order;
1227
- using ::executorch::runtime::tensor_is_default_or_channels_last_dim_order;
1228
- using ::executorch::runtime::tensor_is_floating_type;
1229
- using ::executorch::runtime::tensor_is_integral_type;
1230
- using ::executorch::runtime::tensor_is_rank;
1231
- using ::executorch::runtime::tensor_is_real_type;
1232
- using ::executorch::runtime::tensor_is_realh_type;
1233
- using ::executorch::runtime::tensor_is_realhb_type;
1234
- using ::executorch::runtime::tensor_is_scalar;
1235
- using ::executorch::runtime::tensors_have_same_dim_order;
1236
- using ::executorch::runtime::tensors_have_same_dtype;
1237
- using ::executorch::runtime::tensors_have_same_rank;
1238
- using ::executorch::runtime::tensors_have_same_shape;
1239
- using ::executorch::runtime::tensors_have_same_shape_and_dtype;
1240
- using ::executorch::runtime::tensors_have_same_size_at_dims;
1241
- using ::executorch::runtime::tensors_have_same_strides;
1242
- namespace internal {
1243
- using ::executorch::runtime::internal::copy_tensor_data;
1244
- using ::executorch::runtime::internal::reset_data_ptr;
1245
- using ::executorch::runtime::internal::resize_tensor_impl;
1246
- using ::executorch::runtime::internal::set_tensor_data;
1247
- using ::executorch::runtime::internal::share_tensor_data;
1248
- } // namespace internal
1249
- } // namespace executor
1250
- } // namespace torch