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
|
@@ -247,6 +247,26 @@ ssize_t compute_numel(
|
|
|
247
247
|
const ::executorch::runtime::etensor::TensorImpl::SizesType *sizes,
|
|
248
248
|
ssize_t dim);
|
|
249
249
|
|
|
250
|
+
/// Appropriate format specifier for the result of calling
|
|
251
|
+
/// size(). Must be used instead of using zd directly to support ATen
|
|
252
|
+
/// mode.
|
|
253
|
+
#define ET_PRI_TENSOR_SIZE "zd"
|
|
254
|
+
|
|
255
|
+
/// Appropriate format specifier for the result of calling
|
|
256
|
+
/// dim(). Must be used instead of using zd directly to support ATen
|
|
257
|
+
/// mode.
|
|
258
|
+
#define ET_PRI_TENSOR_DIM "zd"
|
|
259
|
+
|
|
260
|
+
/// Appropriate format specifier for the result of calling
|
|
261
|
+
/// numel(). Must be used instead of using zd directly to support ATen
|
|
262
|
+
/// mode.
|
|
263
|
+
#define ET_PRI_TENSOR_NUMEL "zd"
|
|
264
|
+
|
|
265
|
+
// Appropriate format specifier for elements of sizes() and
|
|
266
|
+
// strides(). Must be used instead of using d directly to support ATen
|
|
267
|
+
// mode.
|
|
268
|
+
#define ET_PRI_SIZES_AND_STRIDES "d"
|
|
269
|
+
|
|
250
270
|
} // namespace etensor
|
|
251
271
|
} // namespace runtime
|
|
252
272
|
} // namespace executorch
|
|
@@ -54,6 +54,10 @@ public:
|
|
|
54
54
|
template <size_t N>
|
|
55
55
|
/* implicit */ constexpr Span(T (&Arr)[N]) : data_(Arr), length_(N) {}
|
|
56
56
|
|
|
57
|
+
/// Construct a Span from a single element reference.
|
|
58
|
+
/* implicit */ constexpr Span(T &single_element)
|
|
59
|
+
: data_(&single_element), length_(1) {}
|
|
60
|
+
|
|
57
61
|
/// @returns a pointer to the start of the underlying element buffer.
|
|
58
62
|
iterator begin() const noexcept { return data_; }
|
|
59
63
|
|
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
#include <executorch/runtime/core/defines.h>
|
|
13
13
|
#include <executorch/runtime/platform/compiler.h>
|
|
14
14
|
|
|
15
|
+
// X11 headers via volk define None, so we need to undef it
|
|
16
|
+
#if defined(__linux__)
|
|
17
|
+
#undef None
|
|
18
|
+
#endif
|
|
19
|
+
|
|
15
20
|
namespace executorch {
|
|
16
21
|
namespace runtime {
|
|
17
22
|
|
|
@@ -38,6 +43,20 @@ enum class Tag : uint32_t {
|
|
|
38
43
|
#undef DEFINE_TAG
|
|
39
44
|
};
|
|
40
45
|
|
|
46
|
+
#if ET_ENABLE_ENUM_STRINGS
|
|
47
|
+
inline const char *tag_to_string(Tag tag) {
|
|
48
|
+
switch (tag) {
|
|
49
|
+
#define CASE_TAG(x) \
|
|
50
|
+
case Tag::x: \
|
|
51
|
+
return #x;
|
|
52
|
+
EXECUTORCH_FORALL_TAGS(CASE_TAG)
|
|
53
|
+
#undef CASE_TAG
|
|
54
|
+
default:
|
|
55
|
+
return "Unknown";
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
#endif // ET_ENABLE_ENUM_STRINGS
|
|
59
|
+
|
|
41
60
|
/**
|
|
42
61
|
* Convert a tag value to a string representation. If ET_ENABLE_ENUM_STRINGS is
|
|
43
62
|
* set (it is on by default), this will return a string name (for example,
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
#include <executorch/runtime/core/span.h>
|
|
15
15
|
|
|
16
16
|
namespace executorch {
|
|
17
|
-
namespace
|
|
17
|
+
namespace ET_RUNTIME_NAMESPACE {
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Describes the layout of a tensor.
|
|
@@ -75,5 +75,5 @@ private:
|
|
|
75
75
|
const size_t nbytes_;
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
-
} // namespace
|
|
78
|
+
} // namespace ET_RUNTIME_NAMESPACE
|
|
79
79
|
} // namespace executorch
|
|
@@ -32,7 +32,7 @@ struct EValue;
|
|
|
32
32
|
} // namespace executorch_flatbuffer
|
|
33
33
|
|
|
34
34
|
namespace executorch {
|
|
35
|
-
namespace
|
|
35
|
+
namespace ET_RUNTIME_NAMESPACE {
|
|
36
36
|
|
|
37
37
|
// Forward declare NamedData. This is a public header and must not include
|
|
38
38
|
// internal data types.
|
|
@@ -187,6 +187,18 @@ public:
|
|
|
187
187
|
*/
|
|
188
188
|
ET_NODISCARD Error get_inputs(EValue *input_evalues, size_t length);
|
|
189
189
|
|
|
190
|
+
/**
|
|
191
|
+
*
|
|
192
|
+
* Retrieves the attribute tensor associated with the given name.
|
|
193
|
+
*
|
|
194
|
+
* @param[in] name The name of the attribute tensor to retrieve.
|
|
195
|
+
*
|
|
196
|
+
* @returns Result containing the attribute tensor on success, non-Ok on
|
|
197
|
+
* failure.
|
|
198
|
+
*/
|
|
199
|
+
ET_NODISCARD Result<executorch::aten::Tensor>
|
|
200
|
+
get_attribute(std::string_view name);
|
|
201
|
+
|
|
190
202
|
/**
|
|
191
203
|
* Execute the method.
|
|
192
204
|
*
|
|
@@ -371,14 +383,14 @@ private:
|
|
|
371
383
|
void log_outputs();
|
|
372
384
|
};
|
|
373
385
|
|
|
374
|
-
} // namespace
|
|
386
|
+
} // namespace ET_RUNTIME_NAMESPACE
|
|
375
387
|
} // namespace executorch
|
|
376
388
|
|
|
377
389
|
namespace torch {
|
|
378
390
|
namespace executor {
|
|
379
391
|
// TODO(T197294990): Remove these deprecated aliases once all users have moved
|
|
380
392
|
// to the new `::executorch` namespaces.
|
|
381
|
-
using ::executorch::
|
|
393
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::Method;
|
|
382
394
|
} // namespace executor
|
|
383
395
|
} // namespace torch
|
|
384
396
|
|
|
@@ -20,7 +20,11 @@ struct ExecutionPlan;
|
|
|
20
20
|
} // namespace executorch_flatbuffer
|
|
21
21
|
|
|
22
22
|
namespace executorch {
|
|
23
|
-
namespace
|
|
23
|
+
namespace ET_RUNTIME_NAMESPACE {
|
|
24
|
+
namespace testing {
|
|
25
|
+
// Provides test access to private Program methods.
|
|
26
|
+
class TensorInfoTestFriend;
|
|
27
|
+
} // namespace testing
|
|
24
28
|
|
|
25
29
|
/**
|
|
26
30
|
* Metadata about a specific tensor of an ExecuTorch Program.
|
|
@@ -62,13 +66,20 @@ public:
|
|
|
62
66
|
*/
|
|
63
67
|
size_t nbytes() const;
|
|
64
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Returns the fully qualified name of the Tensor might be empty if the tensor
|
|
71
|
+
* is nameless.
|
|
72
|
+
*/
|
|
73
|
+
std::string_view name() const;
|
|
74
|
+
|
|
65
75
|
private:
|
|
66
76
|
// Let MethodMeta create TensorInfo.
|
|
67
77
|
friend class MethodMeta;
|
|
78
|
+
friend class testing::TensorInfoTestFriend;
|
|
68
79
|
|
|
69
80
|
TensorInfo(Span<const int32_t> sizes, Span<const uint8_t> dim_order,
|
|
70
81
|
executorch::aten::ScalarType scalar_type,
|
|
71
|
-
const bool is_memory_planned);
|
|
82
|
+
const bool is_memory_planned, std::string_view name);
|
|
72
83
|
|
|
73
84
|
/**
|
|
74
85
|
* The sizes of the tensor.
|
|
@@ -86,6 +97,9 @@ private:
|
|
|
86
97
|
*/
|
|
87
98
|
Span<const uint8_t> dim_order_;
|
|
88
99
|
|
|
100
|
+
/// The fully qualified name of the Tensor.
|
|
101
|
+
std::string_view name_;
|
|
102
|
+
|
|
89
103
|
/// The scalar type of the tensor.
|
|
90
104
|
executorch::aten::ScalarType scalar_type_;
|
|
91
105
|
|
|
@@ -168,6 +182,21 @@ public:
|
|
|
168
182
|
*/
|
|
169
183
|
Result<TensorInfo> output_tensor_meta(size_t index) const;
|
|
170
184
|
|
|
185
|
+
/**
|
|
186
|
+
* Get the number of attribute tensors in this method.
|
|
187
|
+
*
|
|
188
|
+
* @returns The number of attribute tensors.
|
|
189
|
+
*/
|
|
190
|
+
size_t num_attributes() const;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Get metadata about the specified attribute tensor.
|
|
194
|
+
*
|
|
195
|
+
* @param[in] index The index of the attribute tensor to look up.
|
|
196
|
+
* @returns The metadata on success, or an error on failure.
|
|
197
|
+
*/
|
|
198
|
+
Result<TensorInfo> attribute_tensor_meta(size_t index) const;
|
|
199
|
+
|
|
171
200
|
/**
|
|
172
201
|
* Get the number of memory-planned buffers this method requires.
|
|
173
202
|
*
|
|
@@ -238,14 +267,14 @@ private:
|
|
|
238
267
|
const executorch_flatbuffer::ExecutionPlan *s_plan_;
|
|
239
268
|
};
|
|
240
269
|
|
|
241
|
-
} // namespace
|
|
270
|
+
} // namespace ET_RUNTIME_NAMESPACE
|
|
242
271
|
} // namespace executorch
|
|
243
272
|
|
|
244
273
|
namespace torch {
|
|
245
274
|
namespace executor {
|
|
246
275
|
// TODO(T197294990): Remove these deprecated aliases once all users have moved
|
|
247
276
|
// to the new `::executorch` namespaces.
|
|
248
|
-
using ::executorch::
|
|
249
|
-
using ::executorch::
|
|
277
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::MethodMeta;
|
|
278
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::TensorInfo;
|
|
250
279
|
} // namespace executor
|
|
251
280
|
} // namespace torch
|
|
@@ -36,8 +36,7 @@ struct Program;
|
|
|
36
36
|
} // namespace executorch_flatbuffer
|
|
37
37
|
|
|
38
38
|
namespace executorch {
|
|
39
|
-
namespace
|
|
40
|
-
|
|
39
|
+
namespace ET_RUNTIME_NAMESPACE {
|
|
41
40
|
namespace testing {
|
|
42
41
|
// Provides test access to private Program methods.
|
|
43
42
|
class ProgramTestFriend;
|
|
@@ -304,14 +303,14 @@ private:
|
|
|
304
303
|
std::optional<internal::PteDataMap> pte_data_map_;
|
|
305
304
|
};
|
|
306
305
|
|
|
307
|
-
} // namespace
|
|
306
|
+
} // namespace ET_RUNTIME_NAMESPACE
|
|
308
307
|
} // namespace executorch
|
|
309
308
|
|
|
310
309
|
namespace torch {
|
|
311
310
|
namespace executor {
|
|
312
311
|
// TODO(T197294990): Remove these deprecated aliases once all users have moved
|
|
313
312
|
// to the new `::executorch` namespaces.
|
|
314
|
-
using ::executorch::
|
|
313
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::Program;
|
|
315
314
|
} // namespace executor
|
|
316
315
|
} // namespace torch
|
|
317
316
|
|
|
@@ -45,7 +45,7 @@ using FlatbufferDataSegment =
|
|
|
45
45
|
#endif
|
|
46
46
|
|
|
47
47
|
namespace executorch {
|
|
48
|
-
namespace
|
|
48
|
+
namespace ET_RUNTIME_NAMESPACE {
|
|
49
49
|
namespace internal {
|
|
50
50
|
|
|
51
51
|
/**
|
|
@@ -76,8 +76,8 @@ public:
|
|
|
76
76
|
* tensor-specific metadata.
|
|
77
77
|
*/
|
|
78
78
|
ET_NODISCARD
|
|
79
|
-
Result<const TensorLayout>
|
|
80
|
-
|
|
79
|
+
Result<const TensorLayout> get_tensor_layout(
|
|
80
|
+
ET_UNUSED executorch::aten::string_view key) const override {
|
|
81
81
|
return Error::NotImplemented;
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -89,12 +89,13 @@ public:
|
|
|
89
89
|
* @return error if the key is not present or data cannot be loaded.
|
|
90
90
|
*/
|
|
91
91
|
ET_NODISCARD
|
|
92
|
-
Result<FreeableBuffer>
|
|
92
|
+
Result<FreeableBuffer>
|
|
93
|
+
get_data(executorch::aten::string_view key) const override;
|
|
93
94
|
|
|
94
95
|
/**
|
|
95
96
|
* The PteDataMap currently does not implement load_into.
|
|
96
97
|
*/
|
|
97
|
-
ET_NODISCARD Error load_data_into(ET_UNUSED
|
|
98
|
+
ET_NODISCARD Error load_data_into(ET_UNUSED executorch::aten::string_view key,
|
|
98
99
|
ET_UNUSED void *buffer,
|
|
99
100
|
ET_UNUSED size_t size) const override {
|
|
100
101
|
return Error::NotImplemented;
|
|
@@ -103,12 +104,12 @@ public:
|
|
|
103
104
|
/**
|
|
104
105
|
* @returns The number of keys in the map.
|
|
105
106
|
*/
|
|
106
|
-
ET_NODISCARD Result<
|
|
107
|
+
ET_NODISCARD Result<uint32_t> get_num_keys() const override;
|
|
107
108
|
|
|
108
109
|
/**
|
|
109
110
|
* @returns The key at the specified index, error if index out of bounds.
|
|
110
111
|
*/
|
|
111
|
-
ET_NODISCARD Result<const char *> get_key(
|
|
112
|
+
ET_NODISCARD Result<const char *> get_key(uint32_t index) const override;
|
|
112
113
|
|
|
113
114
|
// Moveable, to be compatible with Result.
|
|
114
115
|
PteDataMap(PteDataMap &&) noexcept = default;
|
|
@@ -140,5 +141,5 @@ private:
|
|
|
140
141
|
};
|
|
141
142
|
|
|
142
143
|
} // namespace internal
|
|
143
|
-
} // namespace
|
|
144
|
+
} // namespace ET_RUNTIME_NAMESPACE
|
|
144
145
|
} // namespace executorch
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
#include <executorch/schema/program_generated.h>
|
|
22
22
|
|
|
23
23
|
namespace executorch {
|
|
24
|
-
namespace
|
|
24
|
+
namespace ET_RUNTIME_NAMESPACE {
|
|
25
25
|
namespace deserialization {
|
|
26
26
|
|
|
27
27
|
/// Data structure to hold key and data buffer for external data used
|
|
@@ -54,7 +54,7 @@ validateTensorLayout(const executorch_flatbuffer::Tensor *s_tensor,
|
|
|
54
54
|
// list of optionals: list of optional Tensor, list of optional float etc, so we
|
|
55
55
|
// just use a template to avoid boilerplate.
|
|
56
56
|
template <typename T>
|
|
57
|
-
ET_NODISCARD Result<BoxedEvalueList<
|
|
57
|
+
ET_NODISCARD Result<BoxedEvalueList<std::optional<T>>>
|
|
58
58
|
parseListOptionalType(const flatbuffers::Vector<int32_t> *value_indices,
|
|
59
59
|
EValue *values, size_t values_len,
|
|
60
60
|
MemoryManager *memory_manager) {
|
|
@@ -65,8 +65,8 @@ parseListOptionalType(const flatbuffers::Vector<int32_t> *value_indices,
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
auto *optional_tensor_list =
|
|
68
|
-
memory_manager->method_allocator()
|
|
69
|
-
|
|
68
|
+
memory_manager->method_allocator()->allocateList<std::optional<T>>(
|
|
69
|
+
value_indices->size());
|
|
70
70
|
if (optional_tensor_list == nullptr) {
|
|
71
71
|
return Error::MemoryAllocationFailed;
|
|
72
72
|
}
|
|
@@ -83,7 +83,7 @@ parseListOptionalType(const flatbuffers::Vector<int32_t> *value_indices,
|
|
|
83
83
|
// copy assignment is not defined if its non trivial.
|
|
84
84
|
if (index == -1) {
|
|
85
85
|
new (&optional_tensor_list[output_idx])
|
|
86
|
-
|
|
86
|
+
std::optional<T>(executorch::aten::nullopt);
|
|
87
87
|
// no value to point to. BoxedEvalueList for optional tensor will convert
|
|
88
88
|
// this to nullopt.
|
|
89
89
|
// TODO(T161156879): do something less hacky here.
|
|
@@ -93,13 +93,13 @@ parseListOptionalType(const flatbuffers::Vector<int32_t> *value_indices,
|
|
|
93
93
|
index >= 0 && static_cast<size_t>(index) < values_len, InvalidProgram,
|
|
94
94
|
"Invalid value index %" PRId32 " for ListOptional", index);
|
|
95
95
|
new (&optional_tensor_list[output_idx])
|
|
96
|
-
|
|
96
|
+
std::optional<T>(values[index].toOptional<T>());
|
|
97
97
|
evalp_list[output_idx] = &values[static_cast<size_t>(index)];
|
|
98
98
|
}
|
|
99
99
|
output_idx++;
|
|
100
100
|
}
|
|
101
|
-
return BoxedEvalueList<
|
|
102
|
-
|
|
101
|
+
return BoxedEvalueList<std::optional<T>>(evalp_list, optional_tensor_list,
|
|
102
|
+
value_indices->size());
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
/**
|
|
@@ -135,7 +135,7 @@ getTensorDataPtr(const executorch_flatbuffer::Tensor *s_tensor,
|
|
|
135
135
|
Span<NamedData> external_constants = {});
|
|
136
136
|
|
|
137
137
|
} // namespace deserialization
|
|
138
|
-
} // namespace
|
|
138
|
+
} // namespace ET_RUNTIME_NAMESPACE
|
|
139
139
|
} // namespace executorch
|
|
140
140
|
|
|
141
141
|
namespace torch {
|
|
@@ -143,10 +143,11 @@ namespace executor {
|
|
|
143
143
|
namespace deserialization {
|
|
144
144
|
// TODO(T197294990): Remove these deprecated aliases once all users have moved
|
|
145
145
|
// to the new `::executorch` namespaces.
|
|
146
|
-
using ::executorch::
|
|
147
|
-
using ::executorch::
|
|
148
|
-
|
|
149
|
-
using ::executorch::
|
|
146
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::deserialization::getTensorDataPtr;
|
|
147
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::deserialization::
|
|
148
|
+
parseListOptionalType;
|
|
149
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::deserialization::parseTensor;
|
|
150
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::deserialization::parseTensorList;
|
|
150
151
|
} // namespace deserialization
|
|
151
152
|
} // namespace executor
|
|
152
153
|
} // namespace torch
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
#include <executorch/runtime/platform/compiler.h>
|
|
16
16
|
|
|
17
17
|
namespace executorch {
|
|
18
|
-
namespace
|
|
18
|
+
namespace ET_RUNTIME_NAMESPACE {
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Runtime state and functionality for kernel implementations.
|
|
@@ -98,7 +98,7 @@ private:
|
|
|
98
98
|
Error failure_state_ = Error::Ok;
|
|
99
99
|
};
|
|
100
100
|
|
|
101
|
-
} // namespace
|
|
101
|
+
} // namespace ET_RUNTIME_NAMESPACE
|
|
102
102
|
} // namespace executorch
|
|
103
103
|
|
|
104
104
|
// TODO(T197294990): Remove these deprecated aliases once all users have moved
|
|
@@ -106,15 +106,15 @@ private:
|
|
|
106
106
|
namespace torch {
|
|
107
107
|
namespace executor {
|
|
108
108
|
/// DEPRECATED: Use ::executorch::runtime::KernelRuntimeContext instead.
|
|
109
|
-
using ::executorch::
|
|
109
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::KernelRuntimeContext;
|
|
110
110
|
/// DEPRECATED: Use ::executorch::runtime::KernelRuntimeContext instead.
|
|
111
|
-
using RuntimeContext = ::executorch::
|
|
111
|
+
using RuntimeContext = ::executorch::ET_RUNTIME_NAMESPACE::KernelRuntimeContext;
|
|
112
112
|
} // namespace executor
|
|
113
113
|
} // namespace torch
|
|
114
114
|
namespace executorch {
|
|
115
115
|
namespace aten {
|
|
116
116
|
/// DEPRECATED: Use ::executorch::runtime::KernelRuntimeContext instead.
|
|
117
|
-
using RuntimeContext = ::executorch::
|
|
117
|
+
using RuntimeContext = ::executorch::ET_RUNTIME_NAMESPACE::KernelRuntimeContext;
|
|
118
118
|
} // namespace aten
|
|
119
119
|
} // namespace executorch
|
|
120
120
|
// DEPRECATED: The executorch::aten:: namespace is deprecated. Use
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
namespace executorch {
|
|
40
|
-
namespace
|
|
40
|
+
namespace ET_RUNTIME_NAMESPACE {
|
|
41
41
|
|
|
42
42
|
class KernelRuntimeContext; // Forward declaration
|
|
43
43
|
using OpFunction = void (*)(KernelRuntimeContext &, EValue **);
|
|
@@ -117,7 +117,7 @@ public:
|
|
|
117
117
|
* for all input tensor dtypes and dim orders if the specialized kernel is not
|
|
118
118
|
* registered.
|
|
119
119
|
*/
|
|
120
|
-
KernelKey()
|
|
120
|
+
KernelKey() = default;
|
|
121
121
|
|
|
122
122
|
/**
|
|
123
123
|
* Creates a specialized (non-fallback) kernel key that matches a specific
|
|
@@ -125,23 +125,23 @@ public:
|
|
|
125
125
|
* expected format of `kernel_key_data`.
|
|
126
126
|
*/
|
|
127
127
|
/* implicit */ KernelKey(const char *kernel_key_data)
|
|
128
|
-
: kernel_key_data_(kernel_key_data)
|
|
128
|
+
: kernel_key_data_(kernel_key_data) {}
|
|
129
129
|
|
|
130
130
|
bool operator==(const KernelKey &other) const { return this->equals(other); }
|
|
131
131
|
|
|
132
132
|
bool operator!=(const KernelKey &other) const { return !this->equals(other); }
|
|
133
133
|
|
|
134
134
|
bool equals(const KernelKey &other) const {
|
|
135
|
-
if (
|
|
135
|
+
if (is_fallback() != other.is_fallback()) {
|
|
136
136
|
return false;
|
|
137
137
|
}
|
|
138
|
-
if (
|
|
138
|
+
if (is_fallback()) {
|
|
139
139
|
return true;
|
|
140
140
|
}
|
|
141
141
|
return strcmp(kernel_key_data_, other.kernel_key_data_) == 0;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
bool is_fallback() const { return
|
|
144
|
+
bool is_fallback() const { return kernel_key_data_ == nullptr; }
|
|
145
145
|
|
|
146
146
|
const char *data() const { return kernel_key_data_; }
|
|
147
147
|
|
|
@@ -154,7 +154,6 @@ public:
|
|
|
154
154
|
|
|
155
155
|
private:
|
|
156
156
|
const char *kernel_key_data_ = nullptr;
|
|
157
|
-
bool is_fallback_;
|
|
158
157
|
};
|
|
159
158
|
|
|
160
159
|
/**
|
|
@@ -241,37 +240,40 @@ ET_NODISCARD inline Error register_kernel(const Kernel &kernel) {
|
|
|
241
240
|
return register_kernels({&kernel, 1});
|
|
242
241
|
};
|
|
243
242
|
|
|
244
|
-
} // namespace
|
|
243
|
+
} // namespace ET_RUNTIME_NAMESPACE
|
|
245
244
|
} // namespace executorch
|
|
246
245
|
|
|
247
246
|
namespace torch {
|
|
248
247
|
namespace executor {
|
|
249
248
|
// TODO(T197294990): Remove these deprecated aliases once all users have moved
|
|
250
249
|
// to the new `::executorch` namespaces.
|
|
251
|
-
using ::executorch::
|
|
252
|
-
using ::executorch::
|
|
253
|
-
using ::executorch::
|
|
254
|
-
using ::executorch::
|
|
255
|
-
using ::executorch::
|
|
256
|
-
using KernelRuntimeContext =
|
|
250
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::Kernel;
|
|
251
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::KernelKey;
|
|
252
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::KernelRuntimeContext;
|
|
253
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::OpFunction;
|
|
254
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::TensorMeta;
|
|
255
|
+
using KernelRuntimeContext =
|
|
256
|
+
::executorch::ET_RUNTIME_NAMESPACE::KernelRuntimeContext;
|
|
257
257
|
|
|
258
258
|
inline ::executorch::runtime::Error register_kernels(ArrayRef<Kernel> kernels) {
|
|
259
|
-
return ::executorch::
|
|
259
|
+
return ::executorch::ET_RUNTIME_NAMESPACE::register_kernels(
|
|
260
260
|
{kernels.data(), kernels.size()});
|
|
261
261
|
}
|
|
262
262
|
inline OpFunction getOpsFn(const char *name,
|
|
263
263
|
ArrayRef<TensorMeta> meta_list = {}) {
|
|
264
|
-
auto result =
|
|
265
|
-
|
|
264
|
+
auto result =
|
|
265
|
+
::executorch::ET_RUNTIME_NAMESPACE::get_op_function_from_registry(
|
|
266
|
+
name, {meta_list.data(), meta_list.size()});
|
|
266
267
|
ET_CHECK(result.ok()); // get_op_function_from_registry() logs details.
|
|
267
268
|
return *result;
|
|
268
269
|
}
|
|
269
270
|
inline bool hasOpsFn(const char *name, ArrayRef<TensorMeta> meta_list = {}) {
|
|
270
|
-
return ::executorch::
|
|
271
|
+
return ::executorch::ET_RUNTIME_NAMESPACE::registry_has_op_function(
|
|
271
272
|
name, {meta_list.data(), meta_list.size()});
|
|
272
273
|
}
|
|
273
274
|
inline ArrayRef<Kernel> get_kernels() {
|
|
274
|
-
Span<const Kernel> kernels =
|
|
275
|
+
Span<const Kernel> kernels =
|
|
276
|
+
::executorch::ET_RUNTIME_NAMESPACE::get_registered_kernels();
|
|
275
277
|
return ArrayRef<Kernel>(kernels.data(), kernels.size());
|
|
276
278
|
}
|
|
277
279
|
} // namespace executor
|
|
@@ -171,6 +171,14 @@
|
|
|
171
171
|
using ssize_t = ptrdiff_t;
|
|
172
172
|
#endif
|
|
173
173
|
|
|
174
|
+
#ifdef __EXCEPTIONS
|
|
175
|
+
#define ET_HAS_EXCEPTIONS 1
|
|
176
|
+
#elif defined(_MSC_VER) && defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS
|
|
177
|
+
#define ET_HAS_EXCEPTIONS 1
|
|
178
|
+
#else
|
|
179
|
+
#define ET_HAS_EXCEPTIONS 0
|
|
180
|
+
#endif
|
|
181
|
+
|
|
174
182
|
// DEPRECATED: Use the non-underscore-prefixed versions instead.
|
|
175
183
|
// TODO(T199005537): Remove these once all users have stopped using them.
|
|
176
184
|
#define __ET_DEPRECATED ET_DEPRECATED
|