react-native-executorch 0.5.6 → 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.
- package/android/libs/classes.jar +0 -0
- package/android/src/main/cpp/CMakeLists.txt +23 -14
- package/common/rnexecutorch/RnExecutorchInstaller.cpp +4 -21
- package/common/rnexecutorch/host_objects/ModelHostObject.h +67 -51
- package/common/rnexecutorch/models/llm/LLM.cpp +24 -1
- package/common/rnexecutorch/models/llm/LLM.h +4 -1
- package/common/rnexecutorch/threads/GlobalThreadPool.h +79 -0
- package/common/rnexecutorch/threads/HighPerformanceThreadPool.h +364 -0
- package/common/rnexecutorch/threads/utils/ThreadUtils.h +29 -0
- package/common/runner/runner.cpp +9 -3
- package/common/runner/runner.h +4 -3
- package/common/runner/text_token_generator.h +28 -10
- package/lib/module/controllers/LLMController.js +21 -2
- package/lib/module/controllers/LLMController.js.map +1 -1
- package/lib/module/hooks/natural_language_processing/useLLM.js +6 -2
- package/lib/module/hooks/natural_language_processing/useLLM.js.map +1 -1
- package/lib/module/modules/natural_language_processing/LLMModule.js +4 -2
- package/lib/module/modules/natural_language_processing/LLMModule.js.map +1 -1
- package/lib/module/types/llm.js.map +1 -1
- package/lib/typescript/controllers/LLMController.d.ts +4 -2
- package/lib/typescript/controllers/LLMController.d.ts.map +1 -1
- package/lib/typescript/hooks/natural_language_processing/useLLM.d.ts.map +1 -1
- package/lib/typescript/modules/natural_language_processing/LLMModule.d.ts +3 -2
- package/lib/typescript/modules/natural_language_processing/LLMModule.d.ts.map +1 -1
- package/lib/typescript/types/llm.d.ts +7 -1
- package/lib/typescript/types/llm.d.ts.map +1 -1
- package/package.json +3 -1
- package/react-native-executorch.podspec +12 -31
- package/src/controllers/LLMController.ts +29 -5
- package/src/hooks/natural_language_processing/useLLM.ts +15 -1
- package/src/modules/natural_language_processing/LLMModule.ts +10 -2
- package/src/types/llm.ts +8 -0
- 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/android/libs/tokenizers-cpp/arm64-v8a/libsentencepiece.a +0 -0
- package/third-party/android/libs/tokenizers-cpp/arm64-v8a/libtokenizers_c.a +0 -0
- package/third-party/android/libs/tokenizers-cpp/arm64-v8a/libtokenizers_cpp.a +0 -0
- package/third-party/android/libs/tokenizers-cpp/x86_64/libsentencepiece.a +0 -0
- package/third-party/android/libs/tokenizers-cpp/x86_64/libtokenizers_c.a +0 -0
- package/third-party/android/libs/tokenizers-cpp/x86_64/libtokenizers_cpp.a +0 -0
- package/third-party/include/c10/macros/Export.h +2 -86
- package/third-party/include/c10/macros/Macros.h +28 -5
- package/third-party/include/c10/util/BFloat16-inl.h +1 -4
- package/third-party/include/c10/util/BFloat16.h +5 -8
- package/third-party/include/c10/util/Half.h +5 -0
- package/third-party/include/c10/util/bit_cast.h +1 -1
- package/third-party/include/c10/util/complex.h +639 -0
- package/third-party/include/c10/util/complex_math.h +399 -0
- package/third-party/include/c10/util/complex_utils.h +41 -0
- package/third-party/include/c10/util/irange.h +2 -2
- package/third-party/include/c10/util/overflows.h +95 -0
- package/third-party/include/executorch/ExecuTorchError.h +75 -0
- package/third-party/include/executorch/ExecuTorchModule.h +115 -11
- package/third-party/include/executorch/ExecuTorchTensor.h +731 -51
- package/third-party/include/executorch/ExecuTorchValue.h +61 -9
- package/third-party/include/executorch/extension/kernel_util/make_boxed_from_unboxed_functor.h +181 -0
- package/third-party/include/executorch/extension/kernel_util/meta_programming.h +108 -0
- package/third-party/include/executorch/extension/kernel_util/type_list.h +137 -0
- package/third-party/include/executorch/extension/module/bundled_module.h +131 -0
- package/third-party/include/executorch/extension/module/module.h +46 -20
- package/third-party/include/executorch/extension/threadpool/cpuinfo_utils.h +1 -3
- package/third-party/include/executorch/extension/threadpool/threadpool.h +1 -3
- package/third-party/include/executorch/extension/threadpool/threadpool_guard.h +35 -0
- package/third-party/include/executorch/runtime/backend/backend_execution_context.h +3 -3
- package/third-party/include/executorch/runtime/backend/backend_init_context.h +12 -6
- package/third-party/include/executorch/runtime/backend/backend_option_context.h +34 -0
- package/third-party/include/executorch/runtime/backend/interface.h +70 -9
- package/third-party/include/executorch/runtime/backend/options.h +206 -0
- package/third-party/include/executorch/runtime/core/evalue.h +19 -25
- package/third-party/include/executorch/runtime/core/event_tracer.h +32 -17
- package/third-party/include/executorch/runtime/core/event_tracer_hooks.h +23 -14
- package/third-party/include/executorch/runtime/core/exec_aten/exec_aten.h +32 -9
- package/third-party/include/executorch/runtime/core/exec_aten/util/dim_order_util.h +3 -2
- package/third-party/include/executorch/runtime/core/exec_aten/util/scalar_type_util.h +43 -75
- package/third-party/include/executorch/runtime/core/exec_aten/util/tensor_util.h +88 -87
- package/third-party/include/executorch/runtime/core/function_ref.h +100 -0
- package/third-party/include/executorch/runtime/core/named_data_map.h +14 -14
- package/third-party/include/executorch/runtime/core/portable_type/c10/c10/macros/Export.h +2 -86
- package/third-party/include/executorch/runtime/core/portable_type/c10/c10/macros/Macros.h +28 -5
- package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-inl.h +1 -4
- package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/BFloat16.h +5 -8
- package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/Half.h +5 -0
- package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/bit_cast.h +1 -1
- package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/complex.h +639 -0
- package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/complex_math.h +399 -0
- package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/complex_utils.h +41 -0
- package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/irange.h +2 -2
- package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/overflows.h +95 -0
- package/third-party/include/executorch/runtime/core/portable_type/c10/torch/headeronly/macros/Export.h +88 -0
- package/third-party/include/executorch/runtime/core/portable_type/complex.h +6 -29
- package/third-party/include/executorch/runtime/core/portable_type/tensor_impl.h +20 -0
- package/third-party/include/executorch/runtime/core/span.h +4 -0
- package/third-party/include/executorch/runtime/core/tag.h +19 -0
- package/third-party/include/executorch/runtime/core/tensor_layout.h +2 -2
- package/third-party/include/executorch/runtime/executor/method.h +15 -3
- package/third-party/include/executorch/runtime/executor/method_meta.h +34 -5
- package/third-party/include/executorch/runtime/executor/program.h +3 -4
- package/third-party/include/executorch/runtime/executor/pte_data_map.h +9 -8
- package/third-party/include/executorch/runtime/executor/tensor_parser.h +14 -13
- package/third-party/include/executorch/runtime/kernel/kernel_runtime_context.h +5 -5
- package/third-party/include/executorch/runtime/kernel/operator_registry.h +21 -19
- package/third-party/include/executorch/runtime/platform/compiler.h +8 -0
- package/third-party/include/executorch/runtime/platform/platform.h +126 -0
- package/third-party/include/headeronly/macros/Export.h +88 -0
- package/third-party/include/tokenizers-cpp/tokenizers_c.h +61 -0
- package/third-party/include/torch/headeronly/macros/Export.h +88 -0
- package/third-party/ios/ExecutorchLib.xcframework/Info.plist +43 -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/third-party/ios/libs/cpuinfo/libcpuinfo.a +0 -0
- package/third-party/ios/libs/pthreadpool/physical-arm64-release/libpthreadpool.a +0 -0
- package/third-party/ios/libs/pthreadpool/simulator-arm64-debug/libpthreadpool.a +0 -0
- package/ios/libs/executorch/libbackend_coreml_ios.a +0 -0
- package/ios/libs/executorch/libbackend_coreml_simulator.a +0 -0
- package/ios/libs/executorch/libbackend_mps_ios.a +0 -0
- package/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/third-party/ios/ios.toolchain.cmake +0 -1122
- /package/{ios → third-party/ios}/libs/tokenizers-cpp/physical-arm64-release/libsentencepiece.a +0 -0
- /package/{ios → third-party/ios}/libs/tokenizers-cpp/physical-arm64-release/libtokenizers_c.a +0 -0
- /package/{ios → third-party/ios}/libs/tokenizers-cpp/physical-arm64-release/libtokenizers_cpp.a +0 -0
- /package/{ios → third-party/ios}/libs/tokenizers-cpp/simulator-arm64-debug/libsentencepiece.a +0 -0
- /package/{ios → third-party/ios}/libs/tokenizers-cpp/simulator-arm64-debug/libtokenizers_c.a +0 -0
- /package/{ios → third-party/ios}/libs/tokenizers-cpp/simulator-arm64-debug/libtokenizers_cpp.a +0 -0
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
#if !defined(C10_INTERNAL_INCLUDE_COMPLEX_REMAINING_H)
|
|
2
|
+
#error \
|
|
3
|
+
"c10/util/complex_math.h is not meant to be individually included. Include c10/util/complex.h instead."
|
|
4
|
+
#endif
|
|
5
|
+
|
|
6
|
+
namespace c10_complex_math {
|
|
7
|
+
|
|
8
|
+
// Exponential functions
|
|
9
|
+
|
|
10
|
+
template <typename T>
|
|
11
|
+
C10_HOST_DEVICE inline c10::complex<T> exp(const c10::complex<T> &x) {
|
|
12
|
+
#if defined(__CUDACC__) || defined(__HIPCC__)
|
|
13
|
+
return static_cast<c10::complex<T>>(
|
|
14
|
+
thrust::exp(static_cast<thrust::complex<T>>(x)));
|
|
15
|
+
#else
|
|
16
|
+
return static_cast<c10::complex<T>>(
|
|
17
|
+
std::exp(static_cast<std::complex<T>>(x)));
|
|
18
|
+
#endif
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
template <typename T>
|
|
22
|
+
C10_HOST_DEVICE inline c10::complex<T> log(const c10::complex<T> &x) {
|
|
23
|
+
#if defined(__CUDACC__) || defined(__HIPCC__)
|
|
24
|
+
return static_cast<c10::complex<T>>(
|
|
25
|
+
thrust::log(static_cast<thrust::complex<T>>(x)));
|
|
26
|
+
#else
|
|
27
|
+
return static_cast<c10::complex<T>>(
|
|
28
|
+
std::log(static_cast<std::complex<T>>(x)));
|
|
29
|
+
#endif
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
template <typename T>
|
|
33
|
+
C10_HOST_DEVICE inline c10::complex<T> log10(const c10::complex<T> &x) {
|
|
34
|
+
#if defined(__CUDACC__) || defined(__HIPCC__)
|
|
35
|
+
return static_cast<c10::complex<T>>(
|
|
36
|
+
thrust::log10(static_cast<thrust::complex<T>>(x)));
|
|
37
|
+
#else
|
|
38
|
+
return static_cast<c10::complex<T>>(
|
|
39
|
+
std::log10(static_cast<std::complex<T>>(x)));
|
|
40
|
+
#endif
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
template <typename T>
|
|
44
|
+
C10_HOST_DEVICE inline c10::complex<T> log2(const c10::complex<T> &x) {
|
|
45
|
+
const c10::complex<T> log2 = c10::complex<T>(::log(2.0), 0.0);
|
|
46
|
+
return c10_complex_math::log(x) / log2;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Power functions
|
|
50
|
+
//
|
|
51
|
+
#if defined(_LIBCPP_VERSION) || \
|
|
52
|
+
(defined(__GLIBCXX__) && !defined(_GLIBCXX11_USE_C99_COMPLEX))
|
|
53
|
+
namespace _detail {
|
|
54
|
+
C10_API c10::complex<float> sqrt(const c10::complex<float> &in);
|
|
55
|
+
C10_API c10::complex<double> sqrt(const c10::complex<double> &in);
|
|
56
|
+
C10_API c10::complex<float> acos(const c10::complex<float> &in);
|
|
57
|
+
C10_API c10::complex<double> acos(const c10::complex<double> &in);
|
|
58
|
+
} // namespace _detail
|
|
59
|
+
#endif
|
|
60
|
+
|
|
61
|
+
template <typename T>
|
|
62
|
+
C10_HOST_DEVICE inline c10::complex<T> sqrt(const c10::complex<T> &x) {
|
|
63
|
+
#if defined(__CUDACC__) || defined(__HIPCC__)
|
|
64
|
+
return static_cast<c10::complex<T>>(
|
|
65
|
+
thrust::sqrt(static_cast<thrust::complex<T>>(x)));
|
|
66
|
+
#elif !(defined(_LIBCPP_VERSION) || \
|
|
67
|
+
(defined(__GLIBCXX__) && !defined(_GLIBCXX11_USE_C99_COMPLEX)))
|
|
68
|
+
return static_cast<c10::complex<T>>(
|
|
69
|
+
std::sqrt(static_cast<std::complex<T>>(x)));
|
|
70
|
+
#else
|
|
71
|
+
return _detail::sqrt(x);
|
|
72
|
+
#endif
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
template <typename T>
|
|
76
|
+
C10_HOST_DEVICE inline c10::complex<T> pow(const c10::complex<T> &x,
|
|
77
|
+
const c10::complex<T> &y) {
|
|
78
|
+
#if defined(__CUDACC__) || defined(__HIPCC__)
|
|
79
|
+
return static_cast<c10::complex<T>>(thrust::pow(
|
|
80
|
+
static_cast<thrust::complex<T>>(x), static_cast<thrust::complex<T>>(y)));
|
|
81
|
+
#else
|
|
82
|
+
return static_cast<c10::complex<T>>(std::pow(
|
|
83
|
+
static_cast<std::complex<T>>(x), static_cast<std::complex<T>>(y)));
|
|
84
|
+
#endif
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
template <typename T>
|
|
88
|
+
C10_HOST_DEVICE inline c10::complex<T> pow(const c10::complex<T> &x,
|
|
89
|
+
const T &y) {
|
|
90
|
+
#if defined(__CUDACC__) || defined(__HIPCC__)
|
|
91
|
+
return static_cast<c10::complex<T>>(
|
|
92
|
+
thrust::pow(static_cast<thrust::complex<T>>(x), y));
|
|
93
|
+
#else
|
|
94
|
+
return static_cast<c10::complex<T>>(
|
|
95
|
+
std::pow(static_cast<std::complex<T>>(x), y));
|
|
96
|
+
#endif
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
template <typename T>
|
|
100
|
+
C10_HOST_DEVICE inline c10::complex<T> pow(const T &x,
|
|
101
|
+
const c10::complex<T> &y) {
|
|
102
|
+
#if defined(__CUDACC__) || defined(__HIPCC__)
|
|
103
|
+
return static_cast<c10::complex<T>>(
|
|
104
|
+
thrust::pow(x, static_cast<thrust::complex<T>>(y)));
|
|
105
|
+
#else
|
|
106
|
+
return static_cast<c10::complex<T>>(
|
|
107
|
+
std::pow(x, static_cast<std::complex<T>>(y)));
|
|
108
|
+
#endif
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
template <typename T, typename U>
|
|
112
|
+
C10_HOST_DEVICE inline c10::complex<decltype(T() * U())>
|
|
113
|
+
pow(const c10::complex<T> &x, const c10::complex<U> &y) {
|
|
114
|
+
#if defined(__CUDACC__) || defined(__HIPCC__)
|
|
115
|
+
return static_cast<c10::complex<T>>(thrust::pow(
|
|
116
|
+
static_cast<thrust::complex<T>>(x), static_cast<thrust::complex<T>>(y)));
|
|
117
|
+
#else
|
|
118
|
+
return static_cast<c10::complex<T>>(std::pow(
|
|
119
|
+
static_cast<std::complex<T>>(x), static_cast<std::complex<T>>(y)));
|
|
120
|
+
#endif
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
template <typename T, typename U>
|
|
124
|
+
C10_HOST_DEVICE inline c10::complex<decltype(T() * U())>
|
|
125
|
+
pow(const c10::complex<T> &x, const U &y) {
|
|
126
|
+
#if defined(__CUDACC__) || defined(__HIPCC__)
|
|
127
|
+
return static_cast<c10::complex<T>>(
|
|
128
|
+
thrust::pow(static_cast<thrust::complex<T>>(x), y));
|
|
129
|
+
#else
|
|
130
|
+
return static_cast<c10::complex<T>>(
|
|
131
|
+
std::pow(static_cast<std::complex<T>>(x), y));
|
|
132
|
+
#endif
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
template <typename T, typename U>
|
|
136
|
+
C10_HOST_DEVICE inline c10::complex<decltype(T() * U())>
|
|
137
|
+
pow(const T &x, const c10::complex<U> &y) {
|
|
138
|
+
#if defined(__CUDACC__) || defined(__HIPCC__)
|
|
139
|
+
return static_cast<c10::complex<T>>(
|
|
140
|
+
thrust::pow(x, static_cast<thrust::complex<T>>(y)));
|
|
141
|
+
#else
|
|
142
|
+
return static_cast<c10::complex<T>>(
|
|
143
|
+
std::pow(x, static_cast<std::complex<T>>(y)));
|
|
144
|
+
#endif
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Trigonometric functions
|
|
148
|
+
|
|
149
|
+
template <typename T>
|
|
150
|
+
C10_HOST_DEVICE inline c10::complex<T> sin(const c10::complex<T> &x) {
|
|
151
|
+
#if defined(__CUDACC__) || defined(__HIPCC__)
|
|
152
|
+
return static_cast<c10::complex<T>>(
|
|
153
|
+
thrust::sin(static_cast<thrust::complex<T>>(x)));
|
|
154
|
+
#else
|
|
155
|
+
return static_cast<c10::complex<T>>(
|
|
156
|
+
std::sin(static_cast<std::complex<T>>(x)));
|
|
157
|
+
#endif
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
template <typename T>
|
|
161
|
+
C10_HOST_DEVICE inline c10::complex<T> cos(const c10::complex<T> &x) {
|
|
162
|
+
#if defined(__CUDACC__) || defined(__HIPCC__)
|
|
163
|
+
return static_cast<c10::complex<T>>(
|
|
164
|
+
thrust::cos(static_cast<thrust::complex<T>>(x)));
|
|
165
|
+
#else
|
|
166
|
+
return static_cast<c10::complex<T>>(
|
|
167
|
+
std::cos(static_cast<std::complex<T>>(x)));
|
|
168
|
+
#endif
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
template <typename T>
|
|
172
|
+
C10_HOST_DEVICE inline c10::complex<T> tan(const c10::complex<T> &x) {
|
|
173
|
+
#if defined(__CUDACC__) || defined(__HIPCC__)
|
|
174
|
+
return static_cast<c10::complex<T>>(
|
|
175
|
+
thrust::tan(static_cast<thrust::complex<T>>(x)));
|
|
176
|
+
#else
|
|
177
|
+
return static_cast<c10::complex<T>>(
|
|
178
|
+
std::tan(static_cast<std::complex<T>>(x)));
|
|
179
|
+
#endif
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
template <typename T>
|
|
183
|
+
C10_HOST_DEVICE inline c10::complex<T> asin(const c10::complex<T> &x) {
|
|
184
|
+
#if defined(__CUDACC__) || defined(__HIPCC__)
|
|
185
|
+
return static_cast<c10::complex<T>>(
|
|
186
|
+
thrust::asin(static_cast<thrust::complex<T>>(x)));
|
|
187
|
+
#else
|
|
188
|
+
return static_cast<c10::complex<T>>(
|
|
189
|
+
std::asin(static_cast<std::complex<T>>(x)));
|
|
190
|
+
#endif
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
template <typename T>
|
|
194
|
+
C10_HOST_DEVICE inline c10::complex<T> acos(const c10::complex<T> &x) {
|
|
195
|
+
#if defined(__CUDACC__) || defined(__HIPCC__)
|
|
196
|
+
return static_cast<c10::complex<T>>(
|
|
197
|
+
thrust::acos(static_cast<thrust::complex<T>>(x)));
|
|
198
|
+
#elif !defined(_LIBCPP_VERSION)
|
|
199
|
+
return static_cast<c10::complex<T>>(
|
|
200
|
+
std::acos(static_cast<std::complex<T>>(x)));
|
|
201
|
+
#else
|
|
202
|
+
return _detail::acos(x);
|
|
203
|
+
#endif
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
template <typename T>
|
|
207
|
+
C10_HOST_DEVICE inline c10::complex<T> atan(const c10::complex<T> &x) {
|
|
208
|
+
#if defined(__CUDACC__) || defined(__HIPCC__)
|
|
209
|
+
return static_cast<c10::complex<T>>(
|
|
210
|
+
thrust::atan(static_cast<thrust::complex<T>>(x)));
|
|
211
|
+
#else
|
|
212
|
+
return static_cast<c10::complex<T>>(
|
|
213
|
+
std::atan(static_cast<std::complex<T>>(x)));
|
|
214
|
+
#endif
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Hyperbolic functions
|
|
218
|
+
|
|
219
|
+
template <typename T>
|
|
220
|
+
C10_HOST_DEVICE inline c10::complex<T> sinh(const c10::complex<T> &x) {
|
|
221
|
+
#if defined(__CUDACC__) || defined(__HIPCC__)
|
|
222
|
+
return static_cast<c10::complex<T>>(
|
|
223
|
+
thrust::sinh(static_cast<thrust::complex<T>>(x)));
|
|
224
|
+
#else
|
|
225
|
+
return static_cast<c10::complex<T>>(
|
|
226
|
+
std::sinh(static_cast<std::complex<T>>(x)));
|
|
227
|
+
#endif
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
template <typename T>
|
|
231
|
+
C10_HOST_DEVICE inline c10::complex<T> cosh(const c10::complex<T> &x) {
|
|
232
|
+
#if defined(__CUDACC__) || defined(__HIPCC__)
|
|
233
|
+
return static_cast<c10::complex<T>>(
|
|
234
|
+
thrust::cosh(static_cast<thrust::complex<T>>(x)));
|
|
235
|
+
#else
|
|
236
|
+
return static_cast<c10::complex<T>>(
|
|
237
|
+
std::cosh(static_cast<std::complex<T>>(x)));
|
|
238
|
+
#endif
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
template <typename T>
|
|
242
|
+
C10_HOST_DEVICE inline c10::complex<T> tanh(const c10::complex<T> &x) {
|
|
243
|
+
#if defined(__CUDACC__) || defined(__HIPCC__)
|
|
244
|
+
return static_cast<c10::complex<T>>(
|
|
245
|
+
thrust::tanh(static_cast<thrust::complex<T>>(x)));
|
|
246
|
+
#else
|
|
247
|
+
return static_cast<c10::complex<T>>(
|
|
248
|
+
std::tanh(static_cast<std::complex<T>>(x)));
|
|
249
|
+
#endif
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
template <typename T>
|
|
253
|
+
C10_HOST_DEVICE inline c10::complex<T> asinh(const c10::complex<T> &x) {
|
|
254
|
+
#if defined(__CUDACC__) || defined(__HIPCC__)
|
|
255
|
+
return static_cast<c10::complex<T>>(
|
|
256
|
+
thrust::asinh(static_cast<thrust::complex<T>>(x)));
|
|
257
|
+
#else
|
|
258
|
+
return static_cast<c10::complex<T>>(
|
|
259
|
+
std::asinh(static_cast<std::complex<T>>(x)));
|
|
260
|
+
#endif
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
template <typename T>
|
|
264
|
+
C10_HOST_DEVICE inline c10::complex<T> acosh(const c10::complex<T> &x) {
|
|
265
|
+
#if defined(__CUDACC__) || defined(__HIPCC__)
|
|
266
|
+
return static_cast<c10::complex<T>>(
|
|
267
|
+
thrust::acosh(static_cast<thrust::complex<T>>(x)));
|
|
268
|
+
#else
|
|
269
|
+
return static_cast<c10::complex<T>>(
|
|
270
|
+
std::acosh(static_cast<std::complex<T>>(x)));
|
|
271
|
+
#endif
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
template <typename T>
|
|
275
|
+
C10_HOST_DEVICE inline c10::complex<T> atanh(const c10::complex<T> &x) {
|
|
276
|
+
#if defined(__CUDACC__) || defined(__HIPCC__)
|
|
277
|
+
return static_cast<c10::complex<T>>(
|
|
278
|
+
thrust::atanh(static_cast<thrust::complex<T>>(x)));
|
|
279
|
+
#else
|
|
280
|
+
return static_cast<c10::complex<T>>(
|
|
281
|
+
std::atanh(static_cast<std::complex<T>>(x)));
|
|
282
|
+
#endif
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
template <typename T>
|
|
286
|
+
C10_HOST_DEVICE inline c10::complex<T> log1p(const c10::complex<T> &z) {
|
|
287
|
+
#if defined(__APPLE__) || defined(__MACOSX) || defined(__CUDACC__) || \
|
|
288
|
+
defined(__HIPCC__)
|
|
289
|
+
// For Mac, the new implementation yielded a high relative error. Falling back
|
|
290
|
+
// to the old version for now.
|
|
291
|
+
// See https://github.com/numpy/numpy/pull/22611#issuecomment-1667945354
|
|
292
|
+
// For CUDA we also use this one, as thrust::log(thrust::complex) takes
|
|
293
|
+
// *forever* to compile
|
|
294
|
+
|
|
295
|
+
// log1p(z) = log(1 + z)
|
|
296
|
+
// Let's define 1 + z = r * e ^ (i * a), then we have
|
|
297
|
+
// log(r * e ^ (i * a)) = log(r) + i * a
|
|
298
|
+
// With z = x + iy, the term r can be written as
|
|
299
|
+
// r = ((1 + x) ^ 2 + y ^ 2) ^ 0.5
|
|
300
|
+
// = (1 + x ^ 2 + 2 * x + y ^ 2) ^ 0.5
|
|
301
|
+
// So, log(r) is
|
|
302
|
+
// log(r) = 0.5 * log(1 + x ^ 2 + 2 * x + y ^ 2)
|
|
303
|
+
// = 0.5 * log1p(x * (x + 2) + y ^ 2)
|
|
304
|
+
// we need to use the expression only on certain condition to avoid overflow
|
|
305
|
+
// and underflow from `(x * (x + 2) + y ^ 2)`
|
|
306
|
+
T x = z.real();
|
|
307
|
+
T y = z.imag();
|
|
308
|
+
T zabs = std::abs(z);
|
|
309
|
+
T theta = std::atan2(y, x + T(1));
|
|
310
|
+
if (zabs < 0.5) {
|
|
311
|
+
T r = x * (T(2) + x) + y * y;
|
|
312
|
+
if (r == 0) { // handle underflow
|
|
313
|
+
return {x, theta};
|
|
314
|
+
}
|
|
315
|
+
return {T(0.5) * std::log1p(r), theta};
|
|
316
|
+
} else {
|
|
317
|
+
T z0 = std::hypot(x + 1, y);
|
|
318
|
+
return {std::log(z0), theta};
|
|
319
|
+
}
|
|
320
|
+
#else
|
|
321
|
+
// CPU path
|
|
322
|
+
// Based on https://github.com/numpy/numpy/pull/22611#issuecomment-1667945354
|
|
323
|
+
c10::complex<T> u = z + T(1);
|
|
324
|
+
if (u == T(1)) {
|
|
325
|
+
return z;
|
|
326
|
+
} else {
|
|
327
|
+
auto log_u = log(u);
|
|
328
|
+
if (u - T(1) == z) {
|
|
329
|
+
return log_u;
|
|
330
|
+
}
|
|
331
|
+
return log_u * (z / (u - T(1)));
|
|
332
|
+
}
|
|
333
|
+
#endif
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
template <typename T>
|
|
337
|
+
C10_HOST_DEVICE inline c10::complex<T> expm1(const c10::complex<T> &z) {
|
|
338
|
+
// expm1(z) = exp(z) - 1
|
|
339
|
+
// Define z = x + i * y
|
|
340
|
+
// f = e ^ (x + i * y) - 1
|
|
341
|
+
// = e ^ x * e ^ (i * y) - 1
|
|
342
|
+
// = (e ^ x * cos(y) - 1) + i * (e ^ x * sin(y))
|
|
343
|
+
// = (e ^ x - 1) * cos(y) - (1 - cos(y)) + i * e ^ x * sin(y)
|
|
344
|
+
// = expm1(x) * cos(y) - 2 * sin(y / 2) ^ 2 + i * e ^ x * sin(y)
|
|
345
|
+
T x = z.real();
|
|
346
|
+
T y = z.imag();
|
|
347
|
+
T a = std::sin(y / 2);
|
|
348
|
+
T er = std::expm1(x) * std::cos(y) - T(2) * a * a;
|
|
349
|
+
T ei = std::exp(x) * std::sin(y);
|
|
350
|
+
return {er, ei};
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
} // namespace c10_complex_math
|
|
354
|
+
|
|
355
|
+
using c10_complex_math::acos;
|
|
356
|
+
using c10_complex_math::acosh;
|
|
357
|
+
using c10_complex_math::asin;
|
|
358
|
+
using c10_complex_math::asinh;
|
|
359
|
+
using c10_complex_math::atan;
|
|
360
|
+
using c10_complex_math::atanh;
|
|
361
|
+
using c10_complex_math::cos;
|
|
362
|
+
using c10_complex_math::cosh;
|
|
363
|
+
using c10_complex_math::exp;
|
|
364
|
+
using c10_complex_math::expm1;
|
|
365
|
+
using c10_complex_math::log;
|
|
366
|
+
using c10_complex_math::log10;
|
|
367
|
+
using c10_complex_math::log1p;
|
|
368
|
+
using c10_complex_math::log2;
|
|
369
|
+
using c10_complex_math::pow;
|
|
370
|
+
using c10_complex_math::sin;
|
|
371
|
+
using c10_complex_math::sinh;
|
|
372
|
+
using c10_complex_math::sqrt;
|
|
373
|
+
using c10_complex_math::tan;
|
|
374
|
+
using c10_complex_math::tanh;
|
|
375
|
+
|
|
376
|
+
namespace std {
|
|
377
|
+
|
|
378
|
+
using c10_complex_math::acos;
|
|
379
|
+
using c10_complex_math::acosh;
|
|
380
|
+
using c10_complex_math::asin;
|
|
381
|
+
using c10_complex_math::asinh;
|
|
382
|
+
using c10_complex_math::atan;
|
|
383
|
+
using c10_complex_math::atanh;
|
|
384
|
+
using c10_complex_math::cos;
|
|
385
|
+
using c10_complex_math::cosh;
|
|
386
|
+
using c10_complex_math::exp;
|
|
387
|
+
using c10_complex_math::expm1;
|
|
388
|
+
using c10_complex_math::log;
|
|
389
|
+
using c10_complex_math::log10;
|
|
390
|
+
using c10_complex_math::log1p;
|
|
391
|
+
using c10_complex_math::log2;
|
|
392
|
+
using c10_complex_math::pow;
|
|
393
|
+
using c10_complex_math::sin;
|
|
394
|
+
using c10_complex_math::sinh;
|
|
395
|
+
using c10_complex_math::sqrt;
|
|
396
|
+
using c10_complex_math::tan;
|
|
397
|
+
using c10_complex_math::tanh;
|
|
398
|
+
|
|
399
|
+
} // namespace std
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#if !defined(C10_INTERNAL_INCLUDE_COMPLEX_REMAINING_H)
|
|
2
|
+
#error \
|
|
3
|
+
"c10/util/complex_utils.h is not meant to be individually included. Include c10/util/complex.h instead."
|
|
4
|
+
#endif
|
|
5
|
+
|
|
6
|
+
#include <limits>
|
|
7
|
+
|
|
8
|
+
namespace c10 {
|
|
9
|
+
|
|
10
|
+
template <typename T> struct is_complex : public std::false_type {};
|
|
11
|
+
|
|
12
|
+
template <typename T>
|
|
13
|
+
struct is_complex<std::complex<T>> : public std::true_type {};
|
|
14
|
+
|
|
15
|
+
template <typename T>
|
|
16
|
+
struct is_complex<c10::complex<T>> : public std::true_type {};
|
|
17
|
+
|
|
18
|
+
// Extract double from std::complex<double>; is identity otherwise
|
|
19
|
+
// TODO: Write in more idiomatic C++17
|
|
20
|
+
template <typename T> struct scalar_value_type {
|
|
21
|
+
using type = T;
|
|
22
|
+
};
|
|
23
|
+
template <typename T> struct scalar_value_type<std::complex<T>> {
|
|
24
|
+
using type = T;
|
|
25
|
+
};
|
|
26
|
+
template <typename T> struct scalar_value_type<c10::complex<T>> {
|
|
27
|
+
using type = T;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
} // namespace c10
|
|
31
|
+
|
|
32
|
+
namespace std {
|
|
33
|
+
|
|
34
|
+
template <typename T>
|
|
35
|
+
class numeric_limits<c10::complex<T>> : public numeric_limits<T> {};
|
|
36
|
+
|
|
37
|
+
template <typename T> bool isnan(const c10::complex<T> &v) {
|
|
38
|
+
return std::isnan(v.real()) || std::isnan(v.imag());
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
} // namespace std
|
|
@@ -22,7 +22,7 @@ struct integer_iterator {
|
|
|
22
22
|
using pointer = I *;
|
|
23
23
|
using reference = I &;
|
|
24
24
|
|
|
25
|
-
explicit constexpr integer_iterator(I
|
|
25
|
+
explicit constexpr integer_iterator(I value) : value(value) {}
|
|
26
26
|
|
|
27
27
|
constexpr I operator*() const { return value; }
|
|
28
28
|
|
|
@@ -89,7 +89,7 @@ private:
|
|
|
89
89
|
template <typename Integer1, typename Integer2,
|
|
90
90
|
std::enable_if_t<std::is_integral_v<Integer1>, bool> = true,
|
|
91
91
|
std::enable_if_t<std::is_integral_v<Integer2>, bool> = true>
|
|
92
|
-
integer_range<Integer2> irange(Integer1 begin, Integer2 end) {
|
|
92
|
+
constexpr integer_range<Integer2> irange(Integer1 begin, Integer2 end) {
|
|
93
93
|
// If end<=begin then the range is empty; we can achieve this effect by
|
|
94
94
|
// choosing the larger of {begin, end} as the loop terminator
|
|
95
95
|
return {static_cast<Integer2>(begin),
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <c10/macros/Macros.h>
|
|
4
|
+
#include <c10/util/TypeSafeSignMath.h>
|
|
5
|
+
#include <c10/util/complex.h>
|
|
6
|
+
|
|
7
|
+
#include <cmath>
|
|
8
|
+
#include <limits>
|
|
9
|
+
#include <type_traits>
|
|
10
|
+
|
|
11
|
+
namespace c10 {
|
|
12
|
+
// In some versions of MSVC, there will be a compiler error when building.
|
|
13
|
+
// C4146: unary minus operator applied to unsigned type, result still unsigned
|
|
14
|
+
// C4804: unsafe use of type 'bool' in operation
|
|
15
|
+
// It can be addressed by disabling the following warning.
|
|
16
|
+
#ifdef _MSC_VER
|
|
17
|
+
#pragma warning(push)
|
|
18
|
+
#pragma warning(disable : 4146)
|
|
19
|
+
#pragma warning(disable : 4804)
|
|
20
|
+
#pragma warning(disable : 4018)
|
|
21
|
+
#endif
|
|
22
|
+
|
|
23
|
+
// The overflow checks may involve float to int conversion which may
|
|
24
|
+
// trigger precision loss warning. Re-enable the warning once the code
|
|
25
|
+
// is fixed. See T58053069.
|
|
26
|
+
C10_CLANG_DIAGNOSTIC_PUSH()
|
|
27
|
+
#if C10_CLANG_HAS_WARNING("-Wimplicit-float-conversion")
|
|
28
|
+
C10_CLANG_DIAGNOSTIC_IGNORE("-Wimplicit-float-conversion")
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
// bool can be converted to any type.
|
|
32
|
+
// Without specializing on bool, in pytorch_linux_trusty_py2_7_9_build:
|
|
33
|
+
// `error: comparison of constant '255' with boolean expression is always false`
|
|
34
|
+
// for `f > limit::max()` below
|
|
35
|
+
template <typename To, typename From>
|
|
36
|
+
std::enable_if_t<std::is_same_v<From, bool>, bool>
|
|
37
|
+
overflows(From /*f*/, bool strict_unsigned [[maybe_unused]] = false) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// skip isnan and isinf check for integral types
|
|
42
|
+
template <typename To, typename From>
|
|
43
|
+
std::enable_if_t<std::is_integral_v<From> && !std::is_same_v<From, bool>, bool>
|
|
44
|
+
overflows(From f, bool strict_unsigned = false) {
|
|
45
|
+
using limit = std::numeric_limits<typename scalar_value_type<To>::type>;
|
|
46
|
+
if constexpr (!limit::is_signed && std::numeric_limits<From>::is_signed) {
|
|
47
|
+
// allow for negative numbers to wrap using two's complement arithmetic.
|
|
48
|
+
// For example, with uint8, this allows for `a - b` to be treated as
|
|
49
|
+
// `a + 255 * b`.
|
|
50
|
+
if (!strict_unsigned) {
|
|
51
|
+
return greater_than_max<To>(f) ||
|
|
52
|
+
(c10::is_negative(f) &&
|
|
53
|
+
-static_cast<uint64_t>(f) > static_cast<uint64_t>(limit::max()));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return c10::less_than_lowest<To>(f) || greater_than_max<To>(f);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
template <typename To, typename From>
|
|
60
|
+
std::enable_if_t<std::is_floating_point_v<From>, bool>
|
|
61
|
+
overflows(From f, bool strict_unsigned [[maybe_unused]] = false) {
|
|
62
|
+
using limit = std::numeric_limits<typename scalar_value_type<To>::type>;
|
|
63
|
+
if (limit::has_infinity && std::isinf(static_cast<double>(f))) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
if (!limit::has_quiet_NaN && (f != f)) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return f < limit::lowest() || f > limit::max();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
C10_CLANG_DIAGNOSTIC_POP()
|
|
73
|
+
|
|
74
|
+
#ifdef _MSC_VER
|
|
75
|
+
#pragma warning(pop)
|
|
76
|
+
#endif
|
|
77
|
+
|
|
78
|
+
template <typename To, typename From>
|
|
79
|
+
std::enable_if_t<is_complex<From>::value, bool>
|
|
80
|
+
overflows(From f, bool strict_unsigned = false) {
|
|
81
|
+
// casts from complex to real are considered to overflow if the
|
|
82
|
+
// imaginary component is non-zero
|
|
83
|
+
if (!is_complex<To>::value && f.imag() != 0) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
// Check for overflow componentwise
|
|
87
|
+
// (Technically, the imag overflow check is guaranteed to be false
|
|
88
|
+
// when !is_complex<To>, but any optimizer worth its salt will be
|
|
89
|
+
// able to figure it out.)
|
|
90
|
+
return overflows<typename scalar_value_type<To>::type,
|
|
91
|
+
typename From::value_type>(f.real(), strict_unsigned) ||
|
|
92
|
+
overflows<typename scalar_value_type<To>::type,
|
|
93
|
+
typename From::value_type>(f.imag(), strict_unsigned);
|
|
94
|
+
}
|
|
95
|
+
} // namespace c10
|
|
@@ -13,4 +13,79 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
13
13
|
FOUNDATION_EXPORT NSErrorDomain const
|
|
14
14
|
ExecuTorchErrorDomain NS_SWIFT_NAME(ErrorDomain);
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Enum to define the error codes.
|
|
18
|
+
* Values can be a subset, but must numerically match exactly those defined in
|
|
19
|
+
* runtime/core/error.h
|
|
20
|
+
*/
|
|
21
|
+
typedef NS_ERROR_ENUM(ExecuTorchErrorDomain, ExecuTorchErrorCode){
|
|
22
|
+
// System errors.
|
|
23
|
+
ExecuTorchErrorCodeOk = 0,
|
|
24
|
+
ExecuTorchErrorCodeInternal = 1,
|
|
25
|
+
ExecuTorchErrorCodeInvalidState = 2,
|
|
26
|
+
ExecuTorchErrorCodeEndOfMethod = 3,
|
|
27
|
+
|
|
28
|
+
// Logical errors.
|
|
29
|
+
ExecuTorchErrorCodeNotSupported = 16,
|
|
30
|
+
ExecuTorchErrorCodeNotImplemented = 17,
|
|
31
|
+
ExecuTorchErrorCodeInvalidArgument = 18,
|
|
32
|
+
ExecuTorchErrorCodeInvalidType = 19,
|
|
33
|
+
ExecuTorchErrorCodeOperatorMissing = 20,
|
|
34
|
+
|
|
35
|
+
// Registration errors.
|
|
36
|
+
ExecuTorchErrorCodeRegistrationExceedingMaxKernels = 21,
|
|
37
|
+
ExecuTorchErrorCodeRegistrationAlreadyRegistered = 22,
|
|
38
|
+
|
|
39
|
+
// Resource errors.
|
|
40
|
+
ExecuTorchErrorCodeNotFound = 32,
|
|
41
|
+
ExecuTorchErrorCodeMemoryAllocationFailed = 33,
|
|
42
|
+
ExecuTorchErrorCodeAccessFailed = 34,
|
|
43
|
+
ExecuTorchErrorCodeInvalidProgram = 35,
|
|
44
|
+
ExecuTorchErrorCodeInvalidExternalData = 36,
|
|
45
|
+
ExecuTorchErrorCodeOutOfResources = 37,
|
|
46
|
+
|
|
47
|
+
// Delegate errors.
|
|
48
|
+
ExecuTorchErrorCodeDelegateInvalidCompatibility = 48,
|
|
49
|
+
ExecuTorchErrorCodeDelegateMemoryAllocationFailed = 49,
|
|
50
|
+
ExecuTorchErrorCodeDelegateInvalidHandle = 50,
|
|
51
|
+
} NS_SWIFT_NAME(ErrorCode);
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Returns a brief error description for the given error code.
|
|
55
|
+
*
|
|
56
|
+
* @param code An ExecuTorchErrorCode value representing the error code.
|
|
57
|
+
* @return An NSString containing the error description.
|
|
58
|
+
*/
|
|
59
|
+
FOUNDATION_EXPORT
|
|
60
|
+
__attribute__((deprecated("This API is experimental."))) NSString *
|
|
61
|
+
ExecuTorchErrorDescription(ExecuTorchErrorCode code)
|
|
62
|
+
NS_SWIFT_NAME(ErrorDescription(_:));
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Create an NSError in the ExecuTorch domain for the given code.
|
|
66
|
+
*
|
|
67
|
+
* @param code The ExecuTorchErrorCode to wrap.
|
|
68
|
+
* @return An NSError with ExecuTorchErrorDomain, the specified code, and a
|
|
69
|
+
* localized description.
|
|
70
|
+
*/
|
|
71
|
+
FOUNDATION_EXPORT
|
|
72
|
+
NS_RETURNS_RETAINED
|
|
73
|
+
__attribute__((deprecated("This API is experimental."))) NSError *
|
|
74
|
+
ExecuTorchErrorWithCode(ExecuTorchErrorCode code) NS_SWIFT_NAME(Error(code:));
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Create an NSError in the ExecuTorch domain for the given code.
|
|
78
|
+
*
|
|
79
|
+
* @param code The ExecuTorchErrorCode to wrap.
|
|
80
|
+
* @param description Additional error description.
|
|
81
|
+
* @return An NSError with ExecuTorchErrorDomain, the specified code, and a
|
|
82
|
+
* localized description.
|
|
83
|
+
*/
|
|
84
|
+
FOUNDATION_EXPORT
|
|
85
|
+
NS_RETURNS_RETAINED
|
|
86
|
+
__attribute__((deprecated("This API is experimental."))) NSError *
|
|
87
|
+
ExecuTorchErrorWithCodeAndDescription(ExecuTorchErrorCode code,
|
|
88
|
+
NSString *__nullable description)
|
|
89
|
+
NS_SWIFT_NAME(Error(code:description:));
|
|
90
|
+
|
|
16
91
|
NS_ASSUME_NONNULL_END
|