cactus-react-native 0.2.11 → 1.0.2
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/Cactus.podspec +34 -0
- package/LICENSE +38 -0
- package/README.md +550 -69
- package/android/CMakeLists.txt +40 -0
- package/android/build.gradle +68 -44
- package/android/gradle.properties +5 -5
- package/android/src/main/AndroidManifest.xml +1 -3
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/cactus/CactusPackage.kt +22 -0
- package/android/src/main/java/com/margelo/nitro/cactus/HybridCactusCrypto.kt +38 -0
- package/android/src/main/java/com/margelo/nitro/cactus/HybridCactusDeviceInfo.kt +24 -0
- package/android/src/main/java/com/margelo/nitro/cactus/HybridCactusFileSystem.kt +227 -0
- package/android/src/main/jniLibs/arm64-v8a/{libcactus_v8.so → libcactus.a} +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libcactus_util.so +0 -0
- package/cpp/HybridCactus.cpp +135 -0
- package/cpp/HybridCactus.hpp +42 -0
- package/cpp/HybridCactusUtil.cpp +47 -0
- package/cpp/HybridCactusUtil.hpp +26 -0
- package/cpp/cactus_ffi.h +55 -0
- package/cpp/cactus_util.h +25 -0
- package/ios/HybridCactusCrypto.swift +37 -0
- package/ios/HybridCactusDeviceInfo.swift +32 -0
- package/ios/HybridCactusFileSystem.swift +234 -0
- package/ios/cactus.xcframework/{info.plist → Info.plist} +2 -37
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus.h +8 -229
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_ffi.h +28 -229
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/engine.h +545 -0
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ffi_utils.h +400 -0
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/graph.h +338 -0
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/kernel.h +275 -0
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/kernel_utils.h +343 -0
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Info.plist +0 -0
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/cactus +0 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus.h +11 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus_ffi.h +55 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/engine.h +545 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/ffi_utils.h +400 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/graph.h +338 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/kernel.h +275 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/kernel_utils.h +343 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Info.plist +0 -0
- package/ios/cactus.xcframework/{tvos-arm64_x86_64-simulator → ios-arm64-simulator}/cactus.framework/_CodeSignature/CodeResources +1 -1
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/cactus +0 -0
- package/ios/cactus_util.xcframework/Info.plist +39 -0
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/cactus_util.h +25 -0
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/ios_utils.h +10 -0
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/logging.h +25 -0
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Info.plist +0 -0
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/cactus_util +0 -0
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/cactus_util.h +25 -0
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/ios_utils.h +10 -0
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/logging.h +25 -0
- package/ios/{cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework → cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework}/Info.plist +0 -0
- package/ios/{cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework → cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework}/_CodeSignature/CodeResources +36 -2
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/cactus_util +0 -0
- package/lib/module/api/Database.js +60 -0
- package/lib/module/api/Database.js.map +1 -0
- package/lib/module/classes/CactusLM.js +151 -0
- package/lib/module/classes/CactusLM.js.map +1 -0
- package/lib/module/config/CactusConfig.js +6 -0
- package/lib/module/config/CactusConfig.js.map +1 -0
- package/lib/module/constants/packageVersion.js +4 -0
- package/lib/module/constants/packageVersion.js.map +1 -0
- package/lib/module/hooks/useCactusLM.js +238 -0
- package/lib/module/hooks/useCactusLM.js.map +1 -0
- package/lib/module/index.js +9 -409
- package/lib/module/index.js.map +1 -1
- package/lib/module/native/Cactus.js +50 -0
- package/lib/module/native/Cactus.js.map +1 -0
- package/lib/module/native/CactusCrypto.js +10 -0
- package/lib/module/native/CactusCrypto.js.map +1 -0
- package/lib/module/native/CactusDeviceInfo.js +13 -0
- package/lib/module/native/CactusDeviceInfo.js.map +1 -0
- package/lib/module/native/CactusFileSystem.js +35 -0
- package/lib/module/native/CactusFileSystem.js.map +1 -0
- package/lib/module/native/CactusUtil.js +23 -0
- package/lib/module/native/CactusUtil.js.map +1 -0
- package/lib/module/native/index.js +8 -0
- package/lib/module/native/index.js.map +1 -0
- package/lib/module/specs/Cactus.nitro.js +4 -0
- package/lib/module/specs/Cactus.nitro.js.map +1 -0
- package/lib/module/specs/CactusCrypto.nitro.js +4 -0
- package/lib/module/specs/CactusCrypto.nitro.js.map +1 -0
- package/lib/module/specs/CactusDeviceInfo.nitro.js +4 -0
- package/lib/module/specs/CactusDeviceInfo.nitro.js.map +1 -0
- package/lib/module/specs/CactusFileSystem.nitro.js +4 -0
- package/lib/module/specs/CactusFileSystem.nitro.js.map +1 -0
- package/lib/module/specs/CactusUtil.nitro.js +4 -0
- package/lib/module/specs/CactusUtil.nitro.js.map +1 -0
- package/lib/module/telemetry/Telemetry.js +100 -0
- package/lib/module/telemetry/Telemetry.js.map +1 -0
- package/lib/module/types/CactusLM.js +2 -0
- package/lib/module/types/CactusLM.js.map +1 -0
- package/lib/module/types/CactusModel.js +2 -0
- package/lib/module/types/CactusModel.js.map +1 -0
- package/lib/module/utils/error.js +4 -0
- package/lib/module/utils/error.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/api/Database.d.ts +11 -0
- package/lib/typescript/src/api/Database.d.ts.map +1 -0
- package/lib/typescript/src/classes/CactusLM.d.ts +26 -0
- package/lib/typescript/src/classes/CactusLM.d.ts.map +1 -0
- package/lib/typescript/src/config/CactusConfig.d.ts +5 -0
- package/lib/typescript/src/config/CactusConfig.d.ts.map +1 -0
- package/lib/typescript/src/constants/packageVersion.d.ts +2 -0
- package/lib/typescript/src/constants/packageVersion.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useCactusLM.d.ts +20 -0
- package/lib/typescript/src/hooks/useCactusLM.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +6 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/native/Cactus.d.ts +11 -0
- package/lib/typescript/src/native/Cactus.d.ts.map +1 -0
- package/lib/typescript/src/native/CactusCrypto.d.ts +5 -0
- package/lib/typescript/src/native/CactusCrypto.d.ts.map +1 -0
- package/lib/typescript/src/native/CactusDeviceInfo.d.ts +7 -0
- package/lib/typescript/src/native/CactusDeviceInfo.d.ts.map +1 -0
- package/lib/typescript/src/native/CactusFileSystem.d.ts +13 -0
- package/lib/typescript/src/native/CactusFileSystem.d.ts.map +1 -0
- package/lib/typescript/src/native/CactusUtil.d.ts +6 -0
- package/lib/typescript/src/native/CactusUtil.d.ts.map +1 -0
- package/lib/typescript/src/native/index.d.ts +6 -0
- package/lib/typescript/src/native/index.d.ts.map +1 -0
- package/lib/typescript/src/specs/Cactus.nitro.d.ts +13 -0
- package/lib/typescript/src/specs/Cactus.nitro.d.ts.map +1 -0
- package/lib/typescript/src/specs/CactusCrypto.nitro.d.ts +8 -0
- package/lib/typescript/src/specs/CactusCrypto.nitro.d.ts.map +1 -0
- package/lib/typescript/src/specs/CactusDeviceInfo.nitro.d.ts +16 -0
- package/lib/typescript/src/specs/CactusDeviceInfo.nitro.d.ts.map +1 -0
- package/lib/typescript/src/specs/CactusFileSystem.nitro.d.ts +16 -0
- package/lib/typescript/src/specs/CactusFileSystem.nitro.d.ts.map +1 -0
- package/lib/typescript/src/specs/CactusUtil.nitro.d.ts +10 -0
- package/lib/typescript/src/specs/CactusUtil.nitro.d.ts.map +1 -0
- package/lib/typescript/src/telemetry/Telemetry.d.ts +30 -0
- package/lib/typescript/src/telemetry/Telemetry.d.ts.map +1 -0
- package/lib/typescript/src/types/CactusLM.d.ts +67 -0
- package/lib/typescript/src/types/CactusLM.d.ts.map +1 -0
- package/lib/typescript/src/types/CactusModel.d.ts +12 -0
- package/lib/typescript/src/types/CactusModel.d.ts.map +1 -0
- package/lib/typescript/src/utils/error.d.ts +2 -0
- package/lib/typescript/src/utils/error.d.ts.map +1 -0
- package/nitro.json +31 -0
- package/nitrogen/generated/android/c++/JDeviceInfo.hpp +74 -0
- package/nitrogen/generated/android/c++/JFunc_void_double.hpp +74 -0
- package/nitrogen/generated/android/c++/JHybridCactusCryptoSpec.cpp +65 -0
- package/nitrogen/generated/android/c++/JHybridCactusCryptoSpec.hpp +65 -0
- package/nitrogen/generated/android/c++/JHybridCactusDeviceInfoSpec.cpp +85 -0
- package/nitrogen/generated/android/c++/JHybridCactusDeviceInfoSpec.hpp +66 -0
- package/nitrogen/generated/android/c++/JHybridCactusFileSystemSpec.cpp +192 -0
- package/nitrogen/generated/android/c++/JHybridCactusFileSystemSpec.hpp +73 -0
- package/nitrogen/generated/android/cactus+autolinking.cmake +87 -0
- package/nitrogen/generated/android/cactus+autolinking.gradle +27 -0
- package/nitrogen/generated/android/cactusOnLoad.cpp +86 -0
- package/nitrogen/generated/android/cactusOnLoad.hpp +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/DeviceInfo.kt +50 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/Func_void_double.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/HybridCactusCryptoSpec.kt +58 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/HybridCactusDeviceInfoSpec.kt +62 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/HybridCactusFileSystemSpec.kt +95 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/cactusOnLoad.kt +35 -0
- package/nitrogen/generated/ios/Cactus+autolinking.rb +60 -0
- package/nitrogen/generated/ios/Cactus-Swift-Cxx-Bridge.cpp +122 -0
- package/nitrogen/generated/ios/Cactus-Swift-Cxx-Bridge.hpp +373 -0
- package/nitrogen/generated/ios/Cactus-Swift-Cxx-Umbrella.hpp +60 -0
- package/nitrogen/generated/ios/CactusAutolinking.mm +69 -0
- package/nitrogen/generated/ios/CactusAutolinking.swift +55 -0
- package/nitrogen/generated/ios/c++/HybridCactusCryptoSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridCactusCryptoSpecSwift.hpp +77 -0
- package/nitrogen/generated/ios/c++/HybridCactusDeviceInfoSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridCactusDeviceInfoSpecSwift.hpp +88 -0
- package/nitrogen/generated/ios/c++/HybridCactusFileSystemSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridCactusFileSystemSpecSwift.hpp +143 -0
- package/nitrogen/generated/ios/swift/DeviceInfo.swift +98 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_DeviceInfo.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_double.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__optional_std__string_.swift +54 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridCactusCryptoSpec.swift +57 -0
- package/nitrogen/generated/ios/swift/HybridCactusCryptoSpec_cxx.swift +139 -0
- package/nitrogen/generated/ios/swift/HybridCactusDeviceInfoSpec.swift +58 -0
- package/nitrogen/generated/ios/swift/HybridCactusDeviceInfoSpec_cxx.swift +164 -0
- package/nitrogen/generated/ios/swift/HybridCactusFileSystemSpec.swift +65 -0
- package/nitrogen/generated/ios/swift/HybridCactusFileSystemSpec_cxx.swift +303 -0
- package/nitrogen/generated/shared/c++/DeviceInfo.hpp +92 -0
- package/nitrogen/generated/shared/c++/HybridCactusCryptoSpec.cpp +21 -0
- package/nitrogen/generated/shared/c++/HybridCactusCryptoSpec.hpp +63 -0
- package/nitrogen/generated/shared/c++/HybridCactusDeviceInfoSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridCactusDeviceInfoSpec.hpp +67 -0
- package/nitrogen/generated/shared/c++/HybridCactusFileSystemSpec.cpp +29 -0
- package/nitrogen/generated/shared/c++/HybridCactusFileSystemSpec.hpp +73 -0
- package/nitrogen/generated/shared/c++/HybridCactusSpec.cpp +26 -0
- package/nitrogen/generated/shared/c++/HybridCactusSpec.hpp +71 -0
- package/nitrogen/generated/shared/c++/HybridCactusUtilSpec.cpp +23 -0
- package/nitrogen/generated/shared/c++/HybridCactusUtilSpec.hpp +66 -0
- package/package.json +84 -143
- package/src/api/Database.ts +83 -0
- package/src/classes/CactusLM.ts +205 -0
- package/src/config/CactusConfig.ts +4 -0
- package/src/constants/packageVersion.ts +1 -0
- package/src/hooks/useCactusLM.ts +285 -0
- package/src/index.tsx +23 -0
- package/src/native/Cactus.ts +83 -0
- package/src/native/CactusCrypto.ts +11 -0
- package/src/native/CactusDeviceInfo.ts +18 -0
- package/src/native/CactusFileSystem.ts +47 -0
- package/src/native/CactusUtil.ts +27 -0
- package/src/native/index.ts +5 -0
- package/src/specs/Cactus.nitro.ts +20 -0
- package/src/specs/CactusCrypto.nitro.ts +6 -0
- package/src/specs/CactusDeviceInfo.nitro.ts +15 -0
- package/src/specs/CactusFileSystem.nitro.ts +21 -0
- package/src/specs/CactusUtil.nitro.ts +8 -0
- package/src/telemetry/Telemetry.ts +159 -0
- package/src/types/CactusLM.ts +73 -0
- package/src/types/CactusModel.ts +14 -0
- package/src/utils/error.ts +2 -0
- package/LICENSE.txt +0 -20
- package/android/src/main/CMakeLists.txt +0 -140
- package/android/src/main/java/com/cactus/Cactus.java +0 -1190
- package/android/src/main/java/com/cactus/CactusPackage.java +0 -48
- package/android/src/main/java/com/cactus/LlamaContext.java +0 -748
- package/android/src/main/jni-utils.h +0 -100
- package/android/src/main/jni.cpp +0 -1605
- package/android/src/main/jniLibs/arm64-v8a/libcactus.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libcactus_v8_2.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libcactus_v8_2_dotprod.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libcactus_v8_2_dotprod_i8mm.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libcactus_v8_2_i8mm.so +0 -0
- package/android/src/newarch/java/com/cactus/CactusModule.java +0 -204
- package/android/src/oldarch/java/com/cactus/CactusModule.java +0 -205
- package/cactus-react-native.podspec +0 -42
- package/ios/CMakeLists.txt +0 -131
- package/ios/Cactus.h +0 -6
- package/ios/Cactus.mm +0 -681
- package/ios/CactusContext.h +0 -81
- package/ios/CactusContext.mm +0 -1032
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/chat.h +0 -145
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/common.h +0 -674
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-alloc.h +0 -76
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-backend-impl.h +0 -255
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-backend.h +0 -354
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-common.h +0 -1857
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-cpp.h +0 -39
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-cpu.h +0 -143
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-impl.h +0 -601
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-metal-impl.h +0 -622
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-metal.h +0 -66
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-opt.h +0 -237
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-quants.h +0 -100
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-threading.h +0 -14
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml.h +0 -2202
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/gguf.h +0 -202
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/json-schema-to-grammar.h +0 -21
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/json.hpp +0 -24766
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-adapter.h +0 -76
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-arch.h +0 -437
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-batch.h +0 -89
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-chat.h +0 -58
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-context.h +0 -276
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-cparams.h +0 -39
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-cpp.h +0 -30
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-grammar.h +0 -173
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-graph.h +0 -640
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-hparams.h +0 -190
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-impl.h +0 -61
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-io.h +0 -35
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-kv-cache.h +0 -515
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-memory.h +0 -32
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-mmap.h +0 -68
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-model-loader.h +0 -169
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-model-saver.h +0 -37
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-model.h +0 -425
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-sampling.h +0 -32
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-vocab.h +0 -131
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama.h +0 -1376
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/log.h +0 -103
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/minja/chat-template.hpp +0 -542
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/minja/minja.hpp +0 -2974
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/sampling.h +0 -107
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/unicode-data.h +0 -20
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/unicode.h +0 -66
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/ggml-llama.metallib +0 -0
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/cactus.h +0 -232
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/cactus_ffi.h +0 -256
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/chat.h +0 -145
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/common.h +0 -674
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-alloc.h +0 -76
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-backend-impl.h +0 -255
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-backend.h +0 -354
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-common.h +0 -1857
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-cpp.h +0 -39
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-cpu.h +0 -143
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-impl.h +0 -601
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-metal-impl.h +0 -622
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-metal.h +0 -66
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-opt.h +0 -237
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-quants.h +0 -100
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-threading.h +0 -14
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml.h +0 -2202
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/gguf.h +0 -202
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/json-schema-to-grammar.h +0 -21
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/json.hpp +0 -24766
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-adapter.h +0 -76
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-arch.h +0 -437
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-batch.h +0 -89
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-chat.h +0 -58
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-context.h +0 -276
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-cparams.h +0 -39
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-cpp.h +0 -30
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-grammar.h +0 -173
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-graph.h +0 -640
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-hparams.h +0 -190
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-impl.h +0 -61
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-io.h +0 -35
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-kv-cache.h +0 -515
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-memory.h +0 -32
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-mmap.h +0 -68
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-model-loader.h +0 -169
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-model-saver.h +0 -37
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-model.h +0 -425
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-sampling.h +0 -32
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-vocab.h +0 -131
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama.h +0 -1376
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/log.h +0 -103
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/minja/chat-template.hpp +0 -542
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/minja/minja.hpp +0 -2974
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/sampling.h +0 -107
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/unicode-data.h +0 -20
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/unicode.h +0 -66
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/cactus +0 -0
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/ggml-llama-sim.metallib +0 -0
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/cactus.h +0 -232
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/cactus_ffi.h +0 -256
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/chat.h +0 -145
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/common.h +0 -674
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-alloc.h +0 -76
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-backend-impl.h +0 -255
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-backend.h +0 -354
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-common.h +0 -1857
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-cpp.h +0 -39
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-cpu.h +0 -143
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-impl.h +0 -601
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-metal-impl.h +0 -622
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-metal.h +0 -66
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-opt.h +0 -237
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-quants.h +0 -100
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-threading.h +0 -14
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml.h +0 -2202
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/gguf.h +0 -202
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/json-schema-to-grammar.h +0 -21
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/json.hpp +0 -24766
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-adapter.h +0 -76
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-arch.h +0 -437
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-batch.h +0 -89
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-chat.h +0 -58
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-context.h +0 -276
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-cparams.h +0 -39
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-cpp.h +0 -30
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-grammar.h +0 -173
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-graph.h +0 -640
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-hparams.h +0 -190
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-impl.h +0 -61
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-io.h +0 -35
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-kv-cache.h +0 -515
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-memory.h +0 -32
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-mmap.h +0 -68
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-model-loader.h +0 -169
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-model-saver.h +0 -37
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-model.h +0 -425
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-sampling.h +0 -32
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-vocab.h +0 -131
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama.h +0 -1376
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/log.h +0 -103
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/minja/chat-template.hpp +0 -542
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/minja/minja.hpp +0 -2974
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/sampling.h +0 -107
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/unicode-data.h +0 -20
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/unicode.h +0 -66
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Info.plist +0 -0
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/cactus +0 -0
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/ggml-llama.metallib +0 -0
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/cactus.h +0 -232
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/cactus_ffi.h +0 -256
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/chat.h +0 -145
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/common.h +0 -674
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-alloc.h +0 -76
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-backend-impl.h +0 -255
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-backend.h +0 -354
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-common.h +0 -1857
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-cpp.h +0 -39
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-cpu.h +0 -143
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-impl.h +0 -601
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-metal-impl.h +0 -622
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-metal.h +0 -66
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-opt.h +0 -237
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-quants.h +0 -100
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-threading.h +0 -14
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml.h +0 -2202
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/gguf.h +0 -202
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/json-schema-to-grammar.h +0 -21
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/json.hpp +0 -24766
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-adapter.h +0 -76
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-arch.h +0 -437
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-batch.h +0 -89
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-chat.h +0 -58
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-context.h +0 -276
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-cparams.h +0 -39
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-cpp.h +0 -30
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-grammar.h +0 -173
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-graph.h +0 -640
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-hparams.h +0 -190
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-impl.h +0 -61
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-io.h +0 -35
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-kv-cache.h +0 -515
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-memory.h +0 -32
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-mmap.h +0 -68
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-model-loader.h +0 -169
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-model-saver.h +0 -37
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-model.h +0 -425
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-sampling.h +0 -32
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-vocab.h +0 -131
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama.h +0 -1376
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/log.h +0 -103
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/minja/chat-template.hpp +0 -542
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/minja/minja.hpp +0 -2974
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/sampling.h +0 -107
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/unicode-data.h +0 -20
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/unicode.h +0 -66
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Info.plist +0 -0
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/cactus +0 -0
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/ggml-llama-sim.metallib +0 -0
- package/lib/commonjs/NativeCactus.js +0 -9
- package/lib/commonjs/NativeCactus.js.map +0 -1
- package/lib/commonjs/agent.js +0 -73
- package/lib/commonjs/agent.js.map +0 -1
- package/lib/commonjs/chat.js +0 -73
- package/lib/commonjs/chat.js.map +0 -1
- package/lib/commonjs/index.js +0 -523
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/lm.js +0 -272
- package/lib/commonjs/lm.js.map +0 -1
- package/lib/commonjs/package.json +0 -1
- package/lib/commonjs/projectId.js +0 -9
- package/lib/commonjs/projectId.js.map +0 -1
- package/lib/commonjs/remote.js +0 -100
- package/lib/commonjs/remote.js.map +0 -1
- package/lib/commonjs/telemetry.js +0 -102
- package/lib/commonjs/telemetry.js.map +0 -1
- package/lib/commonjs/tools.js +0 -72
- package/lib/commonjs/tools.js.map +0 -1
- package/lib/commonjs/tts.js +0 -141
- package/lib/commonjs/tts.js.map +0 -1
- package/lib/commonjs/vlm.js +0 -221
- package/lib/commonjs/vlm.js.map +0 -1
- package/lib/module/NativeCactus.js +0 -5
- package/lib/module/NativeCactus.js.map +0 -1
- package/lib/module/agent.js +0 -68
- package/lib/module/agent.js.map +0 -1
- package/lib/module/chat.js +0 -67
- package/lib/module/chat.js.map +0 -1
- package/lib/module/lm.js +0 -267
- package/lib/module/lm.js.map +0 -1
- package/lib/module/projectId.js +0 -5
- package/lib/module/projectId.js.map +0 -1
- package/lib/module/remote.js +0 -91
- package/lib/module/remote.js.map +0 -1
- package/lib/module/telemetry.js +0 -97
- package/lib/module/telemetry.js.map +0 -1
- package/lib/module/tools.js +0 -66
- package/lib/module/tools.js.map +0 -1
- package/lib/module/tts.js +0 -135
- package/lib/module/tts.js.map +0 -1
- package/lib/module/vlm.js +0 -216
- package/lib/module/vlm.js.map +0 -1
- package/lib/typescript/NativeCactus.d.ts +0 -252
- package/lib/typescript/NativeCactus.d.ts.map +0 -1
- package/lib/typescript/agent.d.ts +0 -31
- package/lib/typescript/agent.d.ts.map +0 -1
- package/lib/typescript/chat.d.ts +0 -23
- package/lib/typescript/chat.d.ts.map +0 -1
- package/lib/typescript/index.d.ts +0 -114
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/lm.d.ts +0 -36
- package/lib/typescript/lm.d.ts.map +0 -1
- package/lib/typescript/projectId.d.ts +0 -2
- package/lib/typescript/projectId.d.ts.map +0 -1
- package/lib/typescript/remote.d.ts +0 -8
- package/lib/typescript/remote.d.ts.map +0 -1
- package/lib/typescript/telemetry.d.ts +0 -25
- package/lib/typescript/telemetry.d.ts.map +0 -1
- package/lib/typescript/tools.d.ts +0 -36
- package/lib/typescript/tools.d.ts.map +0 -1
- package/lib/typescript/tts.d.ts +0 -54
- package/lib/typescript/tts.d.ts.map +0 -1
- package/lib/typescript/vlm.d.ts +0 -33
- package/lib/typescript/vlm.d.ts.map +0 -1
- package/scripts/postInstall.js +0 -33
- package/src/NativeCactus.ts +0 -317
- package/src/agent.ts +0 -112
- package/src/chat.ts +0 -91
- package/src/index.ts +0 -663
- package/src/lm.ts +0 -324
- package/src/projectId.ts +0 -1
- package/src/remote.ts +0 -113
- package/src/telemetry.ts +0 -137
- package/src/tools.ts +0 -94
- package/src/tts.ts +0 -236
- package/src/vlm.ts +0 -276
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
#ifndef KERNEL_UTILS_H
|
|
2
|
+
#define KERNEL_UTILS_H
|
|
3
|
+
|
|
4
|
+
#include <arm_neon.h>
|
|
5
|
+
#include <algorithm>
|
|
6
|
+
#include <cmath>
|
|
7
|
+
#include <thread>
|
|
8
|
+
#include <vector>
|
|
9
|
+
#include <functional>
|
|
10
|
+
#include <queue>
|
|
11
|
+
#include <mutex>
|
|
12
|
+
#include <condition_variable>
|
|
13
|
+
#include <atomic>
|
|
14
|
+
#include <future>
|
|
15
|
+
#include <unistd.h>
|
|
16
|
+
#include <unordered_map>
|
|
17
|
+
#include <chrono>
|
|
18
|
+
#include <string>
|
|
19
|
+
#include <cstdio>
|
|
20
|
+
|
|
21
|
+
constexpr size_t NEON_VECTOR_SIZE = 16;
|
|
22
|
+
|
|
23
|
+
inline int8_t clamp_to_int8(float value) {
|
|
24
|
+
int32_t clamped = static_cast<int32_t>(roundf(value));
|
|
25
|
+
return static_cast<int8_t>(std::max(-128, std::min(127, clamped)));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
inline int8_t clamp_to_int8(int32_t value) {
|
|
29
|
+
return static_cast<int8_t>(std::max(-128, std::min(127, value)));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
#if defined(__ARM_FEATURE_DOTPROD)
|
|
33
|
+
inline int32x4_t accum_i8mm(int32x4_t acc, int8x16_t a, int8x16_t b) {
|
|
34
|
+
return vdotq_s32(acc, a, b);
|
|
35
|
+
}
|
|
36
|
+
#else
|
|
37
|
+
inline int32x4_t accum_i8mm(int32x4_t acc, int8x16_t a, int8x16_t b) {
|
|
38
|
+
int16x8_t prod_low = vmull_s8(vget_low_s8(a), vget_low_s8(b));
|
|
39
|
+
int32x4_t acc_high = vpaddlq_s16(vmull_s8(vget_high_s8(a), vget_high_s8(b)));
|
|
40
|
+
return vaddq_s32(vaddq_s32(acc, vpaddlq_s16(prod_low)), acc_high);
|
|
41
|
+
}
|
|
42
|
+
#endif
|
|
43
|
+
|
|
44
|
+
inline float16x8_t accum_f16_dot(float16x8_t acc, float16x8_t a_low, float16x8_t a_high,
|
|
45
|
+
float16x8_t b_low, float16x8_t b_high) {
|
|
46
|
+
acc = vfmaq_f16(acc, a_low, b_low);
|
|
47
|
+
return vfmaq_f16(acc, a_high, b_high);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
inline float32x4_t accum_f32_dot(float32x4_t acc, float32x4_t a_low, float32x4_t a_high,
|
|
51
|
+
float32x4_t b_low, float32x4_t b_high) {
|
|
52
|
+
acc = vfmaq_f32(acc, a_low, b_low);
|
|
53
|
+
return vfmaq_f32(acc, a_high, b_high);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
namespace CactusThreading {
|
|
57
|
+
|
|
58
|
+
class ThreadPool {
|
|
59
|
+
private:
|
|
60
|
+
std::vector<std::thread> workers;
|
|
61
|
+
std::queue<std::function<void()>> tasks;
|
|
62
|
+
std::mutex queue_mutex;
|
|
63
|
+
std::condition_variable condition;
|
|
64
|
+
std::atomic<bool> stop{false};
|
|
65
|
+
std::atomic<size_t> active_workers{0};
|
|
66
|
+
std::condition_variable finish_condition;
|
|
67
|
+
|
|
68
|
+
void worker_thread() {
|
|
69
|
+
while (true) {
|
|
70
|
+
std::function<void()> task;
|
|
71
|
+
{
|
|
72
|
+
std::unique_lock<std::mutex> lock(queue_mutex);
|
|
73
|
+
condition.wait(lock, [this] { return stop || !tasks.empty(); });
|
|
74
|
+
|
|
75
|
+
if (stop && tasks.empty()) return;
|
|
76
|
+
|
|
77
|
+
task = std::move(tasks.front());
|
|
78
|
+
tasks.pop();
|
|
79
|
+
active_workers++;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
task();
|
|
83
|
+
|
|
84
|
+
active_workers--;
|
|
85
|
+
finish_condition.notify_all();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
public:
|
|
90
|
+
explicit ThreadPool(size_t num_threads = std::thread::hardware_concurrency()) {
|
|
91
|
+
workers.reserve(num_threads);
|
|
92
|
+
for (size_t i = 0; i < num_threads; ++i) {
|
|
93
|
+
workers.emplace_back(&ThreadPool::worker_thread, this);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
~ThreadPool() {
|
|
98
|
+
{
|
|
99
|
+
std::unique_lock<std::mutex> lock(queue_mutex);
|
|
100
|
+
stop = true;
|
|
101
|
+
}
|
|
102
|
+
condition.notify_all();
|
|
103
|
+
for (auto& worker : workers) {
|
|
104
|
+
worker.join();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
template<typename F>
|
|
109
|
+
auto enqueue(F&& f) -> std::future<decltype(f())> {
|
|
110
|
+
using return_type = decltype(f());
|
|
111
|
+
|
|
112
|
+
auto task = std::make_shared<std::packaged_task<return_type()>>(
|
|
113
|
+
std::forward<F>(f)
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
std::future<return_type> res = task->get_future();
|
|
117
|
+
{
|
|
118
|
+
std::unique_lock<std::mutex> lock(queue_mutex);
|
|
119
|
+
if (stop) throw std::runtime_error("enqueue on stopped ThreadPool");
|
|
120
|
+
|
|
121
|
+
tasks.emplace([task](){ (*task)(); });
|
|
122
|
+
}
|
|
123
|
+
condition.notify_one();
|
|
124
|
+
return res;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
void wait_all() {
|
|
128
|
+
std::unique_lock<std::mutex> lock(queue_mutex);
|
|
129
|
+
finish_condition.wait(lock, [this] {
|
|
130
|
+
return tasks.empty() && active_workers == 0;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
size_t num_workers() const { return workers.size(); }
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
inline ThreadPool& get_thread_pool() {
|
|
138
|
+
static ThreadPool pool;
|
|
139
|
+
return pool;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
inline size_t get_optimal_thread_count(size_t total_work, size_t min_work_per_thread) {
|
|
143
|
+
if (total_work < min_work_per_thread) return 1;
|
|
144
|
+
size_t pool_size = get_thread_pool().num_workers();
|
|
145
|
+
return std::min(pool_size,
|
|
146
|
+
std::max(static_cast<size_t>(1), total_work / min_work_per_thread));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
struct Thresholds {
|
|
150
|
+
|
|
151
|
+
#if defined(__ANDROID__)
|
|
152
|
+
static constexpr size_t ELEMENT_WISE = 5000;
|
|
153
|
+
static constexpr size_t AXIS_REDUCE = 1000;
|
|
154
|
+
static constexpr size_t ALL_REDUCE = 10000;
|
|
155
|
+
static constexpr size_t SCALAR_BASIC = 30000;
|
|
156
|
+
static constexpr size_t SCALAR_EXPENSIVE = 10000;
|
|
157
|
+
static constexpr size_t ATTENTION = 512;
|
|
158
|
+
static constexpr size_t GEMM_TILED = 20000;
|
|
159
|
+
static constexpr size_t GEMM_SMALL = 64 * 64 * 64;
|
|
160
|
+
static constexpr size_t GEMM_MEDIUM = 256 * 256 * 256;
|
|
161
|
+
static constexpr size_t GEMM_TILE_M = 64;
|
|
162
|
+
static constexpr size_t GEMM_TILE_N = 64;
|
|
163
|
+
static constexpr size_t GEMM_TILE_M_SMALL = 32;
|
|
164
|
+
static constexpr size_t GEMM_TILE_N_SMALL = 32;
|
|
165
|
+
#else // iOS
|
|
166
|
+
static constexpr size_t ELEMENT_WISE = 5000;
|
|
167
|
+
static constexpr size_t AXIS_REDUCE = 1000;
|
|
168
|
+
static constexpr size_t ALL_REDUCE = 10000;
|
|
169
|
+
static constexpr size_t SCALAR_BASIC = 5000;
|
|
170
|
+
static constexpr size_t SCALAR_EXPENSIVE = 2500;
|
|
171
|
+
static constexpr size_t ATTENTION = 4;
|
|
172
|
+
static constexpr size_t GEMM_TILED = 4;
|
|
173
|
+
static constexpr size_t GEMM_SMALL = 64 * 64 * 64;
|
|
174
|
+
static constexpr size_t GEMM_MEDIUM = 256 * 256 * 256;
|
|
175
|
+
static constexpr size_t GEMM_TILE_M = 64;
|
|
176
|
+
static constexpr size_t GEMM_TILE_N = 64;
|
|
177
|
+
static constexpr size_t GEMM_TILE_M_SMALL = 32;
|
|
178
|
+
static constexpr size_t GEMM_TILE_N_SMALL = 32;
|
|
179
|
+
#endif
|
|
180
|
+
static constexpr size_t L2_CACHE_SIZE = 256 * 1024;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
class TaskHandle {
|
|
184
|
+
private:
|
|
185
|
+
std::vector<std::future<void>> futures_;
|
|
186
|
+
bool auto_wait_;
|
|
187
|
+
|
|
188
|
+
public:
|
|
189
|
+
TaskHandle(bool auto_wait = true) : auto_wait_(auto_wait) {}
|
|
190
|
+
|
|
191
|
+
~TaskHandle() {
|
|
192
|
+
if (auto_wait_) {
|
|
193
|
+
wait();
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
TaskHandle(TaskHandle&&) = default;
|
|
198
|
+
TaskHandle& operator=(TaskHandle&&) = default;
|
|
199
|
+
TaskHandle(const TaskHandle&) = delete;
|
|
200
|
+
TaskHandle& operator=(const TaskHandle&) = delete;
|
|
201
|
+
|
|
202
|
+
void add_future(std::future<void>&& f) {
|
|
203
|
+
futures_.push_back(std::move(f));
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
void wait() {
|
|
207
|
+
for (auto& f : futures_) {
|
|
208
|
+
if (f.valid()) {
|
|
209
|
+
f.wait();
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
futures_.clear();
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
bool is_ready() const {
|
|
216
|
+
for (const auto& f : futures_) {
|
|
217
|
+
if (f.valid() && f.wait_for(std::chrono::seconds(0)) != std::future_status::ready) {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return true;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
size_t task_count() const { return futures_.size(); }
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
template<typename WorkFunc>
|
|
228
|
+
TaskHandle parallel_for(size_t total_work, size_t threshold, WorkFunc work_func, bool wait = true) {
|
|
229
|
+
const size_t num_threads = get_optimal_thread_count(total_work, threshold);
|
|
230
|
+
TaskHandle handle(!wait);
|
|
231
|
+
|
|
232
|
+
if (num_threads == 1) {
|
|
233
|
+
if (wait) {
|
|
234
|
+
work_func(0, total_work);
|
|
235
|
+
return handle;
|
|
236
|
+
}
|
|
237
|
+
auto& pool = get_thread_pool();
|
|
238
|
+
handle.add_future(pool.enqueue([work_func, total_work]() {
|
|
239
|
+
work_func(0, total_work);
|
|
240
|
+
}));
|
|
241
|
+
return handle;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
auto& pool = get_thread_pool();
|
|
245
|
+
const size_t work_per_thread = total_work / num_threads;
|
|
246
|
+
|
|
247
|
+
for (size_t t = 0; t < num_threads; ++t) {
|
|
248
|
+
handle.add_future(pool.enqueue([work_func, t, num_threads, work_per_thread, total_work]() {
|
|
249
|
+
const size_t start_idx = t * work_per_thread;
|
|
250
|
+
const size_t end_idx = (t == num_threads - 1) ? total_work : (t + 1) * work_per_thread;
|
|
251
|
+
work_func(start_idx, end_idx);
|
|
252
|
+
}));
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (wait) {
|
|
256
|
+
handle.wait();
|
|
257
|
+
}
|
|
258
|
+
return handle;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
template<typename WorkFunc>
|
|
262
|
+
void parallel_for_2d(size_t outer_size, size_t inner_size, size_t threshold, WorkFunc work_func) {
|
|
263
|
+
const size_t total_work = outer_size * inner_size;
|
|
264
|
+
parallel_for(total_work, threshold, [&](size_t start_idx, size_t end_idx) {
|
|
265
|
+
for (size_t work_idx = start_idx; work_idx < end_idx; ++work_idx) {
|
|
266
|
+
const size_t outer = work_idx / inner_size;
|
|
267
|
+
const size_t inner = work_idx % inner_size;
|
|
268
|
+
work_func(outer, inner);
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
template<typename WorkFunc, typename ResultType, typename CombineFunc>
|
|
274
|
+
ResultType parallel_reduce(size_t total_work, size_t threshold,
|
|
275
|
+
WorkFunc work_func, ResultType init_value, CombineFunc combine_func) {
|
|
276
|
+
const size_t num_threads = get_optimal_thread_count(total_work, threshold);
|
|
277
|
+
|
|
278
|
+
if (num_threads == 1) {
|
|
279
|
+
return work_func(0, total_work);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
auto& pool = get_thread_pool();
|
|
283
|
+
std::vector<std::future<ResultType>> futures;
|
|
284
|
+
std::vector<ResultType> partial_results(num_threads, init_value);
|
|
285
|
+
const size_t work_per_thread = total_work / num_threads;
|
|
286
|
+
|
|
287
|
+
for (size_t t = 0; t < num_threads; ++t) {
|
|
288
|
+
futures.push_back(pool.enqueue([work_func, t, num_threads, work_per_thread, total_work]() -> ResultType {
|
|
289
|
+
const size_t start_idx = t * work_per_thread;
|
|
290
|
+
const size_t end_idx = (t == num_threads - 1) ? total_work : (t + 1) * work_per_thread;
|
|
291
|
+
return work_func(start_idx, end_idx);
|
|
292
|
+
}));
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
ResultType result = init_value;
|
|
296
|
+
for (auto& future : futures) {
|
|
297
|
+
result = combine_func(result, future.get());
|
|
298
|
+
}
|
|
299
|
+
return result;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
inline size_t compute_gemm_parallelism(size_t M, size_t K, size_t N, size_t element_size) {
|
|
303
|
+
size_t total_ops = M * K * N;
|
|
304
|
+
|
|
305
|
+
if (total_ops < Thresholds::GEMM_SMALL) return 1;
|
|
306
|
+
|
|
307
|
+
if (total_ops < Thresholds::GEMM_MEDIUM) {
|
|
308
|
+
return std::min(static_cast<size_t>(2), get_thread_pool().num_workers());
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
size_t bytes_accessed = (M * K + K * N + M * N) * element_size;
|
|
312
|
+
size_t cache_tiles = (bytes_accessed + Thresholds::L2_CACHE_SIZE - 1) / Thresholds::L2_CACHE_SIZE;
|
|
313
|
+
|
|
314
|
+
size_t compute_threads = std::sqrt(static_cast<double>(total_ops) / Thresholds::GEMM_SMALL);
|
|
315
|
+
size_t memory_threads = cache_tiles;
|
|
316
|
+
|
|
317
|
+
size_t optimal = std::min(compute_threads, memory_threads);
|
|
318
|
+
return std::min(optimal, get_thread_pool().num_workers());
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
template<typename WorkFunc>
|
|
322
|
+
void parallel_for_2d_tiled(size_t rows, size_t cols, size_t tile_rows, size_t tile_cols, WorkFunc work_func) {
|
|
323
|
+
size_t num_row_tiles = (rows + tile_rows - 1) / tile_rows;
|
|
324
|
+
size_t num_col_tiles = (cols + tile_cols - 1) / tile_cols;
|
|
325
|
+
size_t total_tiles = num_row_tiles * num_col_tiles;
|
|
326
|
+
|
|
327
|
+
parallel_for(total_tiles, Thresholds::GEMM_TILED, [=](size_t start_tile, size_t end_tile) {
|
|
328
|
+
for (size_t tile_idx = start_tile; tile_idx < end_tile; ++tile_idx) {
|
|
329
|
+
size_t tile_row = tile_idx / num_col_tiles;
|
|
330
|
+
size_t tile_col = tile_idx % num_col_tiles;
|
|
331
|
+
|
|
332
|
+
size_t row_start = tile_row * tile_rows;
|
|
333
|
+
size_t row_end = std::min(row_start + tile_rows, rows);
|
|
334
|
+
size_t col_start = tile_col * tile_cols;
|
|
335
|
+
size_t col_end = std::min(col_start + tile_cols, cols);
|
|
336
|
+
|
|
337
|
+
work_func(row_start, row_end, col_start, col_end);
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
#endif // KERNEL_UTILS_H
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>AvailableLibraries</key>
|
|
6
|
+
<array>
|
|
7
|
+
<dict>
|
|
8
|
+
<key>LibraryIdentifier</key>
|
|
9
|
+
<string>ios-arm64-simulator</string>
|
|
10
|
+
<key>LibraryPath</key>
|
|
11
|
+
<string>cactus_util.framework</string>
|
|
12
|
+
<key>SupportedArchitectures</key>
|
|
13
|
+
<array>
|
|
14
|
+
<string>arm64</string>
|
|
15
|
+
</array>
|
|
16
|
+
<key>SupportedPlatform</key>
|
|
17
|
+
<string>ios</string>
|
|
18
|
+
<key>SupportedPlatformVariant</key>
|
|
19
|
+
<string>simulator</string>
|
|
20
|
+
</dict>
|
|
21
|
+
<dict>
|
|
22
|
+
<key>LibraryIdentifier</key>
|
|
23
|
+
<string>ios-arm64</string>
|
|
24
|
+
<key>LibraryPath</key>
|
|
25
|
+
<string>cactus_util.framework</string>
|
|
26
|
+
<key>SupportedArchitectures</key>
|
|
27
|
+
<array>
|
|
28
|
+
<string>arm64</string>
|
|
29
|
+
</array>
|
|
30
|
+
<key>SupportedPlatform</key>
|
|
31
|
+
<string>ios</string>
|
|
32
|
+
</dict>
|
|
33
|
+
</array>
|
|
34
|
+
<key>CFBundlePackageType</key>
|
|
35
|
+
<string>XFWK</string>
|
|
36
|
+
<key>XCFrameworkFormatVersion</key>
|
|
37
|
+
<string>1.0</string>
|
|
38
|
+
</dict>
|
|
39
|
+
</plist>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#ifndef cactus_util_H
|
|
2
|
+
#define cactus_util_H
|
|
3
|
+
|
|
4
|
+
#ifdef __cplusplus
|
|
5
|
+
extern "C" {
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
const char* register_app(const char* encrypted_data);
|
|
9
|
+
|
|
10
|
+
const char* get_device_id();
|
|
11
|
+
|
|
12
|
+
// Helper function to free memory allocated by register_app
|
|
13
|
+
void free_string(const char* str);
|
|
14
|
+
|
|
15
|
+
#ifdef __ANDROID__
|
|
16
|
+
// Function to set the Android app data directory
|
|
17
|
+
// This should be called from Flutter/Java side before any other functions
|
|
18
|
+
void set_android_data_directory(const char* data_dir);
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
#ifdef __cplusplus
|
|
22
|
+
}
|
|
23
|
+
#endif
|
|
24
|
+
|
|
25
|
+
#endif
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#ifndef LOGGING_H
|
|
2
|
+
#define LOGGING_H
|
|
3
|
+
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
// Log levels
|
|
7
|
+
enum LogLevel {
|
|
8
|
+
LOG_DEBUG = 0,
|
|
9
|
+
LOG_INFO = 1,
|
|
10
|
+
LOG_WARNING = 2,
|
|
11
|
+
LOG_ERROR = 3
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// Cross-platform logging function
|
|
15
|
+
void cactus_log(LogLevel level, const char* tag, const char* message);
|
|
16
|
+
void cactus_log(LogLevel level, const char* tag, const std::string& message);
|
|
17
|
+
|
|
18
|
+
// Convenience macros
|
|
19
|
+
#define LOG_TAG "CactusUtil"
|
|
20
|
+
#define CACTUS_LOG_DEBUG(msg) cactus_log(LOG_DEBUG, LOG_TAG, msg)
|
|
21
|
+
#define CACTUS_LOG_INFO(msg) cactus_log(LOG_INFO, LOG_TAG, msg)
|
|
22
|
+
#define CACTUS_LOG_WARNING(msg) cactus_log(LOG_WARNING, LOG_TAG, msg)
|
|
23
|
+
#define CACTUS_LOG_ERROR(msg) cactus_log(LOG_ERROR, LOG_TAG, msg)
|
|
24
|
+
|
|
25
|
+
#endif
|
package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/cactus_util.h
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#ifndef cactus_util_H
|
|
2
|
+
#define cactus_util_H
|
|
3
|
+
|
|
4
|
+
#ifdef __cplusplus
|
|
5
|
+
extern "C" {
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
const char* register_app(const char* encrypted_data);
|
|
9
|
+
|
|
10
|
+
const char* get_device_id();
|
|
11
|
+
|
|
12
|
+
// Helper function to free memory allocated by register_app
|
|
13
|
+
void free_string(const char* str);
|
|
14
|
+
|
|
15
|
+
#ifdef __ANDROID__
|
|
16
|
+
// Function to set the Android app data directory
|
|
17
|
+
// This should be called from Flutter/Java side before any other functions
|
|
18
|
+
void set_android_data_directory(const char* data_dir);
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
#ifdef __cplusplus
|
|
22
|
+
}
|
|
23
|
+
#endif
|
|
24
|
+
|
|
25
|
+
#endif
|
package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/logging.h
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#ifndef LOGGING_H
|
|
2
|
+
#define LOGGING_H
|
|
3
|
+
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
// Log levels
|
|
7
|
+
enum LogLevel {
|
|
8
|
+
LOG_DEBUG = 0,
|
|
9
|
+
LOG_INFO = 1,
|
|
10
|
+
LOG_WARNING = 2,
|
|
11
|
+
LOG_ERROR = 3
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// Cross-platform logging function
|
|
15
|
+
void cactus_log(LogLevel level, const char* tag, const char* message);
|
|
16
|
+
void cactus_log(LogLevel level, const char* tag, const std::string& message);
|
|
17
|
+
|
|
18
|
+
// Convenience macros
|
|
19
|
+
#define LOG_TAG "CactusUtil"
|
|
20
|
+
#define CACTUS_LOG_DEBUG(msg) cactus_log(LOG_DEBUG, LOG_TAG, msg)
|
|
21
|
+
#define CACTUS_LOG_INFO(msg) cactus_log(LOG_INFO, LOG_TAG, msg)
|
|
22
|
+
#define CACTUS_LOG_WARNING(msg) cactus_log(LOG_WARNING, LOG_TAG, msg)
|
|
23
|
+
#define CACTUS_LOG_ERROR(msg) cactus_log(LOG_ERROR, LOG_TAG, msg)
|
|
24
|
+
|
|
25
|
+
#endif
|
|
Binary file
|
|
@@ -4,13 +4,47 @@
|
|
|
4
4
|
<dict>
|
|
5
5
|
<key>files</key>
|
|
6
6
|
<dict>
|
|
7
|
+
<key>Headers/cactus_util.h</key>
|
|
8
|
+
<data>
|
|
9
|
+
7z1Ts4xufXPrnEBuKu+NppO1yKg=
|
|
10
|
+
</data>
|
|
11
|
+
<key>Headers/ios_utils.h</key>
|
|
12
|
+
<data>
|
|
13
|
+
DxZ6AL6QIFsgYUKBGkaAndkY1Ew=
|
|
14
|
+
</data>
|
|
15
|
+
<key>Headers/logging.h</key>
|
|
16
|
+
<data>
|
|
17
|
+
m5MdwrQVZglUAv3NSffShqQTwqE=
|
|
18
|
+
</data>
|
|
7
19
|
<key>Info.plist</key>
|
|
8
20
|
<data>
|
|
9
|
-
|
|
21
|
+
OhVLqBjBr8wHfc8V3KCR4rpni5U=
|
|
10
22
|
</data>
|
|
11
23
|
</dict>
|
|
12
24
|
<key>files2</key>
|
|
13
|
-
<dict
|
|
25
|
+
<dict>
|
|
26
|
+
<key>Headers/cactus_util.h</key>
|
|
27
|
+
<dict>
|
|
28
|
+
<key>hash2</key>
|
|
29
|
+
<data>
|
|
30
|
+
mIHS5tpbAc2yQnCfoYds/waoVwabQF9bYng+EYTSSrg=
|
|
31
|
+
</data>
|
|
32
|
+
</dict>
|
|
33
|
+
<key>Headers/ios_utils.h</key>
|
|
34
|
+
<dict>
|
|
35
|
+
<key>hash2</key>
|
|
36
|
+
<data>
|
|
37
|
+
edmm6ZYsnfjlwb1IJ40iJ7zwVnZZrO91p++TgoSO9ig=
|
|
38
|
+
</data>
|
|
39
|
+
</dict>
|
|
40
|
+
<key>Headers/logging.h</key>
|
|
41
|
+
<dict>
|
|
42
|
+
<key>hash2</key>
|
|
43
|
+
<data>
|
|
44
|
+
YpnrA639xaUs3HHamW6aBrNfc58sEqAIKKxdkgsn7Kk=
|
|
45
|
+
</data>
|
|
46
|
+
</dict>
|
|
47
|
+
</dict>
|
|
14
48
|
<key>rules</key>
|
|
15
49
|
<dict>
|
|
16
50
|
<key>^.*</key>
|
|
Binary file
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { CactusUtil } from "../native/index.js";
|
|
4
|
+
import { packageVersion } from "../constants/packageVersion.js";
|
|
5
|
+
export class Database {
|
|
6
|
+
static url = 'https://vlqqczxwyaodtcdmdmlw.supabase.co';
|
|
7
|
+
static key = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InZscXFjenh3eWFvZHRjZG1kbWx3Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTE1MTg2MzIsImV4cCI6MjA2NzA5NDYzMn0.nBzqGuK9j6RZ6mOPWU2boAC_5H9XDs-fPpo5P3WZYbI';
|
|
8
|
+
static async sendLogRecords(records) {
|
|
9
|
+
const response = await fetch(`${this.url}/rest/v1/logs`, {
|
|
10
|
+
method: 'POST',
|
|
11
|
+
headers: {
|
|
12
|
+
'apikey': this.key,
|
|
13
|
+
'Authorization': `Bearer ${this.key}`,
|
|
14
|
+
'Content-Type': 'application/json',
|
|
15
|
+
'Content-Profile': 'cactus',
|
|
16
|
+
'Prefer': 'return=minimal'
|
|
17
|
+
},
|
|
18
|
+
body: JSON.stringify(records)
|
|
19
|
+
});
|
|
20
|
+
if (!response.ok) {
|
|
21
|
+
throw new Error('Sending logs failed');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
static async registerDevice(device_data) {
|
|
25
|
+
const response = await fetch(`${this.url}/functions/v1/device-registration`, {
|
|
26
|
+
method: 'POST',
|
|
27
|
+
body: JSON.stringify({
|
|
28
|
+
device_data
|
|
29
|
+
})
|
|
30
|
+
});
|
|
31
|
+
if (!response.ok) {
|
|
32
|
+
throw new Error('Registering device failed');
|
|
33
|
+
}
|
|
34
|
+
return await CactusUtil.registerApp(await response.text());
|
|
35
|
+
}
|
|
36
|
+
static async getModels() {
|
|
37
|
+
const response = await fetch(`${this.url}/functions/v1/get-models?sdk_name=react&sdk_version=${packageVersion}`, {
|
|
38
|
+
headers: {
|
|
39
|
+
apikey: this.key,
|
|
40
|
+
Authorization: `Bearer ${this.key}`
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
if (!response.ok) {
|
|
44
|
+
throw new Error('Getting models failed');
|
|
45
|
+
}
|
|
46
|
+
const models = await response.json();
|
|
47
|
+
return models.map(model => ({
|
|
48
|
+
name: model.name,
|
|
49
|
+
slug: model.slug,
|
|
50
|
+
quantization: model.quantization,
|
|
51
|
+
sizeMb: model.size_mb,
|
|
52
|
+
downloadUrl: model.download_url,
|
|
53
|
+
supportsToolCalling: model.supports_tool_calling,
|
|
54
|
+
supportsVision: model.supports_vision,
|
|
55
|
+
createdAt: model.created_at,
|
|
56
|
+
isDownloaded: false
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=Database.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CactusUtil","packageVersion","Database","url","key","sendLogRecords","records","response","fetch","method","headers","body","JSON","stringify","ok","Error","registerDevice","device_data","registerApp","text","getModels","apikey","Authorization","models","json","map","model","name","slug","quantization","sizeMb","size_mb","downloadUrl","download_url","supportsToolCalling","supports_tool_calling","supportsVision","supports_vision","createdAt","created_at","isDownloaded"],"sourceRoot":"../../../src","sources":["api/Database.ts"],"mappings":";;AAAA,SAASA,UAAU,QAAQ,oBAAW;AAGtC,SAASC,cAAc,QAAQ,gCAA6B;AAc5D,OAAO,MAAMC,QAAQ,CAAC;EACpB,OAAwBC,GAAG,GAAG,0CAA0C;EACxE,OAAwBC,GAAG,GACzB,kNAAkN;EAEpN,aAAoBC,cAAcA,CAACC,OAAoB,EAAiB;IACtE,MAAMC,QAAQ,GAAG,MAAMC,KAAK,CAAC,GAAG,IAAI,CAACL,GAAG,eAAe,EAAE;MACvDM,MAAM,EAAE,MAAM;MACdC,OAAO,EAAE;QACP,QAAQ,EAAE,IAAI,CAACN,GAAG;QAClB,eAAe,EAAE,UAAU,IAAI,CAACA,GAAG,EAAE;QACrC,cAAc,EAAE,kBAAkB;QAClC,iBAAiB,EAAE,QAAQ;QAC3B,QAAQ,EAAE;MACZ,CAAC;MACDO,IAAI,EAAEC,IAAI,CAACC,SAAS,CAACP,OAAO;IAC9B,CAAC,CAAC;IAEF,IAAI,CAACC,QAAQ,CAACO,EAAE,EAAE;MAChB,MAAM,IAAIC,KAAK,CAAC,qBAAqB,CAAC;IACxC;EACF;EAEA,aAAoBC,cAAcA,CAACC,WAAuB,EAAmB;IAC3E,MAAMV,QAAQ,GAAG,MAAMC,KAAK,CAC1B,GAAG,IAAI,CAACL,GAAG,mCAAmC,EAC9C;MACEM,MAAM,EAAE,MAAM;MACdE,IAAI,EAAEC,IAAI,CAACC,SAAS,CAAC;QAAEI;MAAY,CAAC;IACtC,CACF,CAAC;IAED,IAAI,CAACV,QAAQ,CAACO,EAAE,EAAE;MAChB,MAAM,IAAIC,KAAK,CAAC,2BAA2B,CAAC;IAC9C;IAEA,OAAO,MAAMf,UAAU,CAACkB,WAAW,CAAC,MAAMX,QAAQ,CAACY,IAAI,CAAC,CAAC,CAAC;EAC5D;EAEA,aAAoBC,SAASA,CAAA,EAA2B;IACtD,MAAMb,QAAQ,GAAG,MAAMC,KAAK,CAC1B,GAAG,IAAI,CAACL,GAAG,uDAAuDF,cAAc,EAAE,EAClF;MACES,OAAO,EAAE;QAAEW,MAAM,EAAE,IAAI,CAACjB,GAAG;QAAEkB,aAAa,EAAE,UAAU,IAAI,CAAClB,GAAG;MAAG;IACnE,CACF,CAAC;IAED,IAAI,CAACG,QAAQ,CAACO,EAAE,EAAE;MAChB,MAAM,IAAIC,KAAK,CAAC,uBAAuB,CAAC;IAC1C;IAEA,MAAMQ,MAAM,GAAI,MAAMhB,QAAQ,CAACiB,IAAI,CAAC,CAA2B;IAE/D,OAAOD,MAAM,CAACE,GAAG,CAAEC,KAAK,KAAM;MAC5BC,IAAI,EAAED,KAAK,CAACC,IAAI;MAChBC,IAAI,EAAEF,KAAK,CAACE,IAAI;MAChBC,YAAY,EAAEH,KAAK,CAACG,YAAY;MAChCC,MAAM,EAAEJ,KAAK,CAACK,OAAO;MACrBC,WAAW,EAAEN,KAAK,CAACO,YAAY;MAC/BC,mBAAmB,EAAER,KAAK,CAACS,qBAAqB;MAChDC,cAAc,EAAEV,KAAK,CAACW,eAAe;MACrCC,SAAS,EAAEZ,KAAK,CAACa,UAAU;MAC3BC,YAAY,EAAE;IAChB,CAAC,CAAC,CAAC;EACL;AACF","ignoreList":[]}
|