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
|
@@ -197,6 +197,11 @@ ET_FORALL_SCALAR_TYPES(SPECIALIZE_CppTypeToScalarType)
|
|
|
197
197
|
_(ANOTHER_INPUT, float, Float) \
|
|
198
198
|
_(ANOTHER_INPUT, double, Double)
|
|
199
199
|
|
|
200
|
+
#define ET_FORALL_FLOATH_TYPES_WITH(ANOTHER_INPUT, _) \
|
|
201
|
+
_(ANOTHER_INPUT, float, Float) \
|
|
202
|
+
_(ANOTHER_INPUT, double, Double) \
|
|
203
|
+
_(ANOTHER_INPUT, ::executorch::aten::Half, Half)
|
|
204
|
+
|
|
200
205
|
#define ET_FORALL_FLOAT_TYPES_WITH2(ANOTHER_INPUT1, ANOTHER_INPUT2, _) \
|
|
201
206
|
_(ANOTHER_INPUT1, ANOTHER_INPUT2, float, Float) \
|
|
202
207
|
_(ANOTHER_INPUT1, ANOTHER_INPUT2, double, Double)
|
|
@@ -888,7 +893,7 @@ public:
|
|
|
888
893
|
} \
|
|
889
894
|
}()
|
|
890
895
|
|
|
891
|
-
#define
|
|
896
|
+
#define ET_INTERNAL_SWITCH_CASE_INT_TYPES(CTYPE_ALIAS, ...) \
|
|
892
897
|
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::Byte, CTYPE_ALIAS, \
|
|
893
898
|
__VA_ARGS__) \
|
|
894
899
|
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::Char, CTYPE_ALIAS, \
|
|
@@ -898,33 +903,50 @@ public:
|
|
|
898
903
|
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::Int, CTYPE_ALIAS, \
|
|
899
904
|
__VA_ARGS__) \
|
|
900
905
|
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::Long, CTYPE_ALIAS, \
|
|
906
|
+
__VA_ARGS__)
|
|
907
|
+
|
|
908
|
+
#define ET_INTERNAL_SWITCH_CASE_UINT_TYPES(CTYPE_ALIAS, ...) \
|
|
909
|
+
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::UInt16, CTYPE_ALIAS, \
|
|
901
910
|
__VA_ARGS__) \
|
|
902
|
-
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::
|
|
911
|
+
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::UInt32, CTYPE_ALIAS, \
|
|
903
912
|
__VA_ARGS__) \
|
|
913
|
+
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::UInt64, CTYPE_ALIAS, \
|
|
914
|
+
__VA_ARGS__)
|
|
915
|
+
|
|
916
|
+
#define ET_INTERNAL_SWITCH_CASE_FLOAT_TYPES(CTYPE_ALIAS, ...) \
|
|
904
917
|
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::Float, CTYPE_ALIAS, \
|
|
905
918
|
__VA_ARGS__) \
|
|
906
919
|
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::Double, CTYPE_ALIAS, \
|
|
907
|
-
__VA_ARGS__)
|
|
908
|
-
|
|
909
|
-
|
|
920
|
+
__VA_ARGS__)
|
|
921
|
+
|
|
922
|
+
#define ET_INTERNAL_SWITCH_CASE_REAL_TYPES(CTYPE_ALIAS, ...) \
|
|
923
|
+
ET_INTERNAL_SWITCH_CASE_INT_TYPES(CTYPE_ALIAS, __VA_ARGS__) \
|
|
924
|
+
ET_INTERNAL_SWITCH_CASE_FLOAT_TYPES(CTYPE_ALIAS, __VA_ARGS__)
|
|
925
|
+
|
|
926
|
+
#define ET_INTERNAL_SWITCH_CASE_COMPLEX_TYPES(CTYPE_ALIAS, ...) \
|
|
910
927
|
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::ComplexFloat, \
|
|
911
928
|
CTYPE_ALIAS, __VA_ARGS__) \
|
|
912
929
|
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::ComplexDouble, \
|
|
913
|
-
CTYPE_ALIAS, __VA_ARGS__)
|
|
914
|
-
|
|
915
|
-
|
|
930
|
+
CTYPE_ALIAS, __VA_ARGS__)
|
|
931
|
+
|
|
932
|
+
#define ET_INTERNAL_SWITCH_CASE_COMPLEXH_TYPES(CTYPE_ALIAS, ...) \
|
|
933
|
+
ET_INTERNAL_SWITCH_CASE_COMPLEX_TYPES(CTYPE_ALIAS, __VA_ARGS__) \
|
|
934
|
+
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::ComplexHalf, \
|
|
935
|
+
CTYPE_ALIAS, __VA_ARGS__)
|
|
936
|
+
|
|
937
|
+
#define ET_INTERNAL_SWITCH_CASE_QINT_TYPES(CTYPE_ALIAS, ...) \
|
|
916
938
|
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::QInt8, CTYPE_ALIAS, \
|
|
917
939
|
__VA_ARGS__) \
|
|
918
940
|
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::QUInt8, CTYPE_ALIAS, \
|
|
919
941
|
__VA_ARGS__) \
|
|
920
942
|
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::QInt32, CTYPE_ALIAS, \
|
|
921
943
|
__VA_ARGS__) \
|
|
922
|
-
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::BFloat16, \
|
|
923
|
-
CTYPE_ALIAS, __VA_ARGS__) \
|
|
924
944
|
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::QUInt4x2, \
|
|
925
945
|
CTYPE_ALIAS, __VA_ARGS__) \
|
|
926
946
|
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::QUInt2x4, \
|
|
927
|
-
CTYPE_ALIAS, __VA_ARGS__)
|
|
947
|
+
CTYPE_ALIAS, __VA_ARGS__)
|
|
948
|
+
|
|
949
|
+
#define ET_INTERNAL_SWITCH_CASE_BITS_TYPES(CTYPE_ALIAS, ...) \
|
|
928
950
|
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::Bits1x8, \
|
|
929
951
|
CTYPE_ALIAS, __VA_ARGS__) \
|
|
930
952
|
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::Bits2x4, \
|
|
@@ -936,21 +958,17 @@ public:
|
|
|
936
958
|
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::Bits16, CTYPE_ALIAS, \
|
|
937
959
|
__VA_ARGS__)
|
|
938
960
|
|
|
939
|
-
#define
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::Char, CTYPE_ALIAS, \
|
|
943
|
-
__VA_ARGS__) \
|
|
944
|
-
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::Short, CTYPE_ALIAS, \
|
|
945
|
-
__VA_ARGS__) \
|
|
946
|
-
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::Int, CTYPE_ALIAS, \
|
|
947
|
-
__VA_ARGS__) \
|
|
948
|
-
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::Long, CTYPE_ALIAS, \
|
|
961
|
+
#define ET_INTERNAL_SWITCH_CASE_ALL_TYPES(CTYPE_ALIAS, ...) \
|
|
962
|
+
ET_INTERNAL_SWITCH_CASE_REAL_TYPES(CTYPE_ALIAS, __VA_ARGS__) \
|
|
963
|
+
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::Half, CTYPE_ALIAS, \
|
|
949
964
|
__VA_ARGS__) \
|
|
950
|
-
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::
|
|
965
|
+
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::BFloat16, \
|
|
966
|
+
CTYPE_ALIAS, __VA_ARGS__) \
|
|
967
|
+
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::Bool, CTYPE_ALIAS, \
|
|
951
968
|
__VA_ARGS__) \
|
|
952
|
-
|
|
953
|
-
|
|
969
|
+
ET_INTERNAL_SWITCH_CASE_COMPLEXH_TYPES(CTYPE_ALIAS, __VA_ARGS__) \
|
|
970
|
+
ET_INTERNAL_SWITCH_CASE_QINT_TYPES(CTYPE_ALIAS, __VA_ARGS__) \
|
|
971
|
+
ET_INTERNAL_SWITCH_CASE_BITS_TYPES(CTYPE_ALIAS, __VA_ARGS__)
|
|
954
972
|
|
|
955
973
|
#define ET_INTERNAL_SWITCH_CASE_REAL_TYPES_AND(ADDITIONAL, CTYPE_ALIAS, ...) \
|
|
956
974
|
ET_INTERNAL_SWITCH_CASE_REAL_TYPES(CTYPE_ALIAS, __VA_ARGS__) \
|
|
@@ -975,29 +993,11 @@ public:
|
|
|
975
993
|
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::ADDITIONAL3, \
|
|
976
994
|
CTYPE_ALIAS, __VA_ARGS__)
|
|
977
995
|
|
|
978
|
-
#define ET_INTERNAL_SWITCH_CASE_INT_TYPES(CTYPE_ALIAS, ...) \
|
|
979
|
-
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::Byte, CTYPE_ALIAS, \
|
|
980
|
-
__VA_ARGS__) \
|
|
981
|
-
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::Char, CTYPE_ALIAS, \
|
|
982
|
-
__VA_ARGS__) \
|
|
983
|
-
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::Short, CTYPE_ALIAS, \
|
|
984
|
-
__VA_ARGS__) \
|
|
985
|
-
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::Int, CTYPE_ALIAS, \
|
|
986
|
-
__VA_ARGS__) \
|
|
987
|
-
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::Long, CTYPE_ALIAS, \
|
|
988
|
-
__VA_ARGS__)
|
|
989
|
-
|
|
990
996
|
#define ET_INTERNAL_SWITCH_CASE_INT_TYPES_AND(ADDITIONAL, CTYPE_ALIAS, ...) \
|
|
991
997
|
ET_INTERNAL_SWITCH_CASE_INT_TYPES(CTYPE_ALIAS, __VA_ARGS__) \
|
|
992
998
|
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::ADDITIONAL, \
|
|
993
999
|
CTYPE_ALIAS, __VA_ARGS__)
|
|
994
1000
|
|
|
995
|
-
#define ET_INTERNAL_SWITCH_CASE_FLOAT_TYPES(CTYPE_ALIAS, ...) \
|
|
996
|
-
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::Double, CTYPE_ALIAS, \
|
|
997
|
-
__VA_ARGS__) \
|
|
998
|
-
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::Float, CTYPE_ALIAS, \
|
|
999
|
-
__VA_ARGS__)
|
|
1000
|
-
|
|
1001
1001
|
#define ET_INTERNAL_SWITCH_CASE_FLOAT_TYPES_AND(ADDITIONAL, CTYPE_ALIAS, ...) \
|
|
1002
1002
|
ET_INTERNAL_SWITCH_CASE_FLOAT_TYPES(CTYPE_ALIAS, __VA_ARGS__) \
|
|
1003
1003
|
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::ADDITIONAL, \
|
|
@@ -1017,32 +1017,6 @@ public:
|
|
|
1017
1017
|
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::ADDITIONAL3, \
|
|
1018
1018
|
CTYPE_ALIAS, __VA_ARGS__)
|
|
1019
1019
|
|
|
1020
|
-
#define ET_INTERNAL_SWITCH_CASE_QINT_TYPES(CTYPE_ALIAS, ...) \
|
|
1021
|
-
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::QInt8, CTYPE_ALIAS, \
|
|
1022
|
-
__VA_ARGS__) \
|
|
1023
|
-
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::QUInt8, CTYPE_ALIAS, \
|
|
1024
|
-
__VA_ARGS__) \
|
|
1025
|
-
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::QInt32, CTYPE_ALIAS, \
|
|
1026
|
-
__VA_ARGS__) \
|
|
1027
|
-
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::QUInt4x2, \
|
|
1028
|
-
CTYPE_ALIAS, __VA_ARGS__) \
|
|
1029
|
-
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::QUInt2x4, \
|
|
1030
|
-
CTYPE_ALIAS, __VA_ARGS__)
|
|
1031
|
-
|
|
1032
|
-
#define ET_INTERNAL_SWITCH_CASE_COMPLEX_TYPES(CTYPE_ALIAS, ...) \
|
|
1033
|
-
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::ComplexFloat, \
|
|
1034
|
-
CTYPE_ALIAS, __VA_ARGS__) \
|
|
1035
|
-
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::ComplexDouble, \
|
|
1036
|
-
CTYPE_ALIAS, __VA_ARGS__)
|
|
1037
|
-
|
|
1038
|
-
#define ET_INTERNAL_SWITCH_CASE_COMPLEXH_TYPES(CTYPE_ALIAS, ...) \
|
|
1039
|
-
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::ComplexHalf, \
|
|
1040
|
-
CTYPE_ALIAS, __VA_ARGS__) \
|
|
1041
|
-
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::ComplexFloat, \
|
|
1042
|
-
CTYPE_ALIAS, __VA_ARGS__) \
|
|
1043
|
-
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::ComplexDouble, \
|
|
1044
|
-
CTYPE_ALIAS, __VA_ARGS__)
|
|
1045
|
-
|
|
1046
1020
|
#define ET_INTERNAL_SWITCH_CASE_SCALAR_OBJ_TYPES(CTYPE_ALIAS, ...) \
|
|
1047
1021
|
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::Bool, CTYPE_ALIAS, \
|
|
1048
1022
|
__VA_ARGS__) \
|
|
@@ -1158,13 +1132,7 @@ public:
|
|
|
1158
1132
|
TYPE, CONTEXT, NAME, \
|
|
1159
1133
|
ET_INTERNAL_SWITCH_CASE_REAL_TYPES_AND3(Half, Bool, BFloat16, \
|
|
1160
1134
|
CTYPE_ALIAS, __VA_ARGS__) \
|
|
1161
|
-
|
|
1162
|
-
CTYPE_ALIAS, __VA_ARGS__) \
|
|
1163
|
-
ET_INTERNAL_SWITCH_CASE(::executorch::aten::ScalarType::UInt32, \
|
|
1164
|
-
CTYPE_ALIAS, __VA_ARGS__) \
|
|
1165
|
-
ET_INTERNAL_SWITCH_CASE( \
|
|
1166
|
-
::executorch::aten::ScalarType::UInt64, CTYPE_ALIAS, \
|
|
1167
|
-
__VA_ARGS__))
|
|
1135
|
+
ET_INTERNAL_SWITCH_CASE_UINT_TYPES(CTYPE_ALIAS, __VA_ARGS__))
|
|
1168
1136
|
|
|
1169
1137
|
#define ET_SWITCH_INT_TYPES(TYPE, CONTEXT, NAME, CTYPE_ALIAS, ...) \
|
|
1170
1138
|
ET_INTERNAL_SWITCH( \
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
#include <limits>
|
|
19
19
|
|
|
20
|
+
#include <c10/util/irange.h>
|
|
20
21
|
#include <executorch/runtime/core/array_ref.h>
|
|
21
22
|
#include <executorch/runtime/core/error.h>
|
|
22
23
|
#include <executorch/runtime/core/exec_aten/exec_aten.h>
|
|
@@ -228,7 +229,7 @@
|
|
|
228
229
|
a_strides = a__.strides(); \
|
|
229
230
|
const ::executorch::aten::ArrayRef<executorch::aten::StridesType> \
|
|
230
231
|
b_strides = b__.strides(); \
|
|
231
|
-
for (
|
|
232
|
+
for (const auto i : c10::irange(a__.dim())) { \
|
|
232
233
|
ET_CHECK_MSG(a_strides[i] == b_strides[i], \
|
|
233
234
|
"a.strides()[%zu] shall equal to b.strides()[%zu], " \
|
|
234
235
|
"but now is %d and %d.", \
|
|
@@ -253,7 +254,7 @@
|
|
|
253
254
|
b_strides = b__.strides(); \
|
|
254
255
|
const ::executorch::aten::ArrayRef<executorch::aten::StridesType> \
|
|
255
256
|
c_strides = c__.strides(); \
|
|
256
|
-
for (
|
|
257
|
+
for (const auto i : c10::irange(a__.dim())) { \
|
|
257
258
|
ET_CHECK_MSG(a_strides[i] == b_strides[i] && \
|
|
258
259
|
b_strides[i] == c_strides[i], \
|
|
259
260
|
"a_strides[%zu], b_strides[%zu] and c_strides[%zu] " \
|
|
@@ -334,8 +335,7 @@
|
|
|
334
335
|
" could not be extracted: wrong type or out of range");
|
|
335
336
|
|
|
336
337
|
namespace executorch {
|
|
337
|
-
namespace
|
|
338
|
-
|
|
338
|
+
namespace ET_RUNTIME_NAMESPACE {
|
|
339
339
|
//
|
|
340
340
|
// Utility functions for checking tensor attributes
|
|
341
341
|
//
|
|
@@ -379,10 +379,10 @@ inline ssize_t nonempty_size(const executorch::aten::Tensor &tensor,
|
|
|
379
379
|
|
|
380
380
|
inline bool tensor_can_cast_to(executorch::aten::Tensor a,
|
|
381
381
|
executorch::aten::ScalarType dtype) {
|
|
382
|
-
ET_CHECK_OR_RETURN_FALSE(torch::executor::canCast(a.scalar_type(), dtype),
|
|
382
|
+
ET_CHECK_OR_RETURN_FALSE(::torch::executor::canCast(a.scalar_type(), dtype),
|
|
383
383
|
"Tensor of dtype %s cannot cast to dtype %s",
|
|
384
|
-
torch::executor::toString(a.scalar_type()),
|
|
385
|
-
torch::executor::toString(dtype));
|
|
384
|
+
::torch::executor::toString(a.scalar_type()),
|
|
385
|
+
::torch::executor::toString(dtype));
|
|
386
386
|
|
|
387
387
|
return true;
|
|
388
388
|
}
|
|
@@ -391,7 +391,7 @@ inline bool tensor_is_bool_type(executorch::aten::Tensor t) {
|
|
|
391
391
|
ET_CHECK_OR_RETURN_FALSE(t.scalar_type() ==
|
|
392
392
|
executorch::aten::ScalarType::Bool,
|
|
393
393
|
"Expected to find bool type, but tensor has type %s",
|
|
394
|
-
torch::executor::toString(t.scalar_type()));
|
|
394
|
+
::torch::executor::toString(t.scalar_type()));
|
|
395
395
|
|
|
396
396
|
return true;
|
|
397
397
|
}
|
|
@@ -400,8 +400,8 @@ inline bool tensor_is_type(executorch::aten::Tensor t,
|
|
|
400
400
|
executorch::aten::ScalarType dtype) {
|
|
401
401
|
ET_CHECK_OR_RETURN_FALSE(t.scalar_type() == dtype,
|
|
402
402
|
"Expected to find %s type, but tensor has type %s",
|
|
403
|
-
torch::executor::toString(dtype),
|
|
404
|
-
torch::executor::toString(t.scalar_type()));
|
|
403
|
+
::torch::executor::toString(dtype),
|
|
404
|
+
::torch::executor::toString(t.scalar_type()));
|
|
405
405
|
|
|
406
406
|
return true;
|
|
407
407
|
}
|
|
@@ -412,8 +412,8 @@ inline bool tensor_is_type(executorch::aten::Tensor t,
|
|
|
412
412
|
ET_LOG_MSG_AND_RETURN_IF_FALSE(
|
|
413
413
|
t.scalar_type() == dtype || t.scalar_type() == dtype2,
|
|
414
414
|
"Expected to find %s or %s type, but tensor has type %s",
|
|
415
|
-
torch::executor::toString(dtype), torch::executor::toString(dtype2),
|
|
416
|
-
torch::executor::toString(t.scalar_type()));
|
|
415
|
+
::torch::executor::toString(dtype), ::torch::executor::toString(dtype2),
|
|
416
|
+
::torch::executor::toString(t.scalar_type()));
|
|
417
417
|
|
|
418
418
|
return true;
|
|
419
419
|
}
|
|
@@ -426,9 +426,9 @@ inline bool tensor_is_type(executorch::aten::Tensor t,
|
|
|
426
426
|
t.scalar_type() == dtype || t.scalar_type() == dtype2 ||
|
|
427
427
|
t.scalar_type() == dtype3,
|
|
428
428
|
"Expected to find %s, %s, or %s type, but tensor has type %s",
|
|
429
|
-
torch::executor::toString(dtype), torch::executor::toString(dtype2),
|
|
430
|
-
torch::executor::toString(dtype3),
|
|
431
|
-
torch::executor::toString(t.scalar_type()));
|
|
429
|
+
::torch::executor::toString(dtype), ::torch::executor::toString(dtype2),
|
|
430
|
+
::torch::executor::toString(dtype3),
|
|
431
|
+
::torch::executor::toString(t.scalar_type()));
|
|
432
432
|
|
|
433
433
|
return true;
|
|
434
434
|
}
|
|
@@ -436,36 +436,36 @@ inline bool tensor_is_type(executorch::aten::Tensor t,
|
|
|
436
436
|
inline bool tensor_is_integral_type(executorch::aten::Tensor t,
|
|
437
437
|
bool includeBool = false) {
|
|
438
438
|
ET_CHECK_OR_RETURN_FALSE(
|
|
439
|
-
torch::executor::isIntegralType(t.scalar_type(), includeBool),
|
|
439
|
+
::torch::executor::isIntegralType(t.scalar_type(), includeBool),
|
|
440
440
|
"Expected to find a integral type, but tensor has type %s",
|
|
441
|
-
torch::executor::toString(t.scalar_type()));
|
|
441
|
+
::torch::executor::toString(t.scalar_type()));
|
|
442
442
|
|
|
443
443
|
return true;
|
|
444
444
|
}
|
|
445
445
|
|
|
446
446
|
inline bool tensor_is_floating_type(executorch::aten::Tensor t) {
|
|
447
447
|
ET_CHECK_OR_RETURN_FALSE(
|
|
448
|
-
torch::executor::isFloatingType(t.scalar_type()),
|
|
448
|
+
::torch::executor::isFloatingType(t.scalar_type()),
|
|
449
449
|
"Expected to find a floating type, but tensor has type %s",
|
|
450
|
-
torch::executor::toString(t.scalar_type()));
|
|
450
|
+
::torch::executor::toString(t.scalar_type()));
|
|
451
451
|
|
|
452
452
|
return true;
|
|
453
453
|
}
|
|
454
454
|
|
|
455
455
|
inline bool tensor_is_real_type(executorch::aten::Tensor t) {
|
|
456
456
|
ET_CHECK_OR_RETURN_FALSE(
|
|
457
|
-
torch::executor::isRealType(t.scalar_type()),
|
|
457
|
+
::torch::executor::isRealType(t.scalar_type()),
|
|
458
458
|
"Expected to find a real type, but tensor has type %s",
|
|
459
|
-
torch::executor::toString(t.scalar_type()));
|
|
459
|
+
::torch::executor::toString(t.scalar_type()));
|
|
460
460
|
|
|
461
461
|
return true;
|
|
462
462
|
}
|
|
463
463
|
|
|
464
464
|
inline bool tensor_is_realh_type(executorch::aten::Tensor t) {
|
|
465
465
|
ET_CHECK_OR_RETURN_FALSE(
|
|
466
|
-
torch::executor::isRealHType(t.scalar_type()),
|
|
466
|
+
::torch::executor::isRealHType(t.scalar_type()),
|
|
467
467
|
"Expected to find a real type, but tensor has type %s",
|
|
468
|
-
torch::executor::toString(t.scalar_type()));
|
|
468
|
+
::torch::executor::toString(t.scalar_type()));
|
|
469
469
|
|
|
470
470
|
return true;
|
|
471
471
|
}
|
|
@@ -474,16 +474,16 @@ inline bool tensor_is_realhbf16_type(executorch::aten::Tensor t) {
|
|
|
474
474
|
ET_CHECK_OR_RETURN_FALSE(
|
|
475
475
|
executorch::runtime::isRealHBF16Type(t.scalar_type()),
|
|
476
476
|
"Expected to find a real type, but tensor has type %s",
|
|
477
|
-
torch::executor::toString(t.scalar_type()));
|
|
477
|
+
::torch::executor::toString(t.scalar_type()));
|
|
478
478
|
|
|
479
479
|
return true;
|
|
480
480
|
}
|
|
481
481
|
|
|
482
482
|
inline bool tensor_is_realhb_type(executorch::aten::Tensor t) {
|
|
483
483
|
ET_CHECK_OR_RETURN_FALSE(
|
|
484
|
-
torch::executor::isRealHBType(t.scalar_type()),
|
|
484
|
+
::torch::executor::isRealHBType(t.scalar_type()),
|
|
485
485
|
"Expected to find a real type, but tensor has type %s",
|
|
486
|
-
torch::executor::toString(t.scalar_type()));
|
|
486
|
+
::torch::executor::toString(t.scalar_type()));
|
|
487
487
|
|
|
488
488
|
return true;
|
|
489
489
|
}
|
|
@@ -492,25 +492,25 @@ inline bool tensor_is_realhbbf16_type(executorch::aten::Tensor t) {
|
|
|
492
492
|
ET_CHECK_OR_RETURN_FALSE(
|
|
493
493
|
executorch::runtime::isRealHBBF16Type(t.scalar_type()),
|
|
494
494
|
"Expected to find a real type, but tensor has type %s",
|
|
495
|
-
torch::executor::toString(t.scalar_type()));
|
|
495
|
+
::torch::executor::toString(t.scalar_type()));
|
|
496
496
|
|
|
497
497
|
return true;
|
|
498
498
|
}
|
|
499
499
|
|
|
500
500
|
inline bool tensor_is_complex_type(executorch::aten::Tensor t) {
|
|
501
501
|
ET_CHECK_OR_RETURN_FALSE(
|
|
502
|
-
torch::executor::isComplexType(t.scalar_type()),
|
|
502
|
+
::torch::executor::isComplexType(t.scalar_type()),
|
|
503
503
|
"Expected to find a complex type, but tensor has type %s",
|
|
504
|
-
torch::executor::toString(t.scalar_type()));
|
|
504
|
+
::torch::executor::toString(t.scalar_type()));
|
|
505
505
|
|
|
506
506
|
return true;
|
|
507
507
|
}
|
|
508
508
|
|
|
509
509
|
inline bool tensor_is_bits_type(executorch::aten::Tensor t) {
|
|
510
510
|
ET_CHECK_OR_RETURN_FALSE(
|
|
511
|
-
torch::executor::isBitsType(t.scalar_type()),
|
|
511
|
+
::torch::executor::isBitsType(t.scalar_type()),
|
|
512
512
|
"Expected to find a bits type, but tensor has type %s",
|
|
513
|
-
torch::executor::toString(t.scalar_type()));
|
|
513
|
+
::torch::executor::toString(t.scalar_type()));
|
|
514
514
|
|
|
515
515
|
return true;
|
|
516
516
|
}
|
|
@@ -519,8 +519,8 @@ inline bool tensors_have_same_dtype(executorch::aten::Tensor a,
|
|
|
519
519
|
executorch::aten::Tensor b) {
|
|
520
520
|
ET_CHECK_OR_RETURN_FALSE(a.scalar_type() == b.scalar_type(),
|
|
521
521
|
ET_TENSOR_CHECK_PREFIX__ ": dtype={%s, %s}",
|
|
522
|
-
torch::executor::toString(a.scalar_type()),
|
|
523
|
-
torch::executor::toString(b.scalar_type()));
|
|
522
|
+
::torch::executor::toString(a.scalar_type()),
|
|
523
|
+
::torch::executor::toString(b.scalar_type()));
|
|
524
524
|
return true;
|
|
525
525
|
}
|
|
526
526
|
|
|
@@ -530,9 +530,9 @@ inline bool tensors_have_same_dtype(executorch::aten::Tensor a,
|
|
|
530
530
|
ET_CHECK_OR_RETURN_FALSE(a.scalar_type() == b.scalar_type() &&
|
|
531
531
|
b.scalar_type() == c.scalar_type(),
|
|
532
532
|
ET_TENSOR_CHECK_PREFIX__ ": dtype={%s, %s, %s}",
|
|
533
|
-
torch::executor::toString(a.scalar_type()),
|
|
534
|
-
torch::executor::toString(b.scalar_type()),
|
|
535
|
-
torch::executor::toString(c.scalar_type()));
|
|
533
|
+
::torch::executor::toString(a.scalar_type()),
|
|
534
|
+
::torch::executor::toString(b.scalar_type()),
|
|
535
|
+
::torch::executor::toString(c.scalar_type()));
|
|
536
536
|
return true;
|
|
537
537
|
}
|
|
538
538
|
|
|
@@ -827,7 +827,7 @@ inline size_t getTrailingDims(const executorch::aten::Tensor &tensor,
|
|
|
827
827
|
inline size_t coordinateToIndex(const executorch::aten::Tensor &tensor,
|
|
828
828
|
const size_t *const coordinate) {
|
|
829
829
|
size_t index = 0;
|
|
830
|
-
for (
|
|
830
|
+
for (const auto d : c10::irange(tensor.dim())) {
|
|
831
831
|
index += coordinate[d] * getTrailingDims(tensor, d);
|
|
832
832
|
}
|
|
833
833
|
return index;
|
|
@@ -858,7 +858,7 @@ inline size_t coordinateToIndexWithTrailingDimsMemo(
|
|
|
858
858
|
const executorch::aten::Tensor &tensor, const size_t *const coordinate,
|
|
859
859
|
const size_t trailing_dims_memo[kTensorDimensionLimit]) {
|
|
860
860
|
size_t index = 0;
|
|
861
|
-
for (
|
|
861
|
+
for (const auto d : c10::irange(tensor.dim())) {
|
|
862
862
|
index += coordinate[d] * trailing_dims_memo[d];
|
|
863
863
|
}
|
|
864
864
|
return index;
|
|
@@ -878,7 +878,7 @@ inline size_t coordinateToIndexWithTrailingDimsMemo(
|
|
|
878
878
|
inline void indexToCoordinate(const executorch::aten::Tensor &tensor,
|
|
879
879
|
size_t index, size_t *coordinate) {
|
|
880
880
|
ET_CHECK(index < static_cast<size_t>(tensor.numel()));
|
|
881
|
-
for (auto i
|
|
881
|
+
for (const auto i : c10::irange(tensor.dim())) {
|
|
882
882
|
auto dim = tensor.dim() - 1 - i;
|
|
883
883
|
size_t dim_size = tensor.size(dim);
|
|
884
884
|
coordinate[dim] = index % dim_size;
|
|
@@ -1058,7 +1058,7 @@ resize_tensor(executorch::aten::Tensor t,
|
|
|
1058
1058
|
std::array<executorch::aten::SizesType, kTensorDimensionLimit>
|
|
1059
1059
|
new_sizes_casted{};
|
|
1060
1060
|
size_t new_sizes_ndim = new_sizes.size();
|
|
1061
|
-
for (
|
|
1061
|
+
for (const auto i : c10::irange(new_sizes_ndim)) {
|
|
1062
1062
|
new_sizes_casted[i] =
|
|
1063
1063
|
static_cast<executorch::aten::SizesType>(new_sizes[i]);
|
|
1064
1064
|
}
|
|
@@ -1185,66 +1185,67 @@ calculate_linear_index(const executorch::aten::SizesType *coordinate,
|
|
|
1185
1185
|
const executorch::aten::StridesType *strides,
|
|
1186
1186
|
const size_t ndim) {
|
|
1187
1187
|
size_t index = 0;
|
|
1188
|
-
for (
|
|
1188
|
+
for (const auto i : c10::irange(ndim)) {
|
|
1189
1189
|
index += coordinate[i] * strides[i];
|
|
1190
1190
|
}
|
|
1191
1191
|
return index;
|
|
1192
1192
|
}
|
|
1193
1193
|
|
|
1194
|
-
} // namespace
|
|
1194
|
+
} // namespace ET_RUNTIME_NAMESPACE
|
|
1195
1195
|
} // namespace executorch
|
|
1196
1196
|
|
|
1197
1197
|
namespace torch {
|
|
1198
1198
|
namespace executor {
|
|
1199
1199
|
// TODO(T197294990): Remove these deprecated aliases once all users have moved
|
|
1200
1200
|
// to the new `::executorch` namespaces.
|
|
1201
|
-
using ::executorch::
|
|
1202
|
-
using ::executorch::
|
|
1203
|
-
using ::executorch::
|
|
1204
|
-
using ::executorch::
|
|
1205
|
-
using ::executorch::
|
|
1206
|
-
using ::executorch::
|
|
1207
|
-
using ::executorch::
|
|
1208
|
-
using ::executorch::
|
|
1201
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::calculate_linear_index;
|
|
1202
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::coordinateToIndex;
|
|
1203
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::dim_is_valid;
|
|
1204
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::extract_scalar_tensor;
|
|
1205
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::get_dim_order;
|
|
1206
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::getLeadingDims;
|
|
1207
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::getTrailingDims;
|
|
1208
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::indexToCoordinate;
|
|
1209
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::nonempty_size;
|
|
1210
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::nonzero_dim;
|
|
1211
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::resize;
|
|
1212
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::resize_tensor;
|
|
1213
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::tensor_can_cast_to;
|
|
1214
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::tensor_dim_has_index;
|
|
1215
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::tensor_has_dim;
|
|
1216
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::tensor_has_expected_size;
|
|
1217
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::tensor_has_non_empty_dim;
|
|
1218
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::tensor_has_rank_greater_or_equal_to;
|
|
1219
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::tensor_has_rank_smaller_or_equal_to;
|
|
1220
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::tensor_has_valid_dim_order;
|
|
1221
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::tensor_is_bits_type;
|
|
1222
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::tensor_is_bool_type;
|
|
1223
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::tensor_is_complex_type;
|
|
1224
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::tensor_is_contiguous;
|
|
1225
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::tensor_is_default_dim_order;
|
|
1226
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::
|
|
1227
|
+
tensor_is_default_or_channels_last_dim_order;
|
|
1228
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::tensor_is_floating_type;
|
|
1229
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::tensor_is_integral_type;
|
|
1230
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::tensor_is_rank;
|
|
1231
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::tensor_is_real_type;
|
|
1232
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::tensor_is_realh_type;
|
|
1233
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::tensor_is_realhb_type;
|
|
1234
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::tensor_is_scalar;
|
|
1235
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::tensors_have_same_dim_order;
|
|
1236
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::tensors_have_same_dtype;
|
|
1237
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::tensors_have_same_rank;
|
|
1238
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::tensors_have_same_shape;
|
|
1239
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::tensors_have_same_shape_and_dtype;
|
|
1240
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::tensors_have_same_size_at_dims;
|
|
1241
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::tensors_have_same_strides;
|
|
1209
1242
|
using ::executorch::runtime::kTensorDimensionLimit;
|
|
1210
|
-
using ::executorch::runtime::nonempty_size;
|
|
1211
|
-
using ::executorch::runtime::nonzero_dim;
|
|
1212
|
-
using ::executorch::runtime::resize;
|
|
1213
|
-
using ::executorch::runtime::resize_tensor;
|
|
1214
|
-
using ::executorch::runtime::tensor_can_cast_to;
|
|
1215
|
-
using ::executorch::runtime::tensor_dim_has_index;
|
|
1216
|
-
using ::executorch::runtime::tensor_has_dim;
|
|
1217
|
-
using ::executorch::runtime::tensor_has_expected_size;
|
|
1218
|
-
using ::executorch::runtime::tensor_has_non_empty_dim;
|
|
1219
|
-
using ::executorch::runtime::tensor_has_rank_greater_or_equal_to;
|
|
1220
|
-
using ::executorch::runtime::tensor_has_rank_smaller_or_equal_to;
|
|
1221
|
-
using ::executorch::runtime::tensor_has_valid_dim_order;
|
|
1222
|
-
using ::executorch::runtime::tensor_is_bits_type;
|
|
1223
|
-
using ::executorch::runtime::tensor_is_bool_type;
|
|
1224
|
-
using ::executorch::runtime::tensor_is_complex_type;
|
|
1225
|
-
using ::executorch::runtime::tensor_is_contiguous;
|
|
1226
|
-
using ::executorch::runtime::tensor_is_default_dim_order;
|
|
1227
|
-
using ::executorch::runtime::tensor_is_default_or_channels_last_dim_order;
|
|
1228
|
-
using ::executorch::runtime::tensor_is_floating_type;
|
|
1229
|
-
using ::executorch::runtime::tensor_is_integral_type;
|
|
1230
|
-
using ::executorch::runtime::tensor_is_rank;
|
|
1231
|
-
using ::executorch::runtime::tensor_is_real_type;
|
|
1232
|
-
using ::executorch::runtime::tensor_is_realh_type;
|
|
1233
|
-
using ::executorch::runtime::tensor_is_realhb_type;
|
|
1234
|
-
using ::executorch::runtime::tensor_is_scalar;
|
|
1235
|
-
using ::executorch::runtime::tensors_have_same_dim_order;
|
|
1236
|
-
using ::executorch::runtime::tensors_have_same_dtype;
|
|
1237
|
-
using ::executorch::runtime::tensors_have_same_rank;
|
|
1238
|
-
using ::executorch::runtime::tensors_have_same_shape;
|
|
1239
|
-
using ::executorch::runtime::tensors_have_same_shape_and_dtype;
|
|
1240
|
-
using ::executorch::runtime::tensors_have_same_size_at_dims;
|
|
1241
|
-
using ::executorch::runtime::tensors_have_same_strides;
|
|
1242
1243
|
namespace internal {
|
|
1243
|
-
using ::executorch::
|
|
1244
|
-
using ::executorch::
|
|
1245
|
-
using ::executorch::
|
|
1246
|
-
using ::executorch::
|
|
1247
|
-
using ::executorch::
|
|
1244
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::internal::copy_tensor_data;
|
|
1245
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::internal::reset_data_ptr;
|
|
1246
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::internal::resize_tensor_impl;
|
|
1247
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::internal::set_tensor_data;
|
|
1248
|
+
using ::executorch::ET_RUNTIME_NAMESPACE::internal::share_tensor_data;
|
|
1248
1249
|
} // namespace internal
|
|
1249
1250
|
} // namespace executor
|
|
1250
1251
|
} // namespace torch
|
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
//===- llvm/ADT/STLFunctionalExtras.h - Extras for <functional> -*- C++ -*-===//
|
|
10
|
+
//
|
|
11
|
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
12
|
+
// See https://llvm.org/LICENSE.txt for license information.
|
|
13
|
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
14
|
+
//
|
|
15
|
+
//===----------------------------------------------------------------------===//
|
|
16
|
+
//
|
|
17
|
+
// This file contains some extension to <functional>.
|
|
18
|
+
//
|
|
19
|
+
// No library is required when using these functions.
|
|
20
|
+
//
|
|
21
|
+
//===----------------------------------------------------------------------===//
|
|
22
|
+
// Extra additions to <functional>
|
|
23
|
+
//===----------------------------------------------------------------------===//
|
|
24
|
+
|
|
25
|
+
/// An efficient, type-erasing, non-owning reference to a callable. This is
|
|
26
|
+
/// intended for use as the type of a function parameter that is not used
|
|
27
|
+
/// after the function in question returns.
|
|
28
|
+
///
|
|
29
|
+
/// This class does not own the callable, so it is not in general safe to store
|
|
30
|
+
/// a FunctionRef.
|
|
31
|
+
|
|
32
|
+
// torch::executor: modified from llvm::function_ref
|
|
33
|
+
// - renamed to FunctionRef
|
|
34
|
+
// - removed LLVM_GSL_POINTER and LLVM_LIFETIME_BOUND macro uses
|
|
35
|
+
// - use namespaced internal::remove_cvref_t
|
|
36
|
+
|
|
37
|
+
#pragma once
|
|
38
|
+
|
|
39
|
+
#include <cstdint>
|
|
40
|
+
#include <type_traits>
|
|
41
|
+
#include <utility>
|
|
42
|
+
|
|
43
|
+
namespace executorch::runtime {
|
|
44
|
+
|
|
45
|
+
//===----------------------------------------------------------------------===//
|
|
46
|
+
// Features from C++20
|
|
47
|
+
//===----------------------------------------------------------------------===//
|
|
48
|
+
|
|
49
|
+
namespace internal {
|
|
50
|
+
|
|
51
|
+
template <typename T> struct remove_cvref {
|
|
52
|
+
using type =
|
|
53
|
+
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
template <typename T> using remove_cvref_t = typename remove_cvref<T>::type;
|
|
57
|
+
|
|
58
|
+
} // namespace internal
|
|
59
|
+
|
|
60
|
+
template <typename Fn> class FunctionRef;
|
|
61
|
+
|
|
62
|
+
template <typename Ret, typename... Params> class FunctionRef<Ret(Params...)> {
|
|
63
|
+
Ret (*callback)(intptr_t callable, Params... params) = nullptr;
|
|
64
|
+
intptr_t callable;
|
|
65
|
+
|
|
66
|
+
template <typename Callable>
|
|
67
|
+
static Ret callback_fn(intptr_t callable, Params... params) {
|
|
68
|
+
return (*reinterpret_cast<Callable *>(callable))(
|
|
69
|
+
std::forward<Params>(params)...);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public:
|
|
73
|
+
FunctionRef() = default;
|
|
74
|
+
FunctionRef(std::nullptr_t) {}
|
|
75
|
+
|
|
76
|
+
template <typename Callable>
|
|
77
|
+
FunctionRef(
|
|
78
|
+
Callable &&callable,
|
|
79
|
+
// This is not the copy-constructor.
|
|
80
|
+
std::enable_if_t<!std::is_same<internal::remove_cvref_t<Callable>,
|
|
81
|
+
FunctionRef>::value> * = nullptr,
|
|
82
|
+
// Functor must be callable and return a suitable type.
|
|
83
|
+
std::enable_if_t<std::is_void<Ret>::value ||
|
|
84
|
+
std::is_convertible<decltype(std::declval<Callable>()(
|
|
85
|
+
std::declval<Params>()...)),
|
|
86
|
+
Ret>::value> * = nullptr)
|
|
87
|
+
: callback(callback_fn<std::remove_reference_t<Callable>>),
|
|
88
|
+
callable(reinterpret_cast<intptr_t>(&callable)) {}
|
|
89
|
+
|
|
90
|
+
Ret operator()(Params... params) const {
|
|
91
|
+
return callback(callable, std::forward<Params>(params)...);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
explicit operator bool() const { return callback; }
|
|
95
|
+
|
|
96
|
+
bool operator==(const FunctionRef<Ret(Params...)> &Other) const {
|
|
97
|
+
return callable == Other.callable;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
} // namespace executorch::runtime
|