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.
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +1 -0
- package/android/src/main/cpp/CMakeLists.txt +25 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/RnExecutorchPackage.kt +1 -13
- package/common/rnexecutorch/RnExecutorchInstaller.cpp +52 -18
- package/common/rnexecutorch/RnExecutorchInstaller.h +0 -25
- package/common/rnexecutorch/TokenizerModule.cpp +1 -1
- package/common/rnexecutorch/TokenizerModule.h +4 -1
- package/common/rnexecutorch/data_processing/FileUtils.h +2 -2
- package/common/rnexecutorch/data_processing/ImageProcessing.cpp +5 -5
- package/common/rnexecutorch/data_processing/ImageProcessing.h +2 -2
- package/common/rnexecutorch/data_processing/Numerical.cpp +13 -0
- package/common/rnexecutorch/host_objects/JsiConversions.h +43 -62
- package/common/rnexecutorch/host_objects/ModelHostObject.h +43 -24
- package/common/rnexecutorch/metaprogramming/ConstructorHelpers.h +8 -6
- package/common/rnexecutorch/metaprogramming/FunctionHelpers.h +1 -1
- package/common/rnexecutorch/models/BaseModel.cpp +2 -2
- package/common/rnexecutorch/models/BaseModel.h +5 -0
- package/common/rnexecutorch/models/EncoderDecoderBase.cpp +2 -2
- package/common/rnexecutorch/models/EncoderDecoderBase.h +2 -2
- package/common/rnexecutorch/models/classification/Classification.cpp +6 -6
- package/common/rnexecutorch/models/classification/Classification.h +5 -0
- package/common/rnexecutorch/models/classification/Constants.h +3 -3
- package/common/rnexecutorch/models/embeddings/BaseEmbeddings.cpp +2 -2
- package/common/rnexecutorch/models/embeddings/BaseEmbeddings.h +2 -2
- package/common/rnexecutorch/models/embeddings/image/ImageEmbeddings.cpp +3 -3
- package/common/rnexecutorch/models/embeddings/image/ImageEmbeddings.h +5 -0
- package/common/rnexecutorch/models/embeddings/text/TextEmbeddings.cpp +2 -2
- package/common/rnexecutorch/models/embeddings/text/TextEmbeddings.h +6 -1
- package/common/rnexecutorch/models/image_segmentation/Constants.h +3 -3
- package/common/rnexecutorch/models/image_segmentation/ImageSegmentation.cpp +6 -5
- package/common/rnexecutorch/models/image_segmentation/ImageSegmentation.h +8 -1
- package/common/rnexecutorch/models/llm/LLM.cpp +58 -0
- package/common/rnexecutorch/models/llm/LLM.h +35 -0
- package/common/rnexecutorch/models/object_detection/Constants.h +3 -3
- package/common/rnexecutorch/models/object_detection/ObjectDetection.cpp +8 -8
- package/common/rnexecutorch/models/object_detection/ObjectDetection.h +11 -5
- package/common/rnexecutorch/models/object_detection/Types.h +13 -0
- package/common/rnexecutorch/models/object_detection/Utils.cpp +13 -11
- package/common/rnexecutorch/models/object_detection/Utils.h +7 -13
- package/common/rnexecutorch/models/ocr/CTCLabelConverter.cpp +2 -2
- package/common/rnexecutorch/models/ocr/CTCLabelConverter.h +2 -2
- package/common/rnexecutorch/models/ocr/Constants.h +33 -26
- package/common/rnexecutorch/models/ocr/Detector.cpp +20 -22
- package/common/rnexecutorch/models/ocr/Detector.h +4 -4
- package/common/rnexecutorch/models/ocr/OCR.cpp +9 -8
- package/common/rnexecutorch/models/ocr/OCR.h +11 -3
- package/common/rnexecutorch/models/ocr/RecognitionHandler.cpp +20 -19
- package/common/rnexecutorch/models/ocr/RecognitionHandler.h +9 -7
- package/common/rnexecutorch/models/ocr/Recognizer.cpp +7 -7
- package/common/rnexecutorch/models/ocr/Recognizer.h +2 -2
- package/common/rnexecutorch/models/ocr/Types.h +4 -6
- package/common/rnexecutorch/models/ocr/{DetectorUtils.cpp → utils/DetectorUtils.cpp} +70 -63
- package/common/rnexecutorch/models/ocr/{DetectorUtils.h → utils/DetectorUtils.h} +12 -11
- package/common/rnexecutorch/models/ocr/{RecognitionHandlerUtils.cpp → utils/RecognitionHandlerUtils.cpp} +14 -11
- package/common/rnexecutorch/models/ocr/{RecognitionHandlerUtils.h → utils/RecognitionHandlerUtils.h} +5 -5
- package/common/rnexecutorch/models/ocr/{RecognizerUtils.cpp → utils/RecognizerUtils.cpp} +28 -26
- package/common/rnexecutorch/models/ocr/{RecognizerUtils.h → utils/RecognizerUtils.h} +15 -14
- package/common/rnexecutorch/models/speech_to_text/SpeechToText.cpp +2 -2
- package/common/rnexecutorch/models/speech_to_text/SpeechToText.h +9 -2
- package/common/rnexecutorch/models/speech_to_text/SpeechToTextStrategy.h +2 -2
- package/common/rnexecutorch/models/speech_to_text/WhisperStrategy.cpp +2 -2
- package/common/rnexecutorch/models/speech_to_text/WhisperStrategy.h +2 -2
- package/common/rnexecutorch/models/style_transfer/StyleTransfer.cpp +5 -5
- package/common/rnexecutorch/models/style_transfer/StyleTransfer.h +6 -0
- package/common/rnexecutorch/models/vertical_ocr/VerticalDetector.cpp +23 -22
- package/common/rnexecutorch/models/vertical_ocr/VerticalDetector.h +4 -4
- package/common/rnexecutorch/models/vertical_ocr/VerticalOCR.cpp +34 -34
- package/common/rnexecutorch/models/vertical_ocr/VerticalOCR.h +27 -20
- package/{third-party/ios/ExecutorchLib/ExecutorchLib/sampler → common/runner}/sampler.cpp +3 -2
- package/{third-party/ios/ExecutorchLib/ExecutorchLib/sampler → common/runner}/sampler.h +3 -2
- package/ios/libs/executorch/libbackend_coreml_ios.a +0 -0
- package/ios/libs/executorch/libbackend_coreml_simulator.a +0 -0
- package/{third-party/ios/ExecutorchLib/frameworks/backend_mps.xcframework/ios-arm64 → ios/libs/executorch}/libbackend_mps_ios.a +0 -0
- package/{third-party/ios/ExecutorchLib/frameworks/backend_mps.xcframework/ios-arm64-simulator → ios/libs/executorch}/libbackend_mps_simulator.a +0 -0
- package/ios/libs/executorch/libbackend_xnnpack_ios.a +0 -0
- package/ios/libs/executorch/libbackend_xnnpack_simulator.a +0 -0
- package/ios/libs/executorch/libexecutorch_ios.a +0 -0
- package/ios/libs/executorch/libexecutorch_simulator.a +0 -0
- package/ios/libs/executorch/libkernels_custom_ios.a +0 -0
- package/ios/libs/executorch/libkernels_custom_simulator.a +0 -0
- package/ios/libs/executorch/libkernels_optimized_ios.a +0 -0
- package/ios/libs/executorch/libkernels_optimized_simulator.a +0 -0
- package/ios/libs/executorch/libkernels_portable_ios.a +0 -0
- package/ios/libs/executorch/libkernels_portable_simulator.a +0 -0
- package/ios/libs/executorch/libkernels_quantized_ios.a +0 -0
- package/ios/libs/executorch/libkernels_quantized_simulator.a +0 -0
- package/ios/libs/tokenizers-cpp/physical-arm64-release/libsentencepiece.a +0 -0
- package/ios/{ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/ExecutorchLib → libs/tokenizers-cpp/physical-arm64-release/libtokenizers_c.a} +0 -0
- package/ios/libs/tokenizers-cpp/physical-arm64-release/libtokenizers_cpp.a +0 -0
- package/ios/libs/tokenizers-cpp/simulator-arm64-debug/libsentencepiece.a +0 -0
- package/ios/{ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/ExecutorchLib → libs/tokenizers-cpp/simulator-arm64-debug/libtokenizers_c.a} +0 -0
- package/ios/libs/tokenizers-cpp/simulator-arm64-debug/libtokenizers_cpp.a +0 -0
- package/lib/Error.js +53 -0
- package/lib/ThreadPool.d.ts +10 -0
- package/lib/ThreadPool.js +28 -0
- package/lib/common/Logger.d.ts +8 -0
- package/lib/common/Logger.js +19 -0
- package/lib/constants/directories.js +2 -0
- package/lib/constants/llmDefaults.d.ts +6 -0
- package/lib/constants/llmDefaults.js +16 -0
- package/lib/constants/modelUrls.d.ts +223 -0
- package/lib/constants/modelUrls.js +322 -0
- package/lib/constants/ocr/models.d.ts +882 -0
- package/lib/constants/ocr/models.js +182 -0
- package/lib/constants/ocr/symbols.js +139 -0
- package/lib/constants/sttDefaults.d.ts +28 -0
- package/lib/constants/sttDefaults.js +68 -0
- package/lib/controllers/LLMController.d.ts +47 -0
- package/lib/controllers/LLMController.js +213 -0
- package/lib/controllers/OCRController.js +67 -0
- package/lib/controllers/SpeechToTextController.d.ts +56 -0
- package/lib/controllers/SpeechToTextController.js +349 -0
- package/lib/controllers/VerticalOCRController.js +70 -0
- package/lib/hooks/computer_vision/useClassification.d.ts +15 -0
- package/lib/hooks/computer_vision/useClassification.js +7 -0
- package/lib/hooks/computer_vision/useImageEmbeddings.d.ts +15 -0
- package/lib/hooks/computer_vision/useImageEmbeddings.js +7 -0
- package/lib/hooks/computer_vision/useImageSegmentation.d.ts +38 -0
- package/lib/hooks/computer_vision/useImageSegmentation.js +7 -0
- package/lib/hooks/computer_vision/useOCR.d.ts +20 -0
- package/lib/hooks/computer_vision/useOCR.js +41 -0
- package/lib/hooks/computer_vision/useObjectDetection.d.ts +15 -0
- package/lib/hooks/computer_vision/useObjectDetection.js +7 -0
- package/lib/hooks/computer_vision/useStyleTransfer.d.ts +15 -0
- package/lib/hooks/computer_vision/useStyleTransfer.js +7 -0
- package/lib/hooks/computer_vision/useVerticalOCR.d.ts +21 -0
- package/lib/hooks/computer_vision/useVerticalOCR.js +43 -0
- package/lib/hooks/general/useExecutorchModule.d.ts +13 -0
- package/lib/hooks/general/useExecutorchModule.js +7 -0
- package/lib/hooks/natural_language_processing/useLLM.d.ts +10 -0
- package/lib/hooks/natural_language_processing/useLLM.js +78 -0
- package/lib/hooks/natural_language_processing/useSpeechToText.d.ts +27 -0
- package/lib/hooks/natural_language_processing/useSpeechToText.js +49 -0
- package/lib/hooks/natural_language_processing/useTextEmbeddings.d.ts +16 -0
- package/lib/hooks/natural_language_processing/useTextEmbeddings.js +7 -0
- package/lib/hooks/natural_language_processing/useTokenizer.d.ts +17 -0
- package/lib/hooks/natural_language_processing/useTokenizer.js +52 -0
- package/lib/hooks/useModule.js +45 -0
- package/lib/hooks/useNonStaticModule.d.ts +20 -0
- package/lib/hooks/useNonStaticModule.js +49 -0
- package/lib/index.d.ts +48 -0
- package/lib/index.js +58 -0
- package/lib/module/controllers/LLMController.js +6 -10
- package/lib/module/controllers/LLMController.js.map +1 -1
- package/lib/module/hooks/computer_vision/useClassification.js +2 -2
- package/lib/module/hooks/computer_vision/useClassification.js.map +1 -1
- package/lib/module/hooks/computer_vision/useImageEmbeddings.js +2 -2
- package/lib/module/hooks/computer_vision/useImageEmbeddings.js.map +1 -1
- package/lib/module/hooks/computer_vision/useImageSegmentation.js +2 -2
- package/lib/module/hooks/computer_vision/useImageSegmentation.js.map +1 -1
- package/lib/module/hooks/computer_vision/useObjectDetection.js +2 -2
- package/lib/module/hooks/computer_vision/useObjectDetection.js.map +1 -1
- package/lib/module/hooks/computer_vision/useStyleTransfer.js +2 -2
- package/lib/module/hooks/computer_vision/useStyleTransfer.js.map +1 -1
- package/lib/module/hooks/general/useExecutorchModule.js +2 -2
- package/lib/module/hooks/general/useExecutorchModule.js.map +1 -1
- package/lib/module/hooks/natural_language_processing/useTextEmbeddings.js +2 -2
- package/lib/module/hooks/natural_language_processing/useTextEmbeddings.js.map +1 -1
- package/lib/module/hooks/useModule.js +13 -9
- package/lib/module/hooks/useModule.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/modules/BaseModule.js +9 -17
- package/lib/module/modules/BaseModule.js.map +1 -1
- package/lib/module/modules/computer_vision/ClassificationModule.js +2 -2
- package/lib/module/modules/computer_vision/ClassificationModule.js.map +1 -1
- package/lib/module/modules/computer_vision/ImageEmbeddingsModule.js +2 -2
- package/lib/module/modules/computer_vision/ImageEmbeddingsModule.js.map +1 -1
- package/lib/module/modules/computer_vision/ImageSegmentationModule.js +2 -2
- package/lib/module/modules/computer_vision/ImageSegmentationModule.js.map +1 -1
- package/lib/module/modules/computer_vision/ObjectDetectionModule.js +2 -2
- package/lib/module/modules/computer_vision/ObjectDetectionModule.js.map +1 -1
- package/lib/module/modules/computer_vision/StyleTransferModule.js +2 -2
- package/lib/module/modules/computer_vision/StyleTransferModule.js.map +1 -1
- package/lib/module/modules/general/ExecutorchModule.js +2 -2
- package/lib/module/modules/general/ExecutorchModule.js.map +1 -1
- package/lib/module/modules/natural_language_processing/TextEmbeddingsModule.js +2 -2
- package/lib/module/modules/natural_language_processing/TextEmbeddingsModule.js.map +1 -1
- package/lib/module/native/RnExecutorchModules.js +1 -2
- package/lib/module/native/RnExecutorchModules.js.map +1 -1
- package/lib/module/utils/ResourceFetcher.js +6 -8
- package/lib/module/utils/ResourceFetcher.js.map +1 -1
- package/lib/module/utils/ResourceFetcherUtils.js +20 -20
- package/lib/module/utils/ResourceFetcherUtils.js.map +1 -1
- package/lib/module/utils/SpeechToTextModule/ASR.js +3 -3
- package/lib/module/utils/SpeechToTextModule/ASR.js.map +1 -1
- package/lib/modules/BaseModule.js +25 -0
- package/lib/modules/BaseNonStaticModule.js +14 -0
- package/lib/modules/computer_vision/ClassificationModule.d.ts +8 -0
- package/lib/modules/computer_vision/ClassificationModule.js +17 -0
- package/lib/modules/computer_vision/ImageEmbeddingsModule.d.ts +8 -0
- package/lib/modules/computer_vision/ImageEmbeddingsModule.js +17 -0
- package/lib/modules/computer_vision/ImageSegmentationModule.d.ts +11 -0
- package/lib/modules/computer_vision/ImageSegmentationModule.js +27 -0
- package/lib/modules/computer_vision/OCRModule.d.ts +14 -0
- package/lib/modules/computer_vision/OCRModule.js +17 -0
- package/lib/modules/computer_vision/ObjectDetectionModule.d.ts +9 -0
- package/lib/modules/computer_vision/ObjectDetectionModule.js +17 -0
- package/lib/modules/computer_vision/StyleTransferModule.d.ts +8 -0
- package/lib/modules/computer_vision/StyleTransferModule.js +17 -0
- package/lib/modules/computer_vision/VerticalOCRModule.d.ts +14 -0
- package/lib/modules/computer_vision/VerticalOCRModule.js +19 -0
- package/lib/modules/general/ExecutorchModule.d.ts +7 -0
- package/lib/modules/general/ExecutorchModule.js +14 -0
- package/lib/modules/natural_language_processing/LLMModule.d.ts +28 -0
- package/lib/modules/natural_language_processing/LLMModule.js +45 -0
- package/lib/modules/natural_language_processing/SpeechToTextModule.d.ts +24 -0
- package/lib/modules/natural_language_processing/SpeechToTextModule.js +36 -0
- package/lib/modules/natural_language_processing/TextEmbeddingsModule.d.ts +9 -0
- package/lib/modules/natural_language_processing/TextEmbeddingsModule.js +21 -0
- package/lib/modules/natural_language_processing/TokenizerModule.d.ts +12 -0
- package/lib/modules/natural_language_processing/TokenizerModule.js +30 -0
- package/lib/native/NativeETInstaller.js +2 -0
- package/lib/native/NativeOCR.js +2 -0
- package/lib/native/NativeVerticalOCR.js +2 -0
- package/lib/native/RnExecutorchModules.d.ts +7 -0
- package/lib/native/RnExecutorchModules.js +18 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/common.d.ts +32 -0
- package/lib/types/common.js +25 -0
- package/lib/types/imageSegmentation.js +26 -0
- package/lib/types/llm.d.ts +46 -0
- package/lib/types/llm.js +9 -0
- package/lib/types/objectDetection.js +94 -0
- package/lib/types/ocr.js +1 -0
- package/lib/types/stt.d.ts +94 -0
- package/lib/types/stt.js +85 -0
- package/lib/typescript/controllers/LLMController.d.ts +1 -1
- package/lib/typescript/controllers/LLMController.d.ts.map +1 -1
- package/lib/typescript/hooks/useModule.d.ts +8 -5
- package/lib/typescript/hooks/useModule.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/modules/BaseModule.d.ts +7 -6
- package/lib/typescript/modules/BaseModule.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/ClassificationModule.d.ts +2 -2
- package/lib/typescript/modules/computer_vision/ClassificationModule.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/ImageEmbeddingsModule.d.ts +2 -2
- package/lib/typescript/modules/computer_vision/ImageEmbeddingsModule.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/ImageSegmentationModule.d.ts +2 -2
- package/lib/typescript/modules/computer_vision/ImageSegmentationModule.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/ObjectDetectionModule.d.ts +2 -2
- package/lib/typescript/modules/computer_vision/ObjectDetectionModule.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/StyleTransferModule.d.ts +2 -2
- package/lib/typescript/modules/computer_vision/StyleTransferModule.d.ts.map +1 -1
- package/lib/typescript/modules/general/ExecutorchModule.d.ts +2 -2
- package/lib/typescript/modules/general/ExecutorchModule.d.ts.map +1 -1
- package/lib/typescript/modules/natural_language_processing/TextEmbeddingsModule.d.ts +2 -2
- package/lib/typescript/modules/natural_language_processing/TextEmbeddingsModule.d.ts.map +1 -1
- package/lib/typescript/native/RnExecutorchModules.d.ts +1 -3
- package/lib/typescript/native/RnExecutorchModules.d.ts.map +1 -1
- package/lib/typescript/utils/ResourceFetcher.d.ts.map +1 -1
- package/lib/typescript/utils/ResourceFetcherUtils.d.ts.map +1 -1
- package/lib/utils/ResourceFetcher.d.ts +24 -0
- package/lib/utils/ResourceFetcher.js +305 -0
- package/lib/utils/ResourceFetcherUtils.d.ts +54 -0
- package/lib/utils/ResourceFetcherUtils.js +127 -0
- package/lib/utils/llm.d.ts +6 -0
- package/lib/utils/llm.js +72 -0
- package/lib/utils/stt.js +21 -0
- package/package.json +1 -2
- package/react-native-executorch.podspec +47 -44
- package/src/controllers/LLMController.ts +8 -13
- package/src/hooks/computer_vision/useClassification.ts +2 -2
- package/src/hooks/computer_vision/useImageEmbeddings.ts +2 -2
- package/src/hooks/computer_vision/useImageSegmentation.ts +2 -2
- package/src/hooks/computer_vision/useObjectDetection.ts +2 -2
- package/src/hooks/computer_vision/useStyleTransfer.ts +2 -2
- package/src/hooks/general/useExecutorchModule.ts +2 -2
- package/src/hooks/natural_language_processing/useTextEmbeddings.ts +2 -2
- package/src/hooks/useModule.ts +23 -13
- package/src/index.ts +3 -2
- package/src/modules/BaseModule.ts +17 -28
- package/src/modules/computer_vision/ClassificationModule.ts +2 -2
- package/src/modules/computer_vision/ImageEmbeddingsModule.ts +2 -2
- package/src/modules/computer_vision/ImageSegmentationModule.ts +2 -2
- package/src/modules/computer_vision/ObjectDetectionModule.ts +2 -2
- package/src/modules/computer_vision/StyleTransferModule.ts +2 -2
- package/src/modules/general/ExecutorchModule.ts +2 -2
- package/src/modules/natural_language_processing/TextEmbeddingsModule.ts +2 -2
- package/src/native/RnExecutorchModules.ts +1 -5
- package/src/utils/ResourceFetcher.ts +9 -7
- package/src/utils/ResourceFetcherUtils.ts +15 -17
- package/src/utils/SpeechToTextModule/ASR.ts +4 -4
- package/third-party/android/libs/cpuinfo/arm64-v8a/libcpuinfo.so +0 -0
- package/third-party/android/libs/pthreadpool/arm64-v8a/libpthreadpool.so +0 -0
- package/third-party/include/cpuinfo/cpuinfo.h +2305 -0
- package/third-party/include/executorch/extension/threadpool/cpuinfo_utils.h +26 -0
- package/third-party/include/executorch/extension/threadpool/threadpool.h +94 -0
- package/third-party/include/pthreadpool/pthreadpool.h +2236 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/LLM.kt +0 -63
- package/ios/ExecutorchLib.xcframework/Info.plist +0 -43
- package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Headers/ETModel.h +0 -27
- package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Headers/HuggingFaceTokenizer.h +0 -14
- package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Headers/LLaMARunner.h +0 -32
- package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Info.plist +0 -0
- package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Headers/ETModel.h +0 -27
- package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Headers/HuggingFaceTokenizer.h +0 -14
- package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Headers/LLaMARunner.h +0 -32
- package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Info.plist +0 -0
- package/ios/RnExecutorch/LLM.h +0 -5
- package/ios/RnExecutorch/LLM.mm +0 -78
- package/ios/RnExecutorch.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/RnExecutorch.xcodeproj/project.xcworkspace/xcuserdata/jakubchmura.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RnExecutorch.xcodeproj/xcuserdata/jakubchmura.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/lib/module/modules/BaseNonStaticModule.js +0 -17
- package/lib/module/modules/BaseNonStaticModule.js.map +0 -1
- package/lib/module/native/NativeLLM.js +0 -5
- package/lib/module/native/NativeLLM.js.map +0 -1
- package/lib/typescript/modules/BaseNonStaticModule.d.ts +0 -10
- package/lib/typescript/modules/BaseNonStaticModule.d.ts.map +0 -1
- package/lib/typescript/native/NativeLLM.d.ts +0 -12
- package/lib/typescript/native/NativeLLM.d.ts.map +0 -1
- package/src/modules/BaseNonStaticModule.ts +0 -26
- package/src/native/NativeLLM.ts +0 -14
- package/third-party/include/tokenizers-cpp/tokenizers_c.h +0 -61
- package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/ETModel.h +0 -27
- package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/ETModel.mm +0 -249
- package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/HuggingFaceTokenizer.h +0 -14
- package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/HuggingFaceTokenizer.mm +0 -80
- package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/LLaMARunner.h +0 -32
- package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/LLaMARunner.mm +0 -95
- package/third-party/ios/ExecutorchLib/ExecutorchLib/InputType.h +0 -12
- package/third-party/ios/ExecutorchLib/ExecutorchLib/Utils.hpp +0 -217
- package/third-party/ios/ExecutorchLib/ExecutorchLib/model/Model.cpp +0 -11
- package/third-party/ios/ExecutorchLib/ExecutorchLib/model/Model.h +0 -11
- package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/base64.h +0 -202
- package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/bpe_tokenizer.cpp +0 -313
- package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/bpe_tokenizer.h +0 -57
- package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/llama_tiktoken.cpp +0 -78
- package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/llama_tiktoken.h +0 -23
- package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/tiktoken.cpp +0 -427
- package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/tiktoken.h +0 -87
- package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/tokenizer.h +0 -76
- package/third-party/ios/ExecutorchLib/ExecutorchLib.xcodeproj/project.pbxproj +0 -683
- package/third-party/ios/ExecutorchLib/ExecutorchLib.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/third-party/ios/ExecutorchLib/ExecutorchLib.xcodeproj/project.xcworkspace/xcuserdata/jakubchmura.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/third-party/ios/ExecutorchLib/ExecutorchLib.xcodeproj/xcuserdata/jakubchmura.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/third-party/ios/ExecutorchLib/build.sh +0 -44
- package/third-party/ios/ExecutorchLib/frameworks/backend_coreml.xcframework/Info.plist +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/backend_coreml.xcframework/ios-arm64/libbackend_coreml_ios.a +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/backend_coreml.xcframework/ios-arm64-simulator/libbackend_coreml_simulator.a +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/backend_mps.xcframework/Info.plist +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/backend_xnnpack.xcframework/Info.plist +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/backend_xnnpack.xcframework/ios-arm64/libbackend_xnnpack_ios.a +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/backend_xnnpack.xcframework/ios-arm64-simulator/libbackend_xnnpack_simulator.a +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/Info.plist +0 -47
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/macros/Export.h +0 -163
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/macros/Macros.h +0 -497
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/BFloat16-inl.h +0 -342
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/BFloat16-math.h +0 -266
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/BFloat16.h +0 -125
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/Half-inl.h +0 -347
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/Half.h +0 -416
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/TypeSafeSignMath.h +0 -133
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/bit_cast.h +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/floating_point_utils.h +0 -33
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/irange.h +0 -107
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorch.h +0 -13
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchError.h +0 -16
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchLog.h +0 -76
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchModule.h +0 -286
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchTensor.h +0 -742
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchValue.h +0 -219
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/module/module.h +0 -492
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/tensor/tensor.h +0 -13
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/tensor/tensor_accessor.h +0 -190
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/tensor/tensor_ptr.h +0 -347
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/tensor/tensor_ptr_maker.h +0 -653
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/backend/backend_execution_context.h +0 -71
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/backend/backend_init_context.h +0 -72
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/backend/interface.h +0 -166
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/array_ref.h +0 -235
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/data_loader.h +0 -136
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/defines.h +0 -20
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/error.h +0 -229
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/evalue.h +0 -521
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/event_tracer.h +0 -565
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/event_tracer_hooks.h +0 -323
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/event_tracer_hooks_delegate.h +0 -197
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/exec_aten.h +0 -147
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/util/dim_order_util.h +0 -263
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/util/scalar_type_util.h +0 -1331
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/util/tensor_dimension_limit.h +0 -21
- 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
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/util/tensor_util.h +0 -1250
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/freeable_buffer.h +0 -107
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/hierarchical_allocator.h +0 -107
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/memory_allocator.h +0 -198
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/named_data_map.h +0 -86
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/bfloat16.h +0 -27
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/bfloat16_math.h +0 -14
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/bits_types.h +0 -83
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/macros/Export.h +0 -163
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/macros/Macros.h +0 -497
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-inl.h +0 -342
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-math.h +0 -266
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16.h +0 -125
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/Half-inl.h +0 -347
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/Half.h +0 -416
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/TypeSafeSignMath.h +0 -133
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/bit_cast.h +0 -43
- 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
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/irange.h +0 -107
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/complex.h +0 -44
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/device.h +0 -70
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/half.h +0 -27
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/optional.h +0 -36
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/qint_types.h +0 -83
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/scalar.h +0 -110
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/scalar_type.h +0 -154
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/string_view.h +0 -29
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/tensor.h +0 -142
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/tensor_impl.h +0 -261
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/tensor_options.h +0 -60
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/result.h +0 -258
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/span.h +0 -93
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/tag.h +0 -71
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/tensor_layout.h +0 -79
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/tensor_shape_dynamism.h +0 -39
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/memory_manager.h +0 -113
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/method.h +0 -387
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/method_meta.h +0 -251
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/program.h +0 -320
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/pte_data_map.h +0 -144
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/tensor_parser.h +0 -156
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/kernel/kernel_runtime_context.h +0 -122
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/kernel/operator_registry.h +0 -278
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/abort.h +0 -36
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/assert.h +0 -119
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/clock.h +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/compat_unistd.h +0 -75
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/compiler.h +0 -191
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/log.h +0 -177
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/platform.h +0 -133
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/profiler.h +0 -292
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/runtime.h +0 -35
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/system.h +0 -49
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/types.h +0 -24
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/schema/extended_header.h +0 -76
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/module.modulemap +0 -5
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/libexecutorch_ios.a +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/macros/Export.h +0 -163
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/macros/Macros.h +0 -497
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/BFloat16-inl.h +0 -342
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/BFloat16-math.h +0 -266
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/BFloat16.h +0 -125
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/Half-inl.h +0 -347
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/Half.h +0 -416
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/TypeSafeSignMath.h +0 -133
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/bit_cast.h +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/floating_point_utils.h +0 -33
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/irange.h +0 -107
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorch.h +0 -13
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchError.h +0 -16
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchLog.h +0 -76
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchModule.h +0 -286
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchTensor.h +0 -742
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchValue.h +0 -219
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/module/module.h +0 -492
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/tensor/tensor.h +0 -13
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/tensor/tensor_accessor.h +0 -190
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/tensor/tensor_ptr.h +0 -347
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/tensor/tensor_ptr_maker.h +0 -653
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/backend/backend_execution_context.h +0 -71
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/backend/backend_init_context.h +0 -72
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/backend/interface.h +0 -166
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/array_ref.h +0 -235
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/data_loader.h +0 -136
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/defines.h +0 -20
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/error.h +0 -229
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/evalue.h +0 -521
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/event_tracer.h +0 -565
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/event_tracer_hooks.h +0 -323
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/event_tracer_hooks_delegate.h +0 -197
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/exec_aten.h +0 -147
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/util/dim_order_util.h +0 -263
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/util/scalar_type_util.h +0 -1331
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/util/tensor_dimension_limit.h +0 -21
- 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
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/util/tensor_util.h +0 -1250
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/freeable_buffer.h +0 -107
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/hierarchical_allocator.h +0 -107
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/memory_allocator.h +0 -198
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/named_data_map.h +0 -86
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/bfloat16.h +0 -27
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/bfloat16_math.h +0 -14
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/bits_types.h +0 -83
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/macros/Export.h +0 -163
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/macros/Macros.h +0 -497
- 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
- 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
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16.h +0 -125
- 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
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/Half.h +0 -416
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/TypeSafeSignMath.h +0 -133
- 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
- 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
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/irange.h +0 -107
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/complex.h +0 -44
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/device.h +0 -70
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/half.h +0 -27
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/optional.h +0 -36
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/qint_types.h +0 -83
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/scalar.h +0 -110
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/scalar_type.h +0 -154
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/string_view.h +0 -29
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/tensor.h +0 -142
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/tensor_impl.h +0 -261
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/tensor_options.h +0 -60
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/result.h +0 -258
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/span.h +0 -93
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/tag.h +0 -71
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/tensor_layout.h +0 -79
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/tensor_shape_dynamism.h +0 -39
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/memory_manager.h +0 -113
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/method.h +0 -387
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/method_meta.h +0 -251
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/program.h +0 -320
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/pte_data_map.h +0 -144
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/tensor_parser.h +0 -156
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/kernel/kernel_runtime_context.h +0 -122
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/kernel/operator_registry.h +0 -278
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/abort.h +0 -36
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/assert.h +0 -119
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/clock.h +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/compat_unistd.h +0 -75
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/compiler.h +0 -191
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/log.h +0 -177
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/platform.h +0 -133
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/profiler.h +0 -292
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/runtime.h +0 -35
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/system.h +0 -49
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/types.h +0 -24
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/schema/extended_header.h +0 -76
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/module.modulemap +0 -5
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/libexecutorch_simulator.a +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/kernels_custom.xcframework/Info.plist +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/kernels_custom.xcframework/ios-arm64/libkernels_custom_ios.a +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/kernels_custom.xcframework/ios-arm64-simulator/libkernels_custom_simulator.a +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/kernels_optimized.xcframework/Info.plist +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/kernels_optimized.xcframework/ios-arm64/libkernels_optimized_ios.a +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/kernels_optimized.xcframework/ios-arm64-simulator/libkernels_optimized_simulator.a +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/kernels_portable.xcframework/Info.plist +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/kernels_portable.xcframework/ios-arm64/libkernels_portable_ios.a +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/kernels_portable.xcframework/ios-arm64-simulator/libkernels_portable_simulator.a +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/kernels_quantized.xcframework/Info.plist +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/kernels_quantized.xcframework/ios-arm64/libkernels_quantized_ios.a +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/kernels_quantized.xcframework/ios-arm64-simulator/libkernels_quantized_simulator.a +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/Info.plist +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/bitmap256.h +0 -82
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/filtered_re2.h +0 -111
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/pod_array.h +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/prefilter.h +0 -130
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/prefilter_tree.h +0 -139
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/prog.h +0 -483
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/re2.h +0 -994
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/regexp.h +0 -692
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/set.h +0 -85
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/sparse_array.h +0 -367
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/sparse_set.h +0 -241
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/stringpiece.h +0 -205
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/unicode_casefold.h +0 -78
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/unicode_groups.h +0 -64
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/walker-inl.h +0 -235
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Info.plist +0 -26
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/re2 +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/bitmap256.h +0 -82
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/filtered_re2.h +0 -111
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/pod_array.h +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/prefilter.h +0 -130
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/prefilter_tree.h +0 -139
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/prog.h +0 -483
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/re2.h +0 -994
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/regexp.h +0 -692
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/set.h +0 -85
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/sparse_array.h +0 -367
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/sparse_set.h +0 -241
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/stringpiece.h +0 -205
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/unicode_casefold.h +0 -78
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/unicode_groups.h +0 -64
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/walker-inl.h +0 -235
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Info.plist +0 -26
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/re2 +0 -0
- /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/irunner.h +0 -0
- /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/runner.cpp +0 -0
- /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/runner.h +0 -0
- /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/stats.h +0 -0
- /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/text_decoder_runner.cpp +0 -0
- /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/text_decoder_runner.h +0 -0
- /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/text_prefiller.cpp +0 -0
- /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/text_prefiller.h +0 -0
- /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/text_token_generator.h +0 -0
- /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/util.h +0 -0
|
@@ -1,202 +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
|
-
// @lint-ignore-every LICENSELINT
|
|
9
|
-
/**************************************************************************
|
|
10
|
-
Copyright (c) 2023 sewenew
|
|
11
|
-
|
|
12
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
-
you may not use this file except in compliance with the License.
|
|
14
|
-
You may obtain a copy of the License at
|
|
15
|
-
|
|
16
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
-
|
|
18
|
-
Unless required by applicable law or agreed to in writing, software
|
|
19
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
-
See the License for the specific language governing permissions and
|
|
22
|
-
limitations under the License.
|
|
23
|
-
*************************************************************************/
|
|
24
|
-
|
|
25
|
-
#pragma once
|
|
26
|
-
|
|
27
|
-
#include <cassert>
|
|
28
|
-
#include <executorch/runtime/core/error.h>
|
|
29
|
-
#include <executorch/runtime/core/result.h>
|
|
30
|
-
#include <executorch/runtime/platform/assert.h>
|
|
31
|
-
#include <string>
|
|
32
|
-
#include <string_view>
|
|
33
|
-
|
|
34
|
-
namespace executorch {
|
|
35
|
-
namespace extension {
|
|
36
|
-
namespace llm {
|
|
37
|
-
using Error = executorch::runtime::Error;
|
|
38
|
-
template <typename T> using Result = executorch::runtime::Result<T>;
|
|
39
|
-
|
|
40
|
-
namespace base64 {
|
|
41
|
-
|
|
42
|
-
Result<std::string> decode(const std::string_view &input);
|
|
43
|
-
|
|
44
|
-
namespace detail {
|
|
45
|
-
|
|
46
|
-
constexpr uint32_t DECODE_TABLE[] = {
|
|
47
|
-
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
|
48
|
-
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
|
49
|
-
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 255,
|
|
50
|
-
255, 255, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255,
|
|
51
|
-
255, 255, 255, 255, 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
|
52
|
-
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
|
|
53
|
-
25, 255, 255, 255, 255, 255, 255, 26, 27, 28, 29, 30, 31, 32, 33,
|
|
54
|
-
34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
|
|
55
|
-
49, 50, 51, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
|
56
|
-
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
|
57
|
-
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
|
58
|
-
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
|
59
|
-
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
|
60
|
-
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
|
61
|
-
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
|
62
|
-
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
|
63
|
-
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
|
64
|
-
255};
|
|
65
|
-
|
|
66
|
-
inline Error validate(uint32_t v) {
|
|
67
|
-
ET_CHECK_OR_RETURN_ERROR(v != 255, InvalidArgument, "invalid char");
|
|
68
|
-
return Error::Ok;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
inline Error decode(const std::string_view &input, std::string &output) {
|
|
72
|
-
ET_CHECK_OR_RETURN_ERROR(input.size() == 4, InvalidArgument,
|
|
73
|
-
"input length must be 4, got %zu", input.size());
|
|
74
|
-
|
|
75
|
-
uint32_t val = 0;
|
|
76
|
-
|
|
77
|
-
uint8_t c = input[0];
|
|
78
|
-
auto v = DECODE_TABLE[c];
|
|
79
|
-
ET_CHECK_OK_OR_RETURN_ERROR(validate(v));
|
|
80
|
-
val = v;
|
|
81
|
-
|
|
82
|
-
c = input[1];
|
|
83
|
-
v = DECODE_TABLE[c];
|
|
84
|
-
ET_CHECK_OK_OR_RETURN_ERROR(validate(v));
|
|
85
|
-
val = (val << 6) | v;
|
|
86
|
-
|
|
87
|
-
c = input[2];
|
|
88
|
-
v = DECODE_TABLE[c];
|
|
89
|
-
ET_CHECK_OK_OR_RETURN_ERROR(validate(v));
|
|
90
|
-
val = (val << 6) | v;
|
|
91
|
-
|
|
92
|
-
c = input[3];
|
|
93
|
-
v = DECODE_TABLE[c];
|
|
94
|
-
ET_CHECK_OK_OR_RETURN_ERROR(validate(v));
|
|
95
|
-
val = (val << 6) | v;
|
|
96
|
-
|
|
97
|
-
output.push_back(static_cast<char>((val >> 16) & 0xFF));
|
|
98
|
-
output.push_back(static_cast<char>((val >> 8) & 0xFF));
|
|
99
|
-
output.push_back(static_cast<char>(val & 0xFF));
|
|
100
|
-
return Error::Ok;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
inline Error decode_1_padding(const std::string_view &input,
|
|
104
|
-
std::string &output) {
|
|
105
|
-
ET_CHECK_OR_RETURN_ERROR(input.size() == 3, InvalidArgument,
|
|
106
|
-
"input length must be 3, got %zu", input.size());
|
|
107
|
-
|
|
108
|
-
uint32_t val = 0;
|
|
109
|
-
|
|
110
|
-
uint8_t c = input[0];
|
|
111
|
-
auto v = DECODE_TABLE[c];
|
|
112
|
-
ET_CHECK_OK_OR_RETURN_ERROR(validate(v));
|
|
113
|
-
val = v;
|
|
114
|
-
|
|
115
|
-
c = input[1];
|
|
116
|
-
v = DECODE_TABLE[c];
|
|
117
|
-
ET_CHECK_OK_OR_RETURN_ERROR(validate(v));
|
|
118
|
-
val = (val << 6) | v;
|
|
119
|
-
|
|
120
|
-
c = input[2];
|
|
121
|
-
v = DECODE_TABLE[c];
|
|
122
|
-
ET_CHECK_OK_OR_RETURN_ERROR(validate(v));
|
|
123
|
-
val = (val << 6) | v;
|
|
124
|
-
|
|
125
|
-
output.push_back(static_cast<char>((val >> 10) & 0xFF));
|
|
126
|
-
output.push_back(static_cast<char>((val >> 2) & 0xFF));
|
|
127
|
-
return Error::Ok;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
inline Error decode_2_padding(const std::string_view &input,
|
|
131
|
-
std::string &output) {
|
|
132
|
-
ET_CHECK_OR_RETURN_ERROR(input.size() == 2, InvalidArgument,
|
|
133
|
-
"input length must be 2, got %zu", input.size());
|
|
134
|
-
|
|
135
|
-
uint32_t val = 0;
|
|
136
|
-
|
|
137
|
-
uint8_t c = input[0];
|
|
138
|
-
auto v = DECODE_TABLE[c];
|
|
139
|
-
ET_CHECK_OK_OR_RETURN_ERROR(validate(v));
|
|
140
|
-
val = v;
|
|
141
|
-
|
|
142
|
-
c = input[1];
|
|
143
|
-
v = DECODE_TABLE[c];
|
|
144
|
-
ET_CHECK_OK_OR_RETURN_ERROR(validate(v));
|
|
145
|
-
val = (val << 6) | v;
|
|
146
|
-
|
|
147
|
-
output.push_back(static_cast<char>((val >> 4) & 0xFF));
|
|
148
|
-
return Error::Ok;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
} // namespace detail
|
|
152
|
-
|
|
153
|
-
inline Result<std::string> decode(const std::string_view &input) {
|
|
154
|
-
ET_CHECK_OR_RETURN_ERROR(!input.empty(), InvalidArgument, "empty input");
|
|
155
|
-
|
|
156
|
-
// Faster than `input.size() % 4`.
|
|
157
|
-
ET_CHECK_OR_RETURN_ERROR(
|
|
158
|
-
(input.size() & 3) == 0 && input.size() >= 4, InvalidArgument,
|
|
159
|
-
"input length must be larger than 4 and is multiple of 4, got %zu",
|
|
160
|
-
input.size());
|
|
161
|
-
|
|
162
|
-
std::string output;
|
|
163
|
-
output.reserve(input.size() / 4 * 3);
|
|
164
|
-
auto idx = 0U;
|
|
165
|
-
for (; idx < input.size() - 4; idx += 4) {
|
|
166
|
-
ET_CHECK_OK_OR_RETURN_ERROR(detail::decode(input.substr(idx, 4), output));
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// Last 4 bytes. Might contain paddings.
|
|
170
|
-
if (input[idx + 3] == '=') {
|
|
171
|
-
if (input[idx + 2] == '=') {
|
|
172
|
-
// Tow paddings.
|
|
173
|
-
ET_CHECK_OK_OR_RETURN_ERROR(
|
|
174
|
-
detail::decode_2_padding(input.substr(idx, 2), output));
|
|
175
|
-
} else {
|
|
176
|
-
// One padding.
|
|
177
|
-
ET_CHECK_OK_OR_RETURN_ERROR(
|
|
178
|
-
detail::decode_1_padding(input.substr(idx, 3), output));
|
|
179
|
-
}
|
|
180
|
-
} else {
|
|
181
|
-
// No padding.
|
|
182
|
-
ET_CHECK_OK_OR_RETURN_ERROR(detail::decode(input.substr(idx, 4), output));
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
return output;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
} // namespace base64
|
|
189
|
-
|
|
190
|
-
} // namespace llm
|
|
191
|
-
} // namespace extension
|
|
192
|
-
} // namespace executorch
|
|
193
|
-
|
|
194
|
-
namespace torch {
|
|
195
|
-
namespace executor {
|
|
196
|
-
namespace base64 {
|
|
197
|
-
// TODO(T197294990): Remove these deprecated aliases once all users have moved
|
|
198
|
-
// to the new `::executorch` namespaces.
|
|
199
|
-
using ::executorch::extension::llm::base64::decode;
|
|
200
|
-
} // namespace base64
|
|
201
|
-
} // namespace executor
|
|
202
|
-
} // namespace torch
|
|
@@ -1,313 +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
|
-
#include "bpe_tokenizer.h"
|
|
10
|
-
|
|
11
|
-
#include <cstring>
|
|
12
|
-
|
|
13
|
-
using ::executorch::runtime::Error;
|
|
14
|
-
using ::executorch::runtime::Result;
|
|
15
|
-
|
|
16
|
-
namespace executorch {
|
|
17
|
-
namespace extension {
|
|
18
|
-
namespace llm {
|
|
19
|
-
|
|
20
|
-
static int compare_tokens(const void *a, const void *b) {
|
|
21
|
-
if (((TokenIndex *)a)->str == nullptr) {
|
|
22
|
-
return -1;
|
|
23
|
-
}
|
|
24
|
-
if (((TokenIndex *)b)->str == nullptr) {
|
|
25
|
-
return 1;
|
|
26
|
-
}
|
|
27
|
-
return strcmp(((TokenIndex *)a)->str, ((TokenIndex *)b)->str);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
BPETokenizer::BPETokenizer() : Tokenizer() {
|
|
31
|
-
for (int i = 0; i < 256; i++) {
|
|
32
|
-
byte_pieces_[i * 2] = (unsigned char)i;
|
|
33
|
-
byte_pieces_[i * 2 + 1] = '\0';
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* @brief Load the tokenizer from a file. The tokenizer file contains the
|
|
39
|
-
* vocabulary and scores. The format is: the first integer is the maximum
|
|
40
|
-
* token length, followed by a list of (word_len, word) pairs. Here we
|
|
41
|
-
* are reading all the vocabulary into memory and keep it sorted for fast
|
|
42
|
-
* lookup.
|
|
43
|
-
*
|
|
44
|
-
* @param tokenizer_path The path to the tokenizer file.
|
|
45
|
-
* @return Error
|
|
46
|
-
*/
|
|
47
|
-
Error BPETokenizer::load(const std::string &tokenizer_path) {
|
|
48
|
-
if (initialized_) {
|
|
49
|
-
ET_LOG(Info, "Tokenizer already initialized");
|
|
50
|
-
return Error::Ok;
|
|
51
|
-
}
|
|
52
|
-
// read in the file
|
|
53
|
-
FILE *file = fopen(tokenizer_path.c_str(), "rb");
|
|
54
|
-
if (!file) {
|
|
55
|
-
ET_LOG(Error, "couldn't load %s", tokenizer_path.c_str());
|
|
56
|
-
return Error::InvalidArgument;
|
|
57
|
-
}
|
|
58
|
-
int32_t metadata[4];
|
|
59
|
-
for (int i = 0; i < 4; i++) {
|
|
60
|
-
if (fread(metadata + i, sizeof(int32_t), 1, file) != 1) {
|
|
61
|
-
ET_LOG(Error,
|
|
62
|
-
"Failed to read the metadata at position %d, the tokenizer file "
|
|
63
|
-
"is not valid!",
|
|
64
|
-
i);
|
|
65
|
-
return Error::InvalidArgument;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// now we have two vocab_sizes one from the model and another from the
|
|
70
|
-
// tokenizer file.
|
|
71
|
-
int32_t tokenizer_vocab_size = metadata[0];
|
|
72
|
-
vocab_size_ = tokenizer_vocab_size;
|
|
73
|
-
bos_tok_ = metadata[1];
|
|
74
|
-
eos_tok_ = metadata[2];
|
|
75
|
-
max_token_length_ = metadata[3];
|
|
76
|
-
|
|
77
|
-
// allocate space for the vocabulary
|
|
78
|
-
vocab_ = std::make_unique<char *[]>(vocab_size_);
|
|
79
|
-
vocab_scores_ = std::make_unique<float[]>(vocab_size_);
|
|
80
|
-
sorted_vocab_ = std::make_unique<TokenIndex[]>(vocab_size_);
|
|
81
|
-
|
|
82
|
-
// read in the vocabulary
|
|
83
|
-
for (int i = 0; i < vocab_size_; i++) {
|
|
84
|
-
if (fread(vocab_scores_.get() + i, sizeof(float), 1, file) != 1) {
|
|
85
|
-
// This is allowed, we just pad the rest of the vocab with <pad> strings
|
|
86
|
-
std::string padding = "<pad>";
|
|
87
|
-
vocab_[i] = new char[padding.length() + 1];
|
|
88
|
-
strcpy(vocab_[i], padding.c_str());
|
|
89
|
-
vocab_[i][padding.length()] = '\0';
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
int32_t len;
|
|
93
|
-
if (fread(&len, sizeof(int32_t), 1, file) != 1) {
|
|
94
|
-
ET_LOG(Error, "Failed to read the length of the word at index %d", i);
|
|
95
|
-
return Error::InvalidArgument;
|
|
96
|
-
}
|
|
97
|
-
vocab_[i] = new char[len + 1];
|
|
98
|
-
if (fread(vocab_[i], len, 1, file) != 1) {
|
|
99
|
-
ET_LOG(Error, "Failed to read the word, total length %d, index %d\n", len,
|
|
100
|
-
i);
|
|
101
|
-
return Error::InvalidArgument;
|
|
102
|
-
}
|
|
103
|
-
vocab_[i][len] = '\0'; // add the string terminating token
|
|
104
|
-
}
|
|
105
|
-
fclose(file);
|
|
106
|
-
|
|
107
|
-
for (int32_t i = 0; i < vocab_size_; i++) {
|
|
108
|
-
sorted_vocab_[i].str = vocab_[i];
|
|
109
|
-
sorted_vocab_[i].id = i;
|
|
110
|
-
}
|
|
111
|
-
qsort(sorted_vocab_.get(), vocab_size_, sizeof(TokenIndex), compare_tokens);
|
|
112
|
-
|
|
113
|
-
initialized_ = true;
|
|
114
|
-
return Error::Ok;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
BPETokenizer::~BPETokenizer() {
|
|
118
|
-
for (int i = 0; i < vocab_size_; i++) {
|
|
119
|
-
delete[] vocab_[i];
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* @brief Decode a token into string.
|
|
125
|
-
*
|
|
126
|
-
* @param prev_token The previous token.
|
|
127
|
-
* @param token The current token.
|
|
128
|
-
* @return Result<std::string> A pointer to the string representation of the
|
|
129
|
-
* token.
|
|
130
|
-
*/
|
|
131
|
-
Result<std::string> BPETokenizer::decode(uint64_t prev_token,
|
|
132
|
-
uint64_t token) const {
|
|
133
|
-
ET_CHECK_OK_OR_RETURN_ERROR(Tokenizer::decode_verify(token));
|
|
134
|
-
const char *piece = vocab_[token];
|
|
135
|
-
// following BOS token, sentencepiece decoder strips any leading
|
|
136
|
-
// whitespace
|
|
137
|
-
if (prev_token == bos_tok_ && piece[0] == ' ') {
|
|
138
|
-
piece++;
|
|
139
|
-
}
|
|
140
|
-
// careful, some tokens designate raw bytes, and look like e.g. '<0x01>'
|
|
141
|
-
// parse this and convert and return the actual byte
|
|
142
|
-
unsigned char byte_val;
|
|
143
|
-
if (sscanf(piece, "<0x%02hhX>", &byte_val) == 1) {
|
|
144
|
-
piece = (char *)byte_pieces_ + byte_val * 2;
|
|
145
|
-
}
|
|
146
|
-
std::string res(piece);
|
|
147
|
-
return res;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
static int32_t str_lookup(const char *str, TokenIndex *sorted_vocab,
|
|
151
|
-
int32_t vocab_size) {
|
|
152
|
-
// efficiently find the perfect match for str in vocab, return its index or -1
|
|
153
|
-
// if not found
|
|
154
|
-
TokenIndex tok = {.str = str}; // acts as the key to search for
|
|
155
|
-
TokenIndex *res = (TokenIndex *)bsearch(&tok, sorted_vocab, vocab_size,
|
|
156
|
-
sizeof(TokenIndex), compare_tokens);
|
|
157
|
-
return res != nullptr ? res->id : -1;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* @brief Encode a string into a sequence of tokens.
|
|
162
|
-
*
|
|
163
|
-
* @param text The string to be encoded.
|
|
164
|
-
* @param bos The number of BOS to prepend to the token list.
|
|
165
|
-
* @param eos The number of EOS to append to the token list.
|
|
166
|
-
* @param tokens The output tokens.
|
|
167
|
-
* @param n_tokens The number of tokens.
|
|
168
|
-
* @return Result<std::vector<uint64_t>>
|
|
169
|
-
*/
|
|
170
|
-
Result<std::vector<uint64_t>>
|
|
171
|
-
BPETokenizer::encode(const std::string &text, int8_t bos, int8_t eos) const {
|
|
172
|
-
if (!initialized_) {
|
|
173
|
-
ET_LOG(Error, "Tokenizer not initialized");
|
|
174
|
-
return Error::NotSupported;
|
|
175
|
-
}
|
|
176
|
-
// encode the string text (input) into an upper-bound preallocated tokens[]
|
|
177
|
-
// array bos != 0 means prepend the BOS token (=1), eos != 0 means append the
|
|
178
|
-
// EOS token (=2)
|
|
179
|
-
if (text.empty()) {
|
|
180
|
-
ET_LOG(Error, "cannot encode empty text");
|
|
181
|
-
return Error::InvalidArgument;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// create a temporary buffer that will store merge candidates of always two
|
|
185
|
-
// consecutive tokens *2 for concat, +1 for null terminator +2 for UTF8 (in
|
|
186
|
-
// case max_token_length is 1)
|
|
187
|
-
char *str_buffer = new char[max_token_length_ * 2 + 1 + 2];
|
|
188
|
-
size_t str_len = 0;
|
|
189
|
-
|
|
190
|
-
// start at 0 tokens
|
|
191
|
-
std::vector<uint64_t> tokens;
|
|
192
|
-
|
|
193
|
-
// add optional BOS token, if desired
|
|
194
|
-
if (bos >= 0) {
|
|
195
|
-
while (bos--) {
|
|
196
|
-
tokens.push_back(bos_tok_);
|
|
197
|
-
}
|
|
198
|
-
} else {
|
|
199
|
-
ET_LOG(Error, "bos %d should be >= 0", bos);
|
|
200
|
-
return Error::InvalidArgument;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// add_dummy_prefix is true by default
|
|
204
|
-
// so prepend a dummy prefix token to the input string, but only if text != ""
|
|
205
|
-
// TODO: pretty sure this isn't correct in the general case but I don't have
|
|
206
|
-
// the energy to read more of the sentencepiece code to figure out what it's
|
|
207
|
-
// doing
|
|
208
|
-
const char *space = " ";
|
|
209
|
-
if (text[0] != '\0') {
|
|
210
|
-
int dummy_prefix = str_lookup(space, sorted_vocab_.get(), vocab_size_);
|
|
211
|
-
tokens.push_back(dummy_prefix);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// Okay UTF-8 time. This will get messy. Here is the reference from Wikipedia:
|
|
215
|
-
// Code point ↔ UTF-8 conversion
|
|
216
|
-
// First code point Last code point Byte 1 Byte 2 Byte 3 Byte 4
|
|
217
|
-
// U+0000 U+007F 0xxxxxxx
|
|
218
|
-
// U+0080 U+07FF 110xxxxx 10xxxxxx
|
|
219
|
-
// U+0800 U+FFFF 1110xxxx 10xxxxxx 10xxxxxx
|
|
220
|
-
// U+10000 U+10FFFF 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
|
221
|
-
|
|
222
|
-
// process the raw (UTF-8) byte sequence of the input string
|
|
223
|
-
for (const char *c = text.c_str(); *c != '\0'; c++) {
|
|
224
|
-
// reset buffer if the current byte is ASCII or a leading byte
|
|
225
|
-
// 0xC0 is 11000000, so (*c & 0xC0) keeps the first 2 bits and zeros the
|
|
226
|
-
// rest 0x80 is 10000000 in UTF-8, all continuation bytes start with "10" in
|
|
227
|
-
// first two bits so in English this is: "if this byte is not a continuation
|
|
228
|
-
// byte"
|
|
229
|
-
if ((*c & 0xC0) != 0x80) {
|
|
230
|
-
// this byte must be either a leading byte (11...) or an ASCII char
|
|
231
|
-
// (0x...)
|
|
232
|
-
// => reset our location, as we're starting a new UTF-8 codepoint
|
|
233
|
-
str_len = 0;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// append the current byte to the buffer
|
|
237
|
-
str_buffer[str_len++] =
|
|
238
|
-
*c; // ++ is post-increment, incremented after this line
|
|
239
|
-
str_buffer[str_len] = '\0';
|
|
240
|
-
|
|
241
|
-
// while the next character is a continuation byte, continue appending
|
|
242
|
-
// but if there are too many of them, just stop to avoid overruning
|
|
243
|
-
// str_buffer size.
|
|
244
|
-
if ((*(c + 1) & 0xC0) == 0x80 && str_len < 4) {
|
|
245
|
-
continue;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
// ok c+1 is not a continuation byte, so we've read in a full codepoint
|
|
249
|
-
int id = str_lookup(str_buffer, sorted_vocab_.get(), vocab_size_);
|
|
250
|
-
if (id != -1) {
|
|
251
|
-
// we found this codepoint in vocab, add it as a token
|
|
252
|
-
tokens.push_back(id);
|
|
253
|
-
} else {
|
|
254
|
-
// byte_fallback encoding: just encode each byte as a token
|
|
255
|
-
// +3 is here because the first 3 vocab elements are <unk>, <s>, </s>
|
|
256
|
-
// so the individual bytes only start at index 3
|
|
257
|
-
for (int i = 0; i < str_len; i++) {
|
|
258
|
-
tokens.push_back((unsigned char)str_buffer[i] + 3);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
str_len = 0; // protect against a sequence of stray UTF8 continuation bytes
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// merge the best consecutive pair each iteration, according the scores in
|
|
265
|
-
// vocab_scores
|
|
266
|
-
while (1) {
|
|
267
|
-
float best_score = -1e10;
|
|
268
|
-
int best_id = -1;
|
|
269
|
-
int best_idx = -1;
|
|
270
|
-
|
|
271
|
-
for (int i = 0; i < tokens.size() - 1; i++) {
|
|
272
|
-
// check if we can merge the pair (tokens[i], tokens[i+1])
|
|
273
|
-
snprintf(str_buffer, max_token_length_ * 2 + 3, "%s%s", vocab_[tokens[i]],
|
|
274
|
-
vocab_[tokens[i + 1]]);
|
|
275
|
-
int id = str_lookup(str_buffer, sorted_vocab_.get(), vocab_size_);
|
|
276
|
-
if (id != -1 && vocab_scores_[id] > best_score) {
|
|
277
|
-
// this merge pair exists in vocab! record its score and position
|
|
278
|
-
best_score = vocab_scores_[id];
|
|
279
|
-
best_id = id;
|
|
280
|
-
best_idx = i;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
if (best_idx == -1) {
|
|
285
|
-
break; // we couldn't find any more pairs to merge, so we're done
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
// merge the consecutive pair (best_idx, best_idx+1) into new token best_id
|
|
289
|
-
tokens[best_idx] = best_id;
|
|
290
|
-
// delete token at position best_idx+1, shift the entire sequence back 1
|
|
291
|
-
for (int i = best_idx + 1; i < tokens.size() - 1; i++) {
|
|
292
|
-
tokens[i] = tokens[i + 1];
|
|
293
|
-
}
|
|
294
|
-
tokens.pop_back(); // token length decreased
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
// add optional EOS (=2) token, if desired
|
|
298
|
-
if (eos >= 0) {
|
|
299
|
-
while (eos--) {
|
|
300
|
-
tokens.push_back(eos_tok_);
|
|
301
|
-
}
|
|
302
|
-
} else {
|
|
303
|
-
ET_LOG(Error, "eos %d should be >= 0", eos);
|
|
304
|
-
return Error::InvalidArgument;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
delete[] str_buffer;
|
|
308
|
-
return Result(tokens);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
} // namespace llm
|
|
312
|
-
} // namespace extension
|
|
313
|
-
} // namespace executorch
|
|
@@ -1,57 +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 "tokenizer.h"
|
|
12
|
-
#include <memory>
|
|
13
|
-
|
|
14
|
-
namespace executorch {
|
|
15
|
-
namespace extension {
|
|
16
|
-
namespace llm {
|
|
17
|
-
|
|
18
|
-
struct TokenIndex {
|
|
19
|
-
const char *str;
|
|
20
|
-
int32_t id;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
// A simple Byte Pair Encoding (BPE) Tokenizer. Note that the current C++ code
|
|
24
|
-
// won't work with this class, it needs to go through tokenizer.py first.
|
|
25
|
-
class BPETokenizer : public Tokenizer {
|
|
26
|
-
public:
|
|
27
|
-
explicit BPETokenizer();
|
|
28
|
-
~BPETokenizer() override;
|
|
29
|
-
|
|
30
|
-
::executorch::runtime::Error load(const std::string &tokenizer_path) override;
|
|
31
|
-
|
|
32
|
-
::executorch::runtime::Result<std::vector<uint64_t>>
|
|
33
|
-
encode(const std::string &input, int8_t bos, int8_t eos) const override;
|
|
34
|
-
|
|
35
|
-
::executorch::runtime::Result<std::string>
|
|
36
|
-
decode(uint64_t prev_token, uint64_t token) const override;
|
|
37
|
-
|
|
38
|
-
private:
|
|
39
|
-
std::unique_ptr<char *[]> vocab_ = nullptr;
|
|
40
|
-
std::unique_ptr<float[]> vocab_scores_ = nullptr;
|
|
41
|
-
std::unique_ptr<TokenIndex[]> sorted_vocab_ = nullptr;
|
|
42
|
-
unsigned int max_token_length_ = 0;
|
|
43
|
-
unsigned char byte_pieces_[512]; // stores all single-byte strings
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
} // namespace llm
|
|
47
|
-
} // namespace extension
|
|
48
|
-
} // namespace executorch
|
|
49
|
-
|
|
50
|
-
namespace torch {
|
|
51
|
-
namespace executor {
|
|
52
|
-
// TODO(T197294990): Remove these deprecated aliases once all users have moved
|
|
53
|
-
// to the new `::executorch` namespaces.
|
|
54
|
-
using ::executorch::extension::llm::BPETokenizer;
|
|
55
|
-
using ::executorch::extension::llm::TokenIndex;
|
|
56
|
-
} // namespace executor
|
|
57
|
-
} // namespace torch
|
|
@@ -1,78 +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
|
-
#include "llama_tiktoken.h"
|
|
10
|
-
|
|
11
|
-
namespace example {
|
|
12
|
-
|
|
13
|
-
using ::executorch::extension::llm::Tiktoken;
|
|
14
|
-
|
|
15
|
-
namespace {
|
|
16
|
-
static constexpr int32_t kSpecialTokensSize = 256;
|
|
17
|
-
static constexpr size_t kBOSTokenIndex = 0;
|
|
18
|
-
static constexpr size_t kEOSTokenIndex = 1;
|
|
19
|
-
|
|
20
|
-
static inline std::unique_ptr<std::vector<std::string>>
|
|
21
|
-
_get_default_special_tokens() {
|
|
22
|
-
auto special_tokens =
|
|
23
|
-
std::make_unique<std::vector<std::string>>(std::vector<std::string>{
|
|
24
|
-
"<|begin_of_text|>", "<|end_of_text|>",
|
|
25
|
-
"<|reserved_special_token_0|>", "<|reserved_special_token_1|>",
|
|
26
|
-
"<|finetune_right_pad_id|>", "<|step_id|>", "<|start_header_id|>",
|
|
27
|
-
"<|end_header_id|>", "<|eom_id|>", "<|eot_id|>", "<|python_tag|>"});
|
|
28
|
-
// pad the rest of the special tokens with reserved tokens
|
|
29
|
-
ssize_t reserved_special_token_num = 2;
|
|
30
|
-
while (special_tokens->size() < kSpecialTokensSize) {
|
|
31
|
-
special_tokens->emplace_back("<|reserved_special_token_" +
|
|
32
|
-
std::to_string(reserved_special_token_num++) +
|
|
33
|
-
"|>");
|
|
34
|
-
}
|
|
35
|
-
return special_tokens;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
static inline std::unique_ptr<std::vector<std::string>>
|
|
39
|
-
_get_multimodal_special_tokens() {
|
|
40
|
-
auto special_tokens =
|
|
41
|
-
std::make_unique<std::vector<std::string>>(std::vector<std::string>{
|
|
42
|
-
"<|begin_of_text|>", "<|end_of_text|>",
|
|
43
|
-
"<|reserved_special_token_0|>", "<|reserved_special_token_1|>",
|
|
44
|
-
"<|reserved_special_token_2|>", "<|reserved_special_token_3|>",
|
|
45
|
-
"<|start_header_id|>", "<|end_header_id|>", "<|eom_id|>",
|
|
46
|
-
"<|eot_id|>", "<|image|>"});
|
|
47
|
-
|
|
48
|
-
// pad the rest of the special tokens with reserved tokens except the last
|
|
49
|
-
// one
|
|
50
|
-
ssize_t reserved_special_token_num = 4;
|
|
51
|
-
while (special_tokens->size() < kSpecialTokensSize - 1) {
|
|
52
|
-
special_tokens->emplace_back("<|reserved_special_token_" +
|
|
53
|
-
std::to_string(reserved_special_token_num++) +
|
|
54
|
-
"|>");
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
special_tokens->emplace_back("<|python_tag|>");
|
|
58
|
-
|
|
59
|
-
return special_tokens;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
std::unique_ptr<std::vector<std::string>> _get_special_tokens(Version version) {
|
|
63
|
-
switch (version) {
|
|
64
|
-
case Version::Multimodal:
|
|
65
|
-
return _get_multimodal_special_tokens();
|
|
66
|
-
default:
|
|
67
|
-
return _get_default_special_tokens();
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
} // namespace
|
|
72
|
-
|
|
73
|
-
std::unique_ptr<Tiktoken> get_tiktoken_for_llama(Version version) {
|
|
74
|
-
return std::make_unique<Tiktoken>(_get_special_tokens(version),
|
|
75
|
-
kBOSTokenIndex, kEOSTokenIndex);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
} // namespace example
|
|
@@ -1,23 +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 "tiktoken.h"
|
|
12
|
-
|
|
13
|
-
namespace example {
|
|
14
|
-
|
|
15
|
-
enum class Version {
|
|
16
|
-
Default,
|
|
17
|
-
Multimodal,
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
std::unique_ptr<::executorch::extension::llm::Tiktoken>
|
|
21
|
-
get_tiktoken_for_llama(Version version = Version::Default);
|
|
22
|
-
|
|
23
|
-
} // namespace example
|