Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

NS_ASSUME_NONNULL_BEGIN

FOUNDATION_EXPORT NSErrorDomain const LLaMARunnerErrorDomain;
FOUNDATION_EXPORT NSErrorDomain const LLMRunnerErrorDomain;
FOUNDATION_EXPORT NSErrorDomain const LLaVARunnerErrorDomain;

NS_SWIFT_NAME(Runner)
@interface LLaMARunner : NSObject
@interface LLMRunner : NSObject

- (instancetype)initWithModelPath:(NSString*)filePath
tokenizerPath:(NSString*)tokenizerPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* LICENSE file in the root directory of this source tree.
*/

#import "LLaMARunner.h"
#import "LLMRunner.h"

#import <ExecuTorch/ExecuTorchLog.h>
#import <executorch/examples/models/llama/runner/runner.h>
Expand All @@ -17,13 +17,13 @@
using executorch::extension::llm::TextLLMRunner;
using executorch::runtime::Error;

NSErrorDomain const LLaMARunnerErrorDomain = @"LLaMARunnerErrorDomain";
NSErrorDomain const LLMRunnerErrorDomain = @"LLMRunnerErrorDomain";
NSErrorDomain const LLaVARunnerErrorDomain = @"LLaVARunnerErrorDomain";

@interface LLaMARunner ()<ExecuTorchLogSink>
@interface LLMRunner ()<ExecuTorchLogSink>
@end

@implementation LLaMARunner {
@implementation LLMRunner {
std::unique_ptr<TextLLMRunner> _runner;
}

Expand All @@ -50,7 +50,7 @@ - (BOOL)loadWithError:(NSError**)error {
const auto status = _runner->load();
if (status != Error::Ok) {
if (error) {
*error = [NSError errorWithDomain:LLaMARunnerErrorDomain
*error = [NSError errorWithDomain:LLMRunnerErrorDomain
code:(NSInteger)status
userInfo:nil];
}
Expand All @@ -72,7 +72,7 @@ - (BOOL)generate:(NSString*)prompt
});
if (status != Error::Ok) {
if (error) {
*error = [NSError errorWithDomain:LLaMARunnerErrorDomain
*error = [NSError errorWithDomain:LLMRunnerErrorDomain
code:(NSInteger)status
userInfo:nil];
return NO;
Expand Down Expand Up @@ -170,7 +170,7 @@ - (BOOL)generate:(void*)imageBuffer
[callback](const std::string& token) { callback(@(token.c_str())); });
if (status != Error::Ok) {
if (error) {
*error = [NSError errorWithDomain:LLaMARunnerErrorDomain
*error = [NSError errorWithDomain:LLMRunnerErrorDomain
code:(NSInteger)status
userInfo:nil];
return NO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* LICENSE file in the root directory of this source tree.
*/

@testable import LLaMARunner
@testable import LLMRunner

import XCTest

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
0324D6922BAACB6900DEF36F /* ResourceManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0324D6872BAACB6900DEF36F /* ResourceManager.swift */; };
0324D6932BAACB6900DEF36F /* ResourceMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0324D6882BAACB6900DEF36F /* ResourceMonitor.swift */; };
0324D6962BAACB7000DEF36F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0324D6942BAACB7000DEF36F /* Assets.xcassets */; };
03729EDC2BB1F8DE00152F2E /* LLaMARunner.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 03729ED52BB1F8DE00152F2E /* LLaMARunner.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
03729EE12BB1F93800152F2E /* LLaMARunner.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0324D69A2BAACB7C00DEF36F /* LLaMARunner.mm */; };
03729EE22BB1F93E00152F2E /* LLaMARunner.h in Headers */ = {isa = PBXBuildFile; fileRef = 0324D6992BAACB7C00DEF36F /* LLaMARunner.h */; settings = {ATTRIBUTES = (Public, ); }; };
03729EDC2BB1F8DE00152F2E /* LLMRunner.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 03729ED52BB1F8DE00152F2E /* LLMRunner.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
03729EE12BB1F93800152F2E /* LLMRunner.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0324D69A2BAACB7C00DEF36F /* LLMRunner.mm */; };
03729EE22BB1F93E00152F2E /* LLMRunner.h in Headers */ = {isa = PBXBuildFile; fileRef = 0324D6992BAACB7C00DEF36F /* LLMRunner.h */; settings = {ATTRIBUTES = (Public, ); }; };
03729F0A2BB203B300152F2E /* runner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03729F072BB203B300152F2E /* runner.cpp */; };
03729F0B2BB203B300152F2E /* runner.h in Headers */ = {isa = PBXBuildFile; fileRef = 03729F082BB203B300152F2E /* runner.h */; };
03729F0C2BB203B300152F2E /* util.h in Headers */ = {isa = PBXBuildFile; fileRef = 03729F092BB203B300152F2E /* util.h */; };
Expand Down Expand Up @@ -84,7 +84,7 @@
containerPortal = 032C01672AC228E5002955E1 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 03729ED42BB1F8DE00152F2E;
remoteInfo = LLaMARunner;
remoteInfo = LLMRunner;
};
/* End PBXContainerItemProxy section */

