react-native-executorch 0.5.5 → 0.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/android/libs/classes.jar +0 -0
  2. package/android/src/main/cpp/CMakeLists.txt +23 -14
  3. package/common/rnexecutorch/RnExecutorchInstaller.cpp +4 -21
  4. package/common/rnexecutorch/host_objects/ModelHostObject.h +67 -51
  5. package/common/rnexecutorch/models/llm/LLM.cpp +24 -1
  6. package/common/rnexecutorch/models/llm/LLM.h +4 -1
  7. package/common/rnexecutorch/models/speech_to_text/SpeechToText.cpp +2 -5
  8. package/common/rnexecutorch/models/speech_to_text/SpeechToText.h +1 -1
  9. package/common/rnexecutorch/threads/GlobalThreadPool.h +79 -0
  10. package/common/rnexecutorch/threads/HighPerformanceThreadPool.h +364 -0
  11. package/common/rnexecutorch/threads/utils/ThreadUtils.h +29 -0
  12. package/common/runner/runner.cpp +9 -3
  13. package/common/runner/runner.h +4 -3
  14. package/common/runner/text_token_generator.h +28 -10
  15. package/lib/module/controllers/LLMController.js +21 -2
  16. package/lib/module/controllers/LLMController.js.map +1 -1
  17. package/lib/module/hooks/natural_language_processing/useLLM.js +6 -2
  18. package/lib/module/hooks/natural_language_processing/useLLM.js.map +1 -1
  19. package/lib/module/modules/natural_language_processing/LLMModule.js +4 -2
  20. package/lib/module/modules/natural_language_processing/LLMModule.js.map +1 -1
  21. package/lib/module/types/llm.js.map +1 -1
  22. package/lib/typescript/controllers/LLMController.d.ts +4 -2
  23. package/lib/typescript/controllers/LLMController.d.ts.map +1 -1
  24. package/lib/typescript/hooks/natural_language_processing/useLLM.d.ts.map +1 -1
  25. package/lib/typescript/modules/natural_language_processing/LLMModule.d.ts +3 -2
  26. package/lib/typescript/modules/natural_language_processing/LLMModule.d.ts.map +1 -1
  27. package/lib/typescript/types/llm.d.ts +7 -1
  28. package/lib/typescript/types/llm.d.ts.map +1 -1
  29. package/package.json +3 -1
  30. package/react-native-executorch.podspec +12 -31
  31. package/src/controllers/LLMController.ts +29 -5
  32. package/src/hooks/natural_language_processing/useLLM.ts +15 -1
  33. package/src/modules/natural_language_processing/LLMModule.ts +10 -2
  34. package/src/types/llm.ts +8 -0
  35. package/third-party/android/libs/cpuinfo/arm64-v8a/libcpuinfo.so +0 -0
  36. package/third-party/android/libs/executorch/arm64-v8a/libexecutorch.so +0 -0
  37. package/third-party/android/libs/executorch/x86_64/libexecutorch.so +0 -0
  38. package/third-party/android/libs/pthreadpool/arm64-v8a/libpthreadpool.so +0 -0
  39. package/third-party/android/libs/tokenizers-cpp/arm64-v8a/libsentencepiece.a +0 -0
  40. package/third-party/android/libs/tokenizers-cpp/arm64-v8a/libtokenizers_c.a +0 -0
  41. package/third-party/android/libs/tokenizers-cpp/arm64-v8a/libtokenizers_cpp.a +0 -0
  42. package/third-party/android/libs/tokenizers-cpp/x86_64/libsentencepiece.a +0 -0
  43. package/third-party/android/libs/tokenizers-cpp/x86_64/libtokenizers_c.a +0 -0
  44. package/third-party/android/libs/tokenizers-cpp/x86_64/libtokenizers_cpp.a +0 -0
  45. package/third-party/include/c10/macros/Export.h +2 -86
  46. package/third-party/include/c10/macros/Macros.h +28 -5
  47. package/third-party/include/c10/util/BFloat16-inl.h +1 -4
  48. package/third-party/include/c10/util/BFloat16.h +5 -8
  49. package/third-party/include/c10/util/Half.h +5 -0
  50. package/third-party/include/c10/util/bit_cast.h +1 -1
  51. package/third-party/include/c10/util/complex.h +639 -0
  52. package/third-party/include/c10/util/complex_math.h +399 -0
  53. package/third-party/include/c10/util/complex_utils.h +41 -0
  54. package/third-party/include/c10/util/irange.h +2 -2
  55. package/third-party/include/c10/util/overflows.h +95 -0
  56. package/third-party/include/executorch/ExecuTorchError.h +75 -0
  57. package/third-party/include/executorch/ExecuTorchModule.h +115 -11
  58. package/third-party/include/executorch/ExecuTorchTensor.h +731 -51
  59. package/third-party/include/executorch/ExecuTorchValue.h +61 -9
  60. package/third-party/include/executorch/extension/kernel_util/make_boxed_from_unboxed_functor.h +181 -0
  61. package/third-party/include/executorch/extension/kernel_util/meta_programming.h +108 -0
  62. package/third-party/include/executorch/extension/kernel_util/type_list.h +137 -0
  63. package/third-party/include/executorch/extension/module/bundled_module.h +131 -0
  64. package/third-party/include/executorch/extension/module/module.h +46 -20
  65. package/third-party/include/executorch/extension/threadpool/cpuinfo_utils.h +1 -3
  66. package/third-party/include/executorch/extension/threadpool/threadpool.h +1 -3
  67. package/third-party/include/executorch/extension/threadpool/threadpool_guard.h +35 -0
  68. package/third-party/include/executorch/runtime/backend/backend_execution_context.h +3 -3
  69. package/third-party/include/executorch/runtime/backend/backend_init_context.h +12 -6
  70. package/third-party/include/executorch/runtime/backend/backend_option_context.h +34 -0
  71. package/third-party/include/executorch/runtime/backend/interface.h +70 -9
  72. package/third-party/include/executorch/runtime/backend/options.h +206 -0
  73. package/third-party/include/executorch/runtime/core/evalue.h +19 -25
  74. package/third-party/include/executorch/runtime/core/event_tracer.h +32 -17
  75. package/third-party/include/executorch/runtime/core/event_tracer_hooks.h +23 -14
  76. package/third-party/include/executorch/runtime/core/exec_aten/exec_aten.h +32 -9
  77. package/third-party/include/executorch/runtime/core/exec_aten/util/dim_order_util.h +3 -2
  78. package/third-party/include/executorch/runtime/core/exec_aten/util/scalar_type_util.h +43 -75
  79. package/third-party/include/executorch/runtime/core/exec_aten/util/tensor_util.h +88 -87
  80. package/third-party/include/executorch/runtime/core/function_ref.h +100 -0
  81. package/third-party/include/executorch/runtime/core/named_data_map.h +14 -14
  82. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/macros/Export.h +2 -86
  83. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/macros/Macros.h +28 -5
  84. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-inl.h +1 -4
  85. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/BFloat16.h +5 -8
  86. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/Half.h +5 -0
  87. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/bit_cast.h +1 -1
  88. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/complex.h +639 -0
  89. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/complex_math.h +399 -0
  90. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/complex_utils.h +41 -0
  91. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/irange.h +2 -2
  92. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/overflows.h +95 -0
  93. package/third-party/include/executorch/runtime/core/portable_type/c10/torch/headeronly/macros/Export.h +88 -0
  94. package/third-party/include/executorch/runtime/core/portable_type/complex.h +6 -29
  95. package/third-party/include/executorch/runtime/core/portable_type/tensor_impl.h +20 -0
  96. package/third-party/include/executorch/runtime/core/span.h +4 -0
  97. package/third-party/include/executorch/runtime/core/tag.h +19 -0
  98. package/third-party/include/executorch/runtime/core/tensor_layout.h +2 -2
  99. package/third-party/include/executorch/runtime/executor/method.h +15 -3
  100. package/third-party/include/executorch/runtime/executor/method_meta.h +34 -5
  101. package/third-party/include/executorch/runtime/executor/program.h +3 -4
  102. package/third-party/include/executorch/runtime/executor/pte_data_map.h +9 -8
  103. package/third-party/include/executorch/runtime/executor/tensor_parser.h +14 -13
  104. package/third-party/include/executorch/runtime/kernel/kernel_runtime_context.h +5 -5
  105. package/third-party/include/executorch/runtime/kernel/operator_registry.h +21 -19
  106. package/third-party/include/executorch/runtime/platform/compiler.h +8 -0
  107. package/third-party/include/executorch/runtime/platform/platform.h +126 -0
  108. package/third-party/include/headeronly/macros/Export.h +88 -0
  109. package/third-party/include/tokenizers-cpp/tokenizers_c.h +61 -0
  110. package/third-party/include/torch/headeronly/macros/Export.h +88 -0
  111. package/third-party/ios/ExecutorchLib.xcframework/Info.plist +43 -0
  112. package/third-party/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/ExecutorchLib +0 -0
  113. package/third-party/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Info.plist +0 -0
  114. package/third-party/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/ExecutorchLib +0 -0
  115. package/third-party/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Info.plist +0 -0
  116. package/third-party/ios/libs/cpuinfo/libcpuinfo.a +0 -0
  117. package/third-party/ios/libs/pthreadpool/physical-arm64-release/libpthreadpool.a +0 -0
  118. package/third-party/ios/libs/pthreadpool/simulator-arm64-debug/libpthreadpool.a +0 -0
  119. package/ios/libs/executorch/libbackend_coreml_ios.a +0 -0
  120. package/ios/libs/executorch/libbackend_coreml_simulator.a +0 -0
  121. package/ios/libs/executorch/libbackend_mps_ios.a +0 -0
  122. package/ios/libs/executorch/libbackend_mps_simulator.a +0 -0
  123. package/ios/libs/executorch/libbackend_xnnpack_ios.a +0 -0
  124. package/ios/libs/executorch/libbackend_xnnpack_simulator.a +0 -0
  125. package/ios/libs/executorch/libexecutorch_ios.a +0 -0
  126. package/ios/libs/executorch/libexecutorch_simulator.a +0 -0
  127. package/ios/libs/executorch/libkernels_custom_ios.a +0 -0
  128. package/ios/libs/executorch/libkernels_custom_simulator.a +0 -0
  129. package/ios/libs/executorch/libkernels_optimized_ios.a +0 -0
  130. package/ios/libs/executorch/libkernels_optimized_simulator.a +0 -0
  131. package/ios/libs/executorch/libkernels_portable_ios.a +0 -0
  132. package/ios/libs/executorch/libkernels_portable_simulator.a +0 -0
  133. package/ios/libs/executorch/libkernels_quantized_ios.a +0 -0
  134. package/ios/libs/executorch/libkernels_quantized_simulator.a +0 -0
  135. package/third-party/ios/ios.toolchain.cmake +0 -1122
  136. /package/{ios → third-party/ios}/libs/tokenizers-cpp/physical-arm64-release/libsentencepiece.a +0 -0
  137. /package/{ios → third-party/ios}/libs/tokenizers-cpp/physical-arm64-release/libtokenizers_c.a +0 -0
  138. /package/{ios → third-party/ios}/libs/tokenizers-cpp/physical-arm64-release/libtokenizers_cpp.a +0 -0
  139. /package/{ios → third-party/ios}/libs/tokenizers-cpp/simulator-arm64-debug/libsentencepiece.a +0 -0
  140. /package/{ios → third-party/ios}/libs/tokenizers-cpp/simulator-arm64-debug/libtokenizers_c.a +0 -0
  141. /package/{ios → third-party/ios}/libs/tokenizers-cpp/simulator-arm64-debug/libtokenizers_cpp.a +0 -0
