react-native-executorch 0.5.15 → 0.6.0-nightly-897eae9-20251213
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -36
- package/android/CMakeLists.txt +13 -25
- package/android/build.gradle +2 -3
- package/android/libs/classes.jar +0 -0
- package/android/src/main/cpp/CMakeLists.txt +2 -1
- package/common/rnexecutorch/RnExecutorchInstaller.cpp +18 -0
- package/common/rnexecutorch/TokenizerModule.cpp +3 -3
- package/common/rnexecutorch/data_processing/Numerical.cpp +31 -23
- package/common/rnexecutorch/data_processing/Numerical.h +6 -1
- package/common/rnexecutorch/data_processing/dsp.cpp +0 -46
- package/common/rnexecutorch/host_objects/JsiConversions.h +16 -0
- package/common/rnexecutorch/host_objects/ModelHostObject.h +26 -11
- package/common/rnexecutorch/jsi/OwningArrayBuffer.h +19 -2
- package/common/rnexecutorch/metaprogramming/TypeConcepts.h +0 -20
- package/common/rnexecutorch/models/BaseModel.cpp +12 -11
- package/common/rnexecutorch/models/BaseModel.h +18 -10
- package/common/rnexecutorch/models/embeddings/BaseEmbeddings.cpp +3 -11
- package/common/rnexecutorch/models/embeddings/text/TextEmbeddings.cpp +0 -1
- package/common/rnexecutorch/models/image_segmentation/ImageSegmentation.cpp +6 -12
- package/common/rnexecutorch/models/llm/LLM.cpp +25 -8
- package/common/rnexecutorch/models/llm/LLM.h +4 -4
- package/common/rnexecutorch/models/ocr/CTCLabelConverter.h +1 -1
- package/common/rnexecutorch/models/ocr/utils/RecognitionHandlerUtils.cpp +7 -4
- package/common/rnexecutorch/models/speech_to_text/SpeechToText.cpp +8 -13
- package/common/rnexecutorch/models/speech_to_text/SpeechToText.h +1 -3
- package/common/rnexecutorch/models/speech_to_text/asr/ASR.cpp +12 -19
- package/common/rnexecutorch/models/speech_to_text/asr/ASR.h +4 -5
- package/common/rnexecutorch/models/text_to_image/Constants.h +9 -0
- package/common/rnexecutorch/models/text_to_image/Decoder.cpp +32 -0
- package/common/rnexecutorch/models/text_to_image/Decoder.h +24 -0
- package/common/rnexecutorch/models/text_to_image/Encoder.cpp +44 -0
- package/common/rnexecutorch/models/text_to_image/Encoder.h +32 -0
- package/common/rnexecutorch/models/text_to_image/Scheduler.cpp +152 -0
- package/common/rnexecutorch/models/text_to_image/Scheduler.h +41 -0
- package/common/rnexecutorch/models/text_to_image/TextToImage.cpp +141 -0
- package/common/rnexecutorch/models/text_to_image/TextToImage.h +64 -0
- package/common/rnexecutorch/models/text_to_image/UNet.cpp +38 -0
- package/common/rnexecutorch/models/text_to_image/UNet.h +28 -0
- package/common/rnexecutorch/models/voice_activity_detection/Constants.h +27 -0
- package/common/rnexecutorch/models/voice_activity_detection/Types.h +12 -0
- package/common/rnexecutorch/models/voice_activity_detection/Utils.cpp +15 -0
- package/common/rnexecutorch/models/voice_activity_detection/Utils.h +13 -0
- package/common/rnexecutorch/models/voice_activity_detection/VoiceActivityDetection.cpp +160 -0
- package/common/rnexecutorch/models/voice_activity_detection/VoiceActivityDetection.h +36 -0
- package/common/rnexecutorch/tests/CMakeLists.txt +30 -0
- package/common/rnexecutorch/tests/NumericalTest.cpp +110 -0
- package/common/rnexecutorch/tests/README.md +30 -13
- package/common/rnexecutorch/threads/GlobalThreadPool.h +4 -0
- package/common/runner/arange_util.cpp +44 -0
- package/common/runner/arange_util.h +37 -0
- package/common/runner/constants.h +28 -0
- package/common/runner/io_manager.h +240 -0
- package/common/runner/irunner.h +87 -16
- package/common/runner/kernel_includes.h +23 -0
- package/common/runner/runner.cpp +151 -66
- package/common/runner/runner.h +39 -22
- package/common/runner/sampler.cpp +8 -1
- package/common/runner/sampler.h +4 -2
- package/common/runner/stats.h +1 -4
- package/common/runner/text_decoder_runner.cpp +26 -12
- package/common/runner/text_decoder_runner.h +52 -31
- package/common/runner/text_prefiller.cpp +46 -12
- package/common/runner/text_prefiller.h +38 -4
- package/common/runner/text_token_generator.h +51 -26
- package/common/runner/util.h +53 -8
- package/ios/RnExecutorch.xcodeproj/project.pbxproj +0 -23
- package/lib/module/Error.js +1 -0
- package/lib/module/Error.js.map +1 -1
- package/lib/module/constants/directories.js +1 -1
- package/lib/module/constants/directories.js.map +1 -1
- package/lib/module/constants/modelUrls.js +32 -1
- package/lib/module/constants/modelUrls.js.map +1 -1
- package/lib/module/constants/ocr/models.js +7 -7
- package/lib/module/constants/ocr/models.js.map +1 -1
- package/lib/module/constants/ocr/symbols.js +3 -2
- package/lib/module/constants/ocr/symbols.js.map +1 -1
- package/lib/module/controllers/LLMController.js +10 -1
- package/lib/module/controllers/LLMController.js.map +1 -1
- package/lib/module/controllers/OCRController.js +3 -3
- package/lib/module/controllers/OCRController.js.map +1 -1
- package/lib/module/controllers/VerticalOCRController.js +2 -2
- package/lib/module/controllers/VerticalOCRController.js.map +1 -1
- package/lib/module/hooks/computer_vision/useOCR.js +3 -3
- package/lib/module/hooks/computer_vision/useOCR.js.map +1 -1
- package/lib/module/hooks/{useNonStaticModule.js → computer_vision/useTextToImage.js} +21 -16
- package/lib/module/hooks/computer_vision/useTextToImage.js.map +1 -0
- package/lib/module/hooks/computer_vision/useVerticalOCR.js +3 -3
- package/lib/module/hooks/computer_vision/useVerticalOCR.js.map +1 -1
- package/lib/module/hooks/natural_language_processing/useLLM.js +3 -3
- package/lib/module/hooks/natural_language_processing/useLLM.js.map +1 -1
- package/lib/module/hooks/natural_language_processing/useTokenizer.js +5 -5
- package/lib/module/hooks/natural_language_processing/useTokenizer.js.map +1 -1
- package/lib/module/hooks/natural_language_processing/useVAD.js +13 -0
- package/lib/module/hooks/natural_language_processing/useVAD.js.map +1 -0
- package/lib/module/index.js +7 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/modules/computer_vision/OCRModule.js +2 -2
- package/lib/module/modules/computer_vision/OCRModule.js.map +1 -1
- package/lib/module/modules/computer_vision/TextToImageModule.js +48 -0
- package/lib/module/modules/computer_vision/TextToImageModule.js.map +1 -0
- package/lib/module/modules/computer_vision/VerticalOCRModule.js +2 -2
- package/lib/module/modules/computer_vision/VerticalOCRModule.js.map +1 -1
- package/lib/module/modules/natural_language_processing/SpeechToTextModule.js +7 -4
- package/lib/module/modules/natural_language_processing/SpeechToTextModule.js.map +1 -1
- package/lib/module/modules/natural_language_processing/VADModule.js +19 -0
- package/lib/module/modules/natural_language_processing/VADModule.js.map +1 -0
- package/lib/module/types/llm.js.map +1 -1
- package/lib/module/types/vad.js +2 -0
- package/lib/module/types/vad.js.map +1 -0
- package/lib/module/utils/ResourceFetcher.js +2 -1
- package/lib/module/utils/ResourceFetcher.js.map +1 -1
- package/lib/module/utils/ResourceFetcherUtils.js +6 -6
- package/lib/module/utils/ResourceFetcherUtils.js.map +1 -1
- package/lib/typescript/Error.d.ts +1 -0
- package/lib/typescript/Error.d.ts.map +1 -1
- package/lib/typescript/constants/modelUrls.d.ts +23 -0
- package/lib/typescript/constants/modelUrls.d.ts.map +1 -1
- package/lib/typescript/constants/ocr/symbols.d.ts +1 -1
- package/lib/typescript/constants/ocr/symbols.d.ts.map +1 -1
- package/lib/typescript/controllers/LLMController.d.ts.map +1 -1
- package/lib/typescript/controllers/OCRController.d.ts +1 -1
- package/lib/typescript/controllers/OCRController.d.ts.map +1 -1
- package/lib/typescript/controllers/VerticalOCRController.d.ts +1 -1
- package/lib/typescript/controllers/VerticalOCRController.d.ts.map +1 -1
- package/lib/typescript/hooks/computer_vision/useOCR.d.ts +1 -1
- package/lib/typescript/hooks/computer_vision/useOCR.d.ts.map +1 -1
- package/lib/typescript/hooks/computer_vision/useTextToImage.d.ts +22 -0
- package/lib/typescript/hooks/computer_vision/useTextToImage.d.ts.map +1 -0
- package/lib/typescript/hooks/computer_vision/useVerticalOCR.d.ts +1 -1
- package/lib/typescript/hooks/computer_vision/useVerticalOCR.d.ts.map +1 -1
- package/lib/typescript/hooks/natural_language_processing/useLLM.d.ts.map +1 -1
- package/lib/typescript/hooks/natural_language_processing/useSpeechToText.d.ts +2 -2
- package/lib/typescript/hooks/natural_language_processing/useVAD.d.ts +16 -0
- package/lib/typescript/hooks/natural_language_processing/useVAD.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +8 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/OCRModule.d.ts +1 -1
- package/lib/typescript/modules/computer_vision/OCRModule.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/TextToImageModule.d.ts +16 -0
- package/lib/typescript/modules/computer_vision/TextToImageModule.d.ts.map +1 -0
- package/lib/typescript/modules/computer_vision/VerticalOCRModule.d.ts +1 -1
- package/lib/typescript/modules/computer_vision/VerticalOCRModule.d.ts.map +1 -1
- package/lib/typescript/modules/natural_language_processing/SpeechToTextModule.d.ts +3 -2
- package/lib/typescript/modules/natural_language_processing/SpeechToTextModule.d.ts.map +1 -1
- package/lib/typescript/modules/natural_language_processing/VADModule.d.ts +10 -0
- package/lib/typescript/modules/natural_language_processing/VADModule.d.ts.map +1 -0
- package/lib/typescript/types/llm.d.ts +2 -0
- package/lib/typescript/types/llm.d.ts.map +1 -1
- package/lib/typescript/types/vad.d.ts +5 -0
- package/lib/typescript/types/vad.d.ts.map +1 -0
- package/lib/typescript/utils/ResourceFetcher.d.ts +29 -0
- package/lib/typescript/utils/ResourceFetcher.d.ts.map +1 -1
- package/lib/typescript/utils/ResourceFetcherUtils.d.ts +2 -2
- package/lib/typescript/utils/ResourceFetcherUtils.d.ts.map +1 -1
- package/package.json +11 -8
- package/react-native-executorch.podspec +9 -9
- package/src/Error.ts +1 -0
- package/src/constants/directories.ts +1 -1
- package/src/constants/modelUrls.ts +36 -1
- package/src/constants/ocr/models.ts +7 -7
- package/src/constants/ocr/symbols.ts +3 -2
- package/src/controllers/LLMController.ts +12 -1
- package/src/controllers/OCRController.ts +3 -3
- package/src/controllers/VerticalOCRController.ts +2 -2
- package/src/hooks/computer_vision/useOCR.ts +4 -5
- package/src/hooks/computer_vision/useTextToImage.ts +92 -0
- package/src/hooks/computer_vision/useVerticalOCR.ts +4 -5
- package/src/hooks/natural_language_processing/useLLM.ts +3 -4
- package/src/hooks/natural_language_processing/useTokenizer.ts +5 -5
- package/src/hooks/natural_language_processing/useVAD.ts +15 -0
- package/src/index.ts +20 -1
- package/src/modules/computer_vision/OCRModule.ts +2 -2
- package/src/modules/computer_vision/TextToImageModule.ts +93 -0
- package/src/modules/computer_vision/VerticalOCRModule.ts +2 -2
- package/src/modules/natural_language_processing/SpeechToTextModule.ts +8 -4
- package/src/modules/natural_language_processing/VADModule.ts +27 -0
- package/src/types/llm.ts +2 -0
- package/src/types/vad.ts +4 -0
- package/src/utils/ResourceFetcher.ts +2 -1
- package/src/utils/ResourceFetcherUtils.ts +8 -8
- package/third-party/android/libs/cpuinfo/arm64-v8a/libcpuinfo.so +0 -0
- package/third-party/android/libs/executorch/arm64-v8a/libexecutorch.so +0 -0
- package/third-party/android/libs/executorch/x86_64/libexecutorch.so +0 -0
- package/third-party/android/libs/pthreadpool/arm64-v8a/libpthreadpool.so +0 -0
- package/third-party/include/c10/macros/Export.h +0 -78
- package/third-party/include/c10/macros/Macros.h +1 -520
- package/third-party/include/c10/util/BFloat16-inl.h +1 -339
- package/third-party/include/c10/util/BFloat16.h +1 -122
- package/third-party/include/c10/util/Half-inl.h +1 -347
- package/third-party/include/c10/util/Half.h +6 -419
- package/third-party/include/c10/util/TypeSafeSignMath.h +1 -133
- package/third-party/include/c10/util/bit_cast.h +1 -43
- package/third-party/include/c10/util/complex.h +1 -568
- package/third-party/include/c10/util/floating_point_utils.h +1 -33
- package/third-party/include/c10/util/irange.h +1 -1
- package/third-party/include/c10/util/llvmMathExtras.h +866 -0
- package/third-party/include/c10/util/safe_numerics.h +97 -0
- package/third-party/include/executorch/ExecuTorchError.h +6 -7
- package/third-party/include/executorch/ExecuTorchLLM/ExecuTorchLLM.h +12 -0
- package/third-party/include/executorch/ExecuTorchLLM/ExecuTorchLLMConfig.h +56 -0
- package/third-party/include/executorch/ExecuTorchLLM/ExecuTorchLLMError.h +16 -0
- package/third-party/include/executorch/ExecuTorchLLM/ExecuTorchLLMMultimodalRunner.h +227 -0
- package/third-party/include/executorch/ExecuTorchLLM/ExecuTorchLLMTextRunner.h +97 -0
- package/third-party/include/executorch/ExecuTorchLLM/module.modulemap +4 -0
- package/third-party/include/executorch/ExecuTorchLog.h +1 -0
- package/third-party/include/executorch/ExecuTorchModule.h +177 -4
- package/third-party/include/executorch/ExecuTorchTensor.h +3 -4
- package/third-party/include/executorch/ExecuTorchValue.h +1 -7
- package/third-party/include/executorch/extension/module/module.h +139 -8
- package/third-party/include/executorch/extension/tensor/tensor.h +1 -0
- package/third-party/include/executorch/extension/tensor/tensor_ptr.h +88 -26
- package/third-party/include/executorch/extension/threadpool/threadpool.h +4 -1
- package/third-party/include/executorch/runtime/backend/backend_init_context.h +6 -0
- package/third-party/include/executorch/runtime/backend/interface.h +1 -1
- package/third-party/include/executorch/runtime/core/error.h +76 -49
- package/third-party/include/executorch/runtime/core/exec_aten/util/scalar_type_util.h +18 -4
- package/third-party/include/executorch/runtime/core/memory_allocator.h +12 -2
- package/third-party/include/executorch/runtime/core/named_data_map.h +1 -11
- package/third-party/include/executorch/runtime/core/portable_type/c10/c10/macros/Export.h +0 -78
- package/third-party/include/executorch/runtime/core/portable_type/c10/c10/macros/Macros.h +1 -520
- package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-inl.h +1 -339
- package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/BFloat16.h +1 -122
- package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/Half-inl.h +1 -347
- package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/Half.h +6 -419
- package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/TypeSafeSignMath.h +1 -133
- package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/bit_cast.h +1 -43
- package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/complex.h +1 -568
- package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/floating_point_utils.h +1 -33
- package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/irange.h +1 -1
- package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/llvmMathExtras.h +866 -0
- package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/safe_numerics.h +97 -0
- package/third-party/include/executorch/runtime/core/portable_type/c10/torch/headeronly/macros/Export.h +66 -0
- package/third-party/include/executorch/runtime/core/portable_type/c10/torch/headeronly/macros/Macros.h +553 -0
- package/third-party/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/BFloat16.h +477 -0
- package/third-party/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/Half.h +781 -0
- package/third-party/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/TypeSafeSignMath.h +141 -0
- package/third-party/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/bit_cast.h +49 -0
- package/third-party/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/complex.h +593 -0
- package/third-party/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/floating_point_utils.h +38 -0
- package/third-party/include/executorch/runtime/core/tensor_layout.h +1 -1
- package/third-party/include/executorch/runtime/executor/merged_data_map.h +142 -0
- package/third-party/include/executorch/runtime/executor/method.h +21 -8
- package/third-party/include/executorch/runtime/executor/method_meta.h +20 -2
- package/third-party/include/executorch/runtime/executor/program.h +0 -10
- package/third-party/include/executorch/runtime/kernel/operator_registry.h +1 -1
- package/third-party/include/executorch/runtime/platform/compiler.h +2 -0
- package/third-party/include/executorch/schema/extended_header.h +10 -1
- package/third-party/include/torch/headeronly/macros/Export.h +66 -0
- package/third-party/include/torch/headeronly/macros/Macros.h +553 -0
- package/third-party/include/torch/headeronly/util/BFloat16.h +477 -0
- package/third-party/include/torch/headeronly/util/Half.h +781 -0
- package/third-party/include/torch/headeronly/util/TypeSafeSignMath.h +141 -0
- package/third-party/include/torch/headeronly/util/bit_cast.h +49 -0
- package/third-party/include/torch/headeronly/util/complex.h +593 -0
- package/third-party/include/torch/headeronly/util/floating_point_utils.h +38 -0
- package/third-party/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/ExecutorchLib +0 -0
- package/third-party/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Info.plist +0 -0
- package/third-party/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/ExecutorchLib +0 -0
- package/third-party/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Info.plist +0 -0
- package/common/rnexecutorch/tests/run_all_tests.sh +0 -14
- package/common/rnexecutorch/tests/run_test.sh +0 -18
- package/ios/RnExecutorch/utils/Conversions.h +0 -14
- package/ios/RnExecutorch/utils/ETError.h +0 -26
- package/ios/RnExecutorch/utils/ImageProcessor.h +0 -15
- package/ios/RnExecutorch/utils/ImageProcessor.mm +0 -147
- package/ios/RnExecutorch/utils/Numerical.h +0 -3
- package/ios/RnExecutorch/utils/Numerical.mm +0 -18
- package/ios/RnExecutorch/utils/ScalarType.h +0 -14
- package/ios/RnExecutorch/utils/ScalarType.mm +0 -21
- package/lib/module/hooks/useNonStaticModule.js.map +0 -1
- package/lib/typescript/hooks/useNonStaticModule.d.ts +0 -21
- package/lib/typescript/hooks/useNonStaticModule.d.ts.map +0 -1
- package/src/hooks/useNonStaticModule.ts +0 -74
- package/third-party/include/executorch/extension/kernel_util/make_boxed_from_unboxed_functor.h +0 -181
- package/third-party/include/executorch/extension/kernel_util/meta_programming.h +0 -108
- package/third-party/include/executorch/extension/kernel_util/type_list.h +0 -137
- package/third-party/include/executorch/extension/threadpool/threadpool_guard.h +0 -35
|
@@ -0,0 +1,142 @@
|
|
|
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 <executorch/runtime/core/named_data_map.h>
|
|
12
|
+
|
|
13
|
+
namespace executorch {
|
|
14
|
+
namespace ET_RUNTIME_NAMESPACE {
|
|
15
|
+
namespace internal {
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A NamedDataMap implementation that wraps other NamedDataMaps.
|
|
19
|
+
*/
|
|
20
|
+
class MergedDataMap final : public NamedDataMap {
|
|
21
|
+
public:
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new NamedDataMap that wraps two other data maps.
|
|
24
|
+
*
|
|
25
|
+
* @param[in] first The first NamedDataMap to merge.
|
|
26
|
+
* @param[in] second The second NamedDataMap to merge.
|
|
27
|
+
* Note: the data maps must outlive the MergedDataMap instance.
|
|
28
|
+
*/
|
|
29
|
+
static Result<MergedDataMap> load(const NamedDataMap *first,
|
|
30
|
+
const NamedDataMap *second) {
|
|
31
|
+
ET_CHECK_OR_RETURN_ERROR(first != nullptr && second != nullptr,
|
|
32
|
+
InvalidArgument, "Input data map is null.");
|
|
33
|
+
|
|
34
|
+
// Check for duplicate keys.
|
|
35
|
+
for (uint32_t k = 0; k < first->get_num_keys().get(); k++) {
|
|
36
|
+
const auto key = first->get_key(k).get();
|
|
37
|
+
const auto error = second->get_tensor_layout(key).error();
|
|
38
|
+
// TODO(lfq): add API to check if key exists.
|
|
39
|
+
ET_CHECK_OR_RETURN_ERROR(error == Error::NotFound ||
|
|
40
|
+
error == Error::NotImplemented,
|
|
41
|
+
InvalidArgument, "Duplicate key %s.", key);
|
|
42
|
+
}
|
|
43
|
+
return MergedDataMap(first, second);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Retrieve the tensor_layout for the specified key.
|
|
48
|
+
*
|
|
49
|
+
* @param[in] key The name of the tensor to get metadata on.
|
|
50
|
+
*
|
|
51
|
+
* @return Error::NotFound if the key is not present.
|
|
52
|
+
*/
|
|
53
|
+
ET_NODISCARD
|
|
54
|
+
Result<const TensorLayout>
|
|
55
|
+
get_tensor_layout(executorch::aten::string_view key) const override {
|
|
56
|
+
auto layout = first_->get_tensor_layout(key);
|
|
57
|
+
if (layout.ok()) {
|
|
58
|
+
return layout.get();
|
|
59
|
+
}
|
|
60
|
+
if (layout.error() != Error::NotFound) {
|
|
61
|
+
return layout.error();
|
|
62
|
+
}
|
|
63
|
+
return second_->get_tensor_layout(key);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Retrieve read-only data for the specified key.
|
|
68
|
+
*
|
|
69
|
+
* @param[in] key The name of the tensor to get data on.
|
|
70
|
+
*
|
|
71
|
+
* @return error if the key is not present or data cannot be loaded.
|
|
72
|
+
*/
|
|
73
|
+
ET_NODISCARD
|
|
74
|
+
Result<FreeableBuffer>
|
|
75
|
+
get_data(executorch::aten::string_view key) const override {
|
|
76
|
+
auto data = first_->get_data(key);
|
|
77
|
+
if (data.error() != Error::NotFound) {
|
|
78
|
+
return data;
|
|
79
|
+
}
|
|
80
|
+
return second_->get_data(key);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Loads the data of the specified tensor into the provided buffer.
|
|
85
|
+
* Not used in the MergedDataMap.
|
|
86
|
+
*
|
|
87
|
+
* @param[in] key The name of the tensor to get the data of.
|
|
88
|
+
* @param[in] buffer The buffer to load data into. Must point to at least
|
|
89
|
+
* `size` bytes of memory.
|
|
90
|
+
* @param[in] size The number of bytes to load.
|
|
91
|
+
*
|
|
92
|
+
* @returns an Error indicating if the load was successful.
|
|
93
|
+
*/
|
|
94
|
+
ET_NODISCARD Error load_data_into(ET_UNUSED executorch::aten::string_view key,
|
|
95
|
+
ET_UNUSED void *buffer,
|
|
96
|
+
ET_UNUSED size_t size) const override {
|
|
97
|
+
return Error::NotImplemented;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @returns The number of keys in the map.
|
|
102
|
+
*/
|
|
103
|
+
ET_NODISCARD Result<uint32_t> get_num_keys() const override {
|
|
104
|
+
return first_->get_num_keys().get() + second_->get_num_keys().get();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @returns The key at the specified index, error if index out of bounds.
|
|
109
|
+
*/
|
|
110
|
+
ET_NODISCARD Result<const char *> get_key(uint32_t index) const override {
|
|
111
|
+
uint32_t total_num_keys = get_num_keys().get();
|
|
112
|
+
ET_CHECK_OR_RETURN_ERROR(index < total_num_keys, InvalidArgument,
|
|
113
|
+
"Index %" PRIu32 " out of range of size %" PRIu32,
|
|
114
|
+
index, total_num_keys);
|
|
115
|
+
|
|
116
|
+
if (index < first_->get_num_keys().get()) {
|
|
117
|
+
return first_->get_key(index);
|
|
118
|
+
} else {
|
|
119
|
+
return second_->get_key(index - first_->get_num_keys().get());
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
MergedDataMap(MergedDataMap &&) noexcept = default;
|
|
124
|
+
|
|
125
|
+
~MergedDataMap() override = default;
|
|
126
|
+
|
|
127
|
+
private:
|
|
128
|
+
MergedDataMap(const NamedDataMap *first, const NamedDataMap *second)
|
|
129
|
+
: first_{first}, second_{second} {}
|
|
130
|
+
|
|
131
|
+
// Not copyable or assignable.
|
|
132
|
+
MergedDataMap(const MergedDataMap &rhs) = delete;
|
|
133
|
+
MergedDataMap &operator=(MergedDataMap &&rhs) noexcept = delete;
|
|
134
|
+
MergedDataMap &operator=(const MergedDataMap &rhs) = delete;
|
|
135
|
+
|
|
136
|
+
const NamedDataMap *first_;
|
|
137
|
+
const NamedDataMap *second_;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
} // namespace internal
|
|
141
|
+
} // namespace ET_RUNTIME_NAMESPACE
|
|
142
|
+
} // namespace executorch
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
#include <executorch/runtime/core/named_data_map.h>
|
|
21
21
|
#include <executorch/runtime/core/span.h>
|
|
22
22
|
#include <executorch/runtime/executor/memory_manager.h>
|
|
23
|
+
#include <executorch/runtime/executor/merged_data_map.h>
|
|
23
24
|
#include <executorch/runtime/executor/method_meta.h>
|
|
24
25
|
#include <executorch/runtime/platform/compiler.h>
|
|
25
26
|
|
|
@@ -47,7 +48,7 @@ class Program;
|
|
|
47
48
|
class BackendDelegate;
|
|
48
49
|
struct Chain;
|
|
49
50
|
class KernelRuntimeContext;
|
|
50
|
-
using OpFunction = void (*)(KernelRuntimeContext &, EValue
|
|
51
|
+
using OpFunction = void (*)(KernelRuntimeContext &, Span<EValue *>);
|
|
51
52
|
/// A list of pointers into the master values table that together compose the
|
|
52
53
|
/// argument list for a single instruction
|
|
53
54
|
using InstructionArgs = Span<EValue *>;
|
|
@@ -69,17 +70,22 @@ public:
|
|
|
69
70
|
temp_allocator_(rhs.temp_allocator_),
|
|
70
71
|
serialization_plan_(rhs.serialization_plan_),
|
|
71
72
|
event_tracer_(rhs.event_tracer_), n_value_(rhs.n_value_),
|
|
72
|
-
values_(rhs.values_),
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
values_(rhs.values_), input_set_(rhs.input_set_),
|
|
74
|
+
n_delegate_(rhs.n_delegate_), delegates_(rhs.delegates_),
|
|
75
|
+
n_chains_(rhs.n_chains_), chains_(rhs.chains_),
|
|
76
|
+
merged_data_map_(std::move(rhs.merged_data_map_)),
|
|
77
|
+
external_constants_(rhs.external_constants_),
|
|
75
78
|
n_external_constants_(rhs.n_external_constants_),
|
|
76
79
|
init_state_(rhs.init_state_) {
|
|
77
80
|
// Required: clear out fields that the dtor looks at, so that we don't free
|
|
78
81
|
// anything twice.
|
|
79
82
|
rhs.n_value_ = 0;
|
|
80
83
|
rhs.values_ = nullptr;
|
|
84
|
+
rhs.input_set_ = nullptr;
|
|
81
85
|
rhs.n_delegate_ = 0;
|
|
82
86
|
rhs.delegates_ = nullptr;
|
|
87
|
+
|
|
88
|
+
rhs.merged_data_map_ = nullptr;
|
|
83
89
|
rhs.n_external_constants_ = 0;
|
|
84
90
|
rhs.external_constants_ = nullptr;
|
|
85
91
|
|
|
@@ -172,6 +178,9 @@ public:
|
|
|
172
178
|
ET_NODISCARD Error get_outputs(EValue *output_evalues, size_t length);
|
|
173
179
|
|
|
174
180
|
/**
|
|
181
|
+
* DEPRECATED: Use MethodMeta instead to access metadata, and set_input to
|
|
182
|
+
* update Method inputs.
|
|
183
|
+
*
|
|
175
184
|
* Copies the method's inputs into the provided array.
|
|
176
185
|
*
|
|
177
186
|
* WARNING: The input contains shallow copies of internal tensor inputs.
|
|
@@ -185,7 +194,8 @@ public:
|
|
|
185
194
|
*
|
|
186
195
|
* @returns Error::Ok on success, non-Ok on failure.
|
|
187
196
|
*/
|
|
188
|
-
ET_NODISCARD Error get_inputs(EValue *input_evalues,
|
|
197
|
+
ET_DEPRECATED ET_NODISCARD Error get_inputs(EValue *input_evalues,
|
|
198
|
+
size_t length);
|
|
189
199
|
|
|
190
200
|
/**
|
|
191
201
|
*
|
|
@@ -216,7 +226,7 @@ public:
|
|
|
216
226
|
* @retval non-Ok step failed
|
|
217
227
|
* @retval Error::EndOfMethod method finished executing successfully
|
|
218
228
|
*/
|
|
219
|
-
|
|
229
|
+
ET_NODISCARD Error step();
|
|
220
230
|
|
|
221
231
|
/// DEPRECATED: Use `step()` instead.
|
|
222
232
|
ET_DEPRECATED ET_NODISCARD Error experimental_step();
|
|
@@ -230,7 +240,7 @@ public:
|
|
|
230
240
|
* the end of the Method. This means it is not possible to recover a
|
|
231
241
|
* Method that failed mid-execution.
|
|
232
242
|
*/
|
|
233
|
-
|
|
243
|
+
ET_NODISCARD Error reset_execution();
|
|
234
244
|
|
|
235
245
|
/// DEPRECATED: Use `reset_execution()` instead.
|
|
236
246
|
ET_DEPRECATED ET_NODISCARD Error experimental_reset_execution();
|
|
@@ -297,7 +307,8 @@ private:
|
|
|
297
307
|
: step_state_(), program_(program), memory_manager_(memory_manager),
|
|
298
308
|
temp_allocator_(temp_allocator), serialization_plan_(nullptr),
|
|
299
309
|
event_tracer_(event_tracer), n_value_(0), values_(nullptr),
|
|
300
|
-
n_delegate_(0), delegates_(nullptr), n_chains_(0),
|
|
310
|
+
input_set_(nullptr), n_delegate_(0), delegates_(nullptr), n_chains_(0),
|
|
311
|
+
chains_(nullptr), merged_data_map_(nullptr),
|
|
301
312
|
external_constants_(nullptr), n_external_constants_(0),
|
|
302
313
|
init_state_(InitializationState::Uninitialized) {}
|
|
303
314
|
|
|
@@ -337,6 +348,7 @@ private:
|
|
|
337
348
|
|
|
338
349
|
size_t n_value_;
|
|
339
350
|
EValue *values_;
|
|
351
|
+
bool *input_set_;
|
|
340
352
|
|
|
341
353
|
size_t n_delegate_;
|
|
342
354
|
BackendDelegate *delegates_;
|
|
@@ -344,6 +356,7 @@ private:
|
|
|
344
356
|
size_t n_chains_;
|
|
345
357
|
Chain *chains_;
|
|
346
358
|
|
|
359
|
+
internal::MergedDataMap *merged_data_map_;
|
|
347
360
|
NamedData *external_constants_;
|
|
348
361
|
size_t n_external_constants_ = 0;
|
|
349
362
|
|
|
@@ -77,9 +77,27 @@ private:
|
|
|
77
77
|
friend class MethodMeta;
|
|
78
78
|
friend class testing::TensorInfoTestFriend;
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Create a TensorInfo instance.
|
|
82
|
+
*
|
|
83
|
+
* @param[in] sizes The sizes of the tensor.
|
|
84
|
+
* @param[in] dim_order The dim order of the tensor.
|
|
85
|
+
* @param[in] scalar_type The scalar type of the tensor.
|
|
86
|
+
* @param[in] is_memory_planned Whether the tensor's memory was planned.
|
|
87
|
+
* @param[in] name The fully qualified name of the tensor.
|
|
88
|
+
* @returns A Result containing the TensorInfo on success, or an error on
|
|
89
|
+
* failure.
|
|
90
|
+
*/
|
|
91
|
+
static Result<TensorInfo> create(Span<const int32_t> sizes,
|
|
92
|
+
Span<const uint8_t> dim_order,
|
|
93
|
+
executorch::aten::ScalarType scalar_type,
|
|
94
|
+
const bool is_memory_planned,
|
|
95
|
+
std::string_view name);
|
|
96
|
+
|
|
80
97
|
TensorInfo(Span<const int32_t> sizes, Span<const uint8_t> dim_order,
|
|
81
98
|
executorch::aten::ScalarType scalar_type,
|
|
82
|
-
const bool is_memory_planned, std::string_view name
|
|
99
|
+
const bool is_memory_planned, std::string_view name,
|
|
100
|
+
size_t nbytes);
|
|
83
101
|
|
|
84
102
|
/**
|
|
85
103
|
* The sizes of the tensor.
|
|
@@ -241,7 +259,7 @@ public:
|
|
|
241
259
|
*
|
|
242
260
|
* @returns The number of instructions.
|
|
243
261
|
*/
|
|
244
|
-
|
|
262
|
+
size_t num_instructions() const;
|
|
245
263
|
|
|
246
264
|
/**
|
|
247
265
|
* DEPRECATED: Use num_memory_planned_buffers() instead.
|
|
@@ -8,12 +8,6 @@
|
|
|
8
8
|
|
|
9
9
|
#pragma once
|
|
10
10
|
|
|
11
|
-
#ifdef __GNUC__
|
|
12
|
-
// Disable -Wdeprecated-declarations, as some builds use 'Werror'.
|
|
13
|
-
#pragma GCC diagnostic push
|
|
14
|
-
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
|
15
|
-
#endif
|
|
16
|
-
|
|
17
11
|
#include <cinttypes>
|
|
18
12
|
#include <cstdint>
|
|
19
13
|
#include <optional>
|
|
@@ -313,7 +307,3 @@ namespace executor {
|
|
|
313
307
|
using ::executorch::ET_RUNTIME_NAMESPACE::Program;
|
|
314
308
|
} // namespace executor
|
|
315
309
|
} // namespace torch
|
|
316
|
-
|
|
317
|
-
#ifdef __GNUC__
|
|
318
|
-
#pragma GCC diagnostic pop
|
|
319
|
-
#endif
|
|
@@ -40,7 +40,7 @@ namespace executorch {
|
|
|
40
40
|
namespace ET_RUNTIME_NAMESPACE {
|
|
41
41
|
|
|
42
42
|
class KernelRuntimeContext; // Forward declaration
|
|
43
|
-
using OpFunction = void (*)(KernelRuntimeContext &, EValue
|
|
43
|
+
using OpFunction = void (*)(KernelRuntimeContext &, Span<EValue *>);
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* Dtype and dim order metadata for a Tensor argument to an operator.
|
|
@@ -149,8 +149,10 @@
|
|
|
149
149
|
// As of G3 RJ-2024.3 toolchain, zu format specifier is not supported for Xtensa
|
|
150
150
|
#if defined(__XTENSA__)
|
|
151
151
|
#define ET_PRIsize_t "lu"
|
|
152
|
+
#define ET_PRIssize_t "ld"
|
|
152
153
|
#else
|
|
153
154
|
#define ET_PRIsize_t "zu"
|
|
155
|
+
#define ET_PRIssize_t "zd"
|
|
154
156
|
#endif
|
|
155
157
|
|
|
156
158
|
// Whether the compiler supports GNU statement expressions.
|
|
@@ -22,7 +22,8 @@ namespace runtime {
|
|
|
22
22
|
struct ExtendedHeader {
|
|
23
23
|
/**
|
|
24
24
|
* To find the header, callers should provide at least this many bytes of the
|
|
25
|
-
* head of the serialized Program data.
|
|
25
|
+
* head of the serialized Program data. Keep this in sync with NUM_HEAD_BYTES
|
|
26
|
+
* in //executorch/exir/_serialize/program.py
|
|
26
27
|
*/
|
|
27
28
|
static constexpr size_t kNumHeadBytes = 64;
|
|
28
29
|
|
|
@@ -70,6 +71,14 @@ struct ExtendedHeader {
|
|
|
70
71
|
* is present.
|
|
71
72
|
*/
|
|
72
73
|
uint64_t segment_base_offset;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The size of all the segment data, in bytes. Zero if:
|
|
77
|
+
* - no segment is present
|
|
78
|
+
* - the segment_data_size field doesn't exist in the header - the case for
|
|
79
|
+
* older PTE files.
|
|
80
|
+
*/
|
|
81
|
+
uint64_t segment_data_size;
|
|
73
82
|
};
|
|
74
83
|
|
|
75
84
|
} // namespace runtime
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
#define C10_USING_CUSTOM_GENERATED_MACROS
|
|
2
2
|
#pragma once
|
|
3
3
|
|
|
4
|
+
#ifndef C10_MACROS_EXPORT_H_
|
|
5
|
+
#define C10_MACROS_EXPORT_H_
|
|
6
|
+
|
|
7
|
+
#ifndef C10_USING_CUSTOM_GENERATED_MACROS
|
|
8
|
+
#include <torch/headeronly/macros/cmake_macros.h>
|
|
9
|
+
#endif // C10_USING_CUSTOM_GENERATED_MACROS
|
|
10
|
+
|
|
4
11
|
/* Header file to define the common scaffolding for exported symbols.
|
|
5
12
|
*
|
|
6
13
|
* Export is by itself a quite tricky situation to deal with, and if you are
|
|
@@ -86,3 +93,62 @@
|
|
|
86
93
|
#else
|
|
87
94
|
#define C10_API C10_IMPORT
|
|
88
95
|
#endif
|
|
96
|
+
|
|
97
|
+
// This one is being used by libtorch.so
|
|
98
|
+
#ifdef CAFFE2_BUILD_MAIN_LIB
|
|
99
|
+
#define TORCH_API C10_EXPORT
|
|
100
|
+
#else
|
|
101
|
+
#define TORCH_API C10_IMPORT
|
|
102
|
+
#endif
|
|
103
|
+
|
|
104
|
+
// You may be wondering why we have TORCH_CUDA_CPP_API and TORCH_CUDA_CU_API
|
|
105
|
+
// belonging to the same library instead of just one TORCH_CUDA_API. Well, it
|
|
106
|
+
// can indeed just be one TORCH_CUDA_API (and used to be)! TORCH_CUDA_CPP_API
|
|
107
|
+
// and TORCH_CUDA_CU_API are artifacts of when we needed a split build to
|
|
108
|
+
// avoid relocation marker linking errors. The context is as follows:
|
|
109
|
+
//
|
|
110
|
+
// Once upon a time, there _was_ only TORCH_CUDA_API. All was happy until we
|
|
111
|
+
// tried to compile PyTorch for CUDA 11.1, which ran into relocation marker
|
|
112
|
+
// issues when linking big binaries.
|
|
113
|
+
// (https://github.com/pytorch/pytorch/issues/39968) We had two choices:
|
|
114
|
+
// (1) Stop supporting so many GPU architectures
|
|
115
|
+
// (2) Do something else
|
|
116
|
+
// We chose #2 and decided to split the behemoth that was torch_cuda into two
|
|
117
|
+
// smaller libraries, one with most of the core kernel functions (torch_cuda_cu)
|
|
118
|
+
// and the other that had..well..everything else (torch_cuda_cpp). The idea was
|
|
119
|
+
// this: instead of linking our static libraries (like the hefty
|
|
120
|
+
// libcudnn_static.a) with another huge library, torch_cuda, and run into pesky
|
|
121
|
+
// relocation marker issues, we could link our static libraries to a smaller
|
|
122
|
+
// part of torch_cuda (torch_cuda_cpp) and avoid the issues.
|
|
123
|
+
|
|
124
|
+
// libtorch_cuda.so (where torch_cuda_cu and torch_cuda_cpp are a part of the
|
|
125
|
+
// same api)
|
|
126
|
+
#ifdef TORCH_CUDA_BUILD_MAIN_LIB
|
|
127
|
+
#define TORCH_CUDA_CPP_API C10_EXPORT
|
|
128
|
+
#define TORCH_CUDA_CU_API C10_EXPORT
|
|
129
|
+
#else
|
|
130
|
+
#define TORCH_CUDA_CPP_API C10_IMPORT
|
|
131
|
+
#define TORCH_CUDA_CU_API C10_IMPORT
|
|
132
|
+
#endif
|
|
133
|
+
|
|
134
|
+
#if defined(TORCH_HIP_BUILD_MAIN_LIB)
|
|
135
|
+
#define TORCH_HIP_CPP_API C10_EXPORT
|
|
136
|
+
#define TORCH_HIP_API C10_EXPORT
|
|
137
|
+
#else
|
|
138
|
+
#define TORCH_HIP_CPP_API C10_IMPORT
|
|
139
|
+
#define TORCH_HIP_API C10_IMPORT
|
|
140
|
+
#endif
|
|
141
|
+
|
|
142
|
+
#if defined(TORCH_XPU_BUILD_MAIN_LIB)
|
|
143
|
+
#define TORCH_XPU_API C10_EXPORT
|
|
144
|
+
#else
|
|
145
|
+
#define TORCH_XPU_API C10_IMPORT
|
|
146
|
+
#endif
|
|
147
|
+
|
|
148
|
+
// Enums only need to be exported on windows for non-CUDA files
|
|
149
|
+
#if defined(_WIN32) && defined(__CUDACC__)
|
|
150
|
+
#define C10_API_ENUM C10_API
|
|
151
|
+
#else
|
|
152
|
+
#define C10_API_ENUM
|
|
153
|
+
#endif
|
|
154
|
+
#endif // C10_MACROS_EXPORT_H_
|