Expand All @@ -95,7 +95,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
03729EDC2BB1F8DE00152F2E /* LLaMARunner.framework in Embed Frameworks */,
03729EDC2BB1F8DE00152F2E /* LLMRunner.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -114,11 +114,11 @@
0324D6872BAACB6900DEF36F /* ResourceManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ResourceManager.swift; sourceTree = "<group>"; };
0324D6882BAACB6900DEF36F /* ResourceMonitor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ResourceMonitor.swift; sourceTree = "<group>"; };
0324D6942BAACB7000DEF36F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
0324D6992BAACB7C00DEF36F /* LLaMARunner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LLaMARunner.h; sourceTree = "<group>"; };
0324D69A2BAACB7C00DEF36F /* LLaMARunner.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LLaMARunner.mm; sourceTree = "<group>"; };
0324D6992BAACB7C00DEF36F /* LLMRunner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LLMRunner.h; sourceTree = "<group>"; };
0324D69A2BAACB7C00DEF36F /* LLMRunner.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LLMRunner.mm; sourceTree = "<group>"; };
035A5E942BB4B523001E0553 /* LLaMA.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = LLaMA.entitlements; sourceTree = "<group>"; };
036CAF9D2BB1444500D6C2D5 /* LLaMA.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LLaMA.app; sourceTree = BUILT_PRODUCTS_DIR; };
03729ED52BB1F8DE00152F2E /* LLaMARunner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = LLaMARunner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
03729ED52BB1F8DE00152F2E /* LLMRunner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = LLMRunner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
03729F072BB203B300152F2E /* runner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = runner.cpp; path = ../../../examples/models/llama/runner/runner.cpp; sourceTree = "<group>"; };
03729F082BB203B300152F2E /* runner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = runner.h; path = ../../../examples/models/llama/runner/runner.h; sourceTree = "<group>"; };
03729F092BB203B300152F2E /* util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = util.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -245,29 +245,29 @@
0324D69B2BAACB7C00DEF36F /* Exported */ = {
isa = PBXGroup;
children = (
0324D6992BAACB7C00DEF36F /* LLaMARunner.h */,
0324D69A2BAACB7C00DEF36F /* LLaMARunner.mm */,
0324D6992BAACB7C00DEF36F /* LLMRunner.h */,
0324D69A2BAACB7C00DEF36F /* LLMRunner.mm */,
);
path = Exported;
sourceTree = "<group>";
};
0324D69C2BAACB7C00DEF36F /* LLaMARunner */ = {
0324D69C2BAACB7C00DEF36F /* LLMRunner */ = {
isa = PBXGroup;
children = (
0324D69B2BAACB7C00DEF36F /* Exported */,
03729F062BB2035900152F2E /* runner */,
03729F0F2BB203E100152F2E /* sampler */,
03729F0E2BB203D700152F2E /* tokenizers */,
);
path = LLaMARunner;
path = LLMRunner;
sourceTree = "<group>";
};
0324D69F2BAACB7C00DEF36F /* LLaMARunner */ = {
0324D69F2BAACB7C00DEF36F /* LLMRunner */ = {
isa = PBXGroup;
children = (
0324D69C2BAACB7C00DEF36F /* LLaMARunner */,
0324D69C2BAACB7C00DEF36F /* LLMRunner */,
);
path = LLaMARunner;
path = LLMRunner;
sourceTree = "<group>";
};
032C01662AC228E5002955E1 = {
Expand All @@ -276,9 +276,9 @@
0324D68A2BAACB6900DEF36F /* LLaMA */,
0324D6952BAACB7000DEF36F /* LLaMAAssets */,
035A5E952BB4B523001E0553 /* LLaMAEntitlements */,
0324D69F2BAACB7C00DEF36F /* LLaMARunner */,
0324D69F2BAACB7C00DEF36F /* LLMRunner */,
036CAF9D2BB1444500D6C2D5 /* LLaMA.app */,
03729ED52BB1F8DE00152F2E /* LLaMARunner.framework */,
03729ED52BB1F8DE00152F2E /* LLMRunner.framework */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -384,7 +384,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
03729EE22BB1F93E00152F2E /* LLaMARunner.h in Headers */,
03729EE22BB1F93E00152F2E /* LLMRunner.h in Headers */,
03D03DA82C7823620088D6A7 /* text_prefiller.h in Headers */,
F292B0882D88B0D200BE6839 /* llama2c_tokenizer.h in Headers */,
F292B0892D88B0D200BE6839 /* tokenizer.h in Headers */,
Expand Down Expand Up @@ -435,9 +435,9 @@
productReference = 036CAF9D2BB1444500D6C2D5 /* LLaMA.app */;
productType = "com.apple.product-type.application";
};
03729ED42BB1F8DE00152F2E /* LLaMARunner */ = {
03729ED42BB1F8DE00152F2E /* LLMRunner */ = {
isa = PBXNativeTarget;
buildConfigurationList = 03729EDD2BB1F8DE00152F2E /* Build configuration list for PBXNativeTarget "LLaMARunner" */;
buildConfigurationList = 03729EDD2BB1F8DE00152F2E /* Build configuration list for PBXNativeTarget "LLMRunner" */;
buildPhases = (
03641D7C2C409960004AF8DE /* Build Cmake Dependencies */,
03729ED02BB1F8DE00152F2E /* Headers */,
Expand All @@ -449,7 +449,7 @@
);
dependencies = (
);
name = LLaMARunner;
name = LLMRunner;
packageProductDependencies = (
03CF43952CEC5CEC00C7113B /* backend_coreml */,
03CF43972CEC5CEC00C7113B /* backend_coreml_debug */,
Expand All @@ -467,8 +467,8 @@
03CF43AF2CEC5CEC00C7113B /* kernels_quantized */,
03CF43B12CEC5CEC00C7113B /* kernels_quantized_debug */,
);
productName = LLaMARunner;
productReference = 03729ED52BB1F8DE00152F2E /* LLaMARunner.framework */;
productName = LLMRunner;
productReference = 03729ED52BB1F8DE00152F2E /* LLMRunner.framework */;
productType = "com.apple.product-type.framework";
};
/* End PBXNativeTarget section */
Expand Down Expand Up @@ -506,7 +506,7 @@
projectRoot = "";
targets = (
032C016E2AC228E6002955E1 /* LLaMA */,
03729ED42BB1F8DE00152F2E /* LLaMARunner */,
03729ED42BB1F8DE00152F2E /* LLMRunner */,
);
};
/* End PBXProject section */
Expand Down Expand Up @@ -574,7 +574,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
03729EE12BB1F93800152F2E /* LLaMARunner.mm in Sources */,
03729EE12BB1F93800152F2E /* LLMRunner.mm in Sources */,
0372C3152C89418E00CD942A /* llava_runner.cpp in Sources */,
F292B1022D88B20C00BE6839 /* llama_tiktoken.cpp in Sources */,
03D03DAB2C7823830088D6A7 /* text_decoder_runner.cpp in Sources */,
Expand All @@ -599,7 +599,7 @@
/* Begin PBXTargetDependency section */
03729EDA2BB1F8DE00152F2E /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 03729ED42BB1F8DE00152F2E /* LLaMARunner */;
target = 03729ED42BB1F8DE00152F2E /* LLMRunner */;
targetProxy = 03729ED92BB1F8DE00152F2E /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
Expand Down Expand Up @@ -830,7 +830,7 @@
MARKETING_VERSION = 1.0;
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20";
PRODUCT_BUNDLE_IDENTIFIER = org.pytorch.executorch.illama.LLaMARunner;
PRODUCT_BUNDLE_IDENTIFIER = org.pytorch.executorch.illama.LLMRunner;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
Expand Down Expand Up @@ -866,7 +866,7 @@
MARKETING_VERSION = 1.0;
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20";
PRODUCT_BUNDLE_IDENTIFIER = org.pytorch.executorch.illama.LLaMARunner;
PRODUCT_BUNDLE_IDENTIFIER = org.pytorch.executorch.illama.LLMRunner;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
Expand Down Expand Up @@ -901,7 +901,7 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
03729EDD2BB1F8DE00152F2E /* Build configuration list for PBXNativeTarget "LLaMARunner" */ = {
03729EDD2BB1F8DE00152F2E /* Build configuration list for PBXNativeTarget "LLMRunner" */ = {
isa = XCConfigurationList;
buildConfigurations = (
03729EDE2BB1F8DE00152F2E /* Debug */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "03729ED42BB1F8DE00152F2E"
BuildableName = "LLaMARunner.framework"
BlueprintName = "LLaMARunner"
BuildableName = "LLMRunner.framework"
BlueprintName = "LLMRunner"
ReferencedContainer = "container:LLaMA.xcodeproj">
</BuildableReference>
</BuildActionEntry>
Expand Down Expand Up @@ -51,8 +51,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "03729ED42BB1F8DE00152F2E"
BuildableName = "LLaMARunner.framework"
BlueprintName = "LLaMARunner"
BuildableName = "LLMRunner.framework"
BlueprintName = "LLMRunner"
ReferencedContainer = "container:LLaMA.xcodeproj">
</BuildableReference>
</MacroExpansion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import SwiftUI
import UniformTypeIdentifiers

import LLaMARunner
import LLMRunner

class RunnerHolder: ObservableObject {
var runner: Runner?
Expand Down Expand Up @@ -87,7 +87,7 @@ struct ContentView: View {
case llava
case qwen3
case phi4

static func fromPath(_ path: String) -> ModelType {
let filename = (path as NSString).lastPathComponent.lowercased()
if filename.hasPrefix("llama") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ OTHER_LDFLAGS = $(inherited) \
-force_load $(BUILT_PRODUCTS_DIR)/libkernels_quantized_debug_$(ET_PLATFORM).a \
@$(TEMP_DIR)/cmake/linker_flags

// LLaMARunner requires additional dependencies built with CMake in a custom run script phase.
// LLMRunner requires additional dependencies built with CMake in a custom run script phase.
// Include headers and libraries from $(TEMP_DIR)/cmake for it.
HEADER_SEARCH_PATHS = $(inherited) \
$(SRCROOT)/../../../../.. \
$(TEMP_DIR)/cmake/include \
$(SRCROOT)/../../../../extension/llm/tokenizers/include
$(SRCROOT)/../../../../extension/llm/tokenizers/include

LIBRARY_SEARCH_PATHS = $(inherited) \
$(TEMP_DIR)/cmake/lib
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ OTHER_LDFLAGS = $(inherited) \
-force_load $(BUILT_PRODUCTS_DIR)/libkernels_quantized_$(ET_PLATFORM).a \
@$(TEMP_DIR)/cmake/linker_flags

// LLaMARunner requires additional dependencies built with CMake in a custom run script phase.
// LLMRunner requires additional dependencies built with CMake in a custom run script phase.
// Include headers and libraries from $(TEMP_DIR)/cmake for it.
HEADER_SEARCH_PATHS = $(inherited) \
$(SRCROOT)/../../../../.. \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,14 @@ The following packages should be linked in your app target `LLaMA` (left side, L
- kernels_portable
- kernels_quantized

The following package should be linked in your target app `LLaMARunner` (left side, LLaMA --> General --> select LLaMARunner under "TARGETS" --> scroll down to "Frameworks and Libraries")
The following package should be linked in your target app `LLMRunner` (left side, LLaMA --> General --> select LLMRunner under "TARGETS" --> scroll down to "Frameworks and Libraries")
- executorch

<p align="center">
<img src="https://raw.githubusercontent.com/pytorch/executorch/refs/heads/main/docs/source/_static/img/ios_demo_app_choosing_package.png" alt="iOS LLaMA App Choosing package" style="width:600px">
</p>

If you cannot add the package into your app target (it's greyed out), it might have been linked before. You can verify it by checking it from your target app `(LLaMA / LLaMARunner) --> Build Phases --> Link Binary With Libraries`.
If you cannot add the package into your app target (it's greyed out), it might have been linked before. You can verify it by checking it from your target app `(LLaMA / LLMRunner) --> Build Phases --> Link Binary With Libraries`.



Expand Down
4 changes: 2 additions & 2 deletions examples/demo-apps/react-native/rnllama/ios/LlamaBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

#import <React/RCTBridgeModule.h>
#import <React/RCTEventEmitter.h>
#import "LLaMARunner.h"
#import "LLMRunner.h"

NS_ASSUME_NONNULL_BEGIN

@interface LLaMABridge : RCTEventEmitter <RCTBridgeModule>
@property (nonatomic, strong) LLaMARunner *runner;
@property (nonatomic, strong) LLMRunner *runner;
@end

NS_ASSUME_NONNULL_END
Expand Down
Loading
Loading