@@ -14,14 +14,11 @@
14
14
  #include <cuda_bf16.h>
15
15
  #endif
16
16
 
17
- #if defined(SYCL_EXT_ONEAPI_BFLOAT16_MATH_FUNCTIONS)
18
17
  #if defined(CL_SYCL_LANGUAGE_VERSION)
19
18
  #include <CL/sycl.hpp> // for SYCL 1.2.1
20
- #else
19
+ #elif defined(SYCL_LANGUAGE_VERSION)
21
20
  #include <sycl/sycl.hpp> // for SYCL 2020
22
21
  #endif
23
- #include <ext/oneapi/bfloat16.hpp>
24
- #endif
25
22
 
26
23
  namespace c10 {
27
24
 
@@ -31,7 +28,7 @@ inline C10_HOST_DEVICE float f32_from_bits(uint16_t src) {
31
28
  uint32_t tmp = src;
32
29
  tmp <<= 16;
33
30
 
34
- #if defined(USE_ROCM)
31
+ #if defined(USE_ROCM) && defined(__HIPCC__)
35
32
  float *tempRes;
36
33
 
37
34
  // We should be using memcpy in order to respect the strict aliasing rule
@@ -48,7 +45,7 @@ inline C10_HOST_DEVICE float f32_from_bits(uint16_t src) {
48
45
  inline C10_HOST_DEVICE uint16_t bits_from_f32(float src) {
49
46
  uint32_t res = 0;
50
47
 
51
- #if defined(USE_ROCM)
48
+ #if defined(USE_ROCM) && defined(__HIPCC__)
52
49
  // We should be using memcpy in order to respect the strict aliasing rule
53
50
  // but it fails in the HIP environment.
54
51
  uint32_t *tempRes = reinterpret_cast<uint32_t *>(&src);
@@ -61,7 +58,7 @@ inline C10_HOST_DEVICE uint16_t bits_from_f32(float src) {
61
58
  }
62
59
 
63
60
  inline C10_HOST_DEVICE uint16_t round_to_nearest_even(float src) {
64
- #if defined(USE_ROCM)
61
+ #if defined(USE_ROCM) && defined(__HIPCC__)
65
62
  if (src != src) {
66
63
  #elif defined(_MSC_VER)
67
64
  if (isnan(src)) {
@@ -87,7 +84,7 @@ struct alignas(2) BFloat16 {
87
84
  uint16_t x;
88
85
 
89
86
  // HIP wants __host__ __device__ tag, CUDA does not
90
- #if defined(USE_ROCM)
87
+ #if defined(USE_ROCM) && defined(__HIPCC__)
91
88
  C10_HOST_DEVICE BFloat16() = default;
92
89
  #else
93
90
  BFloat16() = default;
@@ -242,7 +242,12 @@ C10_HOST_DEVICE inline float fp16_ieee_to_fp32_value(uint16_t h) {
242
242
  // const float exp_scale = 0x1.0p-112f;
243
243
  constexpr uint32_t scale_bits = (uint32_t)15 << 23;
244
244
  float exp_scale_val = 0;
245
+ #if defined(_MSC_VER) && defined(__clang__)
246
+ __builtin_memcpy(&exp_scale_val, &scale_bits, sizeof(exp_scale_val));
247
+ #else
245
248
  std::memcpy(&exp_scale_val, &scale_bits, sizeof(exp_scale_val));
249
+ #endif
250
+
246
251
  const float exp_scale = exp_scale_val;
247
252
  const float normalized_value =
248
253
  fp32_from_bits((two_w >> 4) + exp_offset) * exp_scale;
@@ -3,7 +3,7 @@
3
3
  #include <cstring>
4
4
  #include <type_traits>
5
5
 
6
- #if __has_include(<bit>) && (__cplusplus >= 202002L || (defined(__cpp_lib_bit_cast) && __cpp_lib_bit_cast >= 201806L))
6
+ #if __has_include(<bit>) && (defined(__cpp_lib_bit_cast) && __cpp_lib_bit_cast >= 201806L)
7
7
  #include <bit>
8
8
  #define C10_HAVE_STD_BIT_CAST 1
9
9
  #else