Skip to content

Commit 45a14b9

Browse files
authored
Fix nullable-to-nonnull conversions for Xcode 26.6 (#20466)
Differential Revision: D109459540 Pull Request resolved: #20466
1 parent bcba790 commit 45a14b9

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

extension/llm/apple/ExecuTorchLLM/Exported/ExecuTorchLLMMultimodalRunner.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ - (BOOL)isLoaded {
170170
- (BOOL)loadWithError:(NSError**)error {
171171
if (![self isLoaded]) {
172172
_runner = llm::create_multimodal_runner(
173-
_modelPath.UTF8String,
174-
llm::load_tokenizer(_tokenizerPath.UTF8String)
173+
_modelPath.UTF8String ?: "",
174+
llm::load_tokenizer(_tokenizerPath.UTF8String ?: "")
175175
);
176176
if (!_runner) {
177177
if (error) {
@@ -206,7 +206,7 @@ - (BOOL)generateWithInputs:(NSArray<ExecuTorchLLMMultimodalInput *> *)inputs
206206
for (ExecuTorchLLMMultimodalInput *input in inputs) {
207207
switch (input.type) {
208208
case ExecuTorchLLMMultimodalInputTypeText:
209-
nativeInputs.emplace_back(llm::MultimodalInput(input.text.UTF8String));
209+
nativeInputs.emplace_back(llm::MultimodalInput(input.text.UTF8String ?: ""));
210210
break;
211211
case ExecuTorchLLMMultimodalInputTypeImage: {
212212
ExecuTorchLLMImage *image = input.image;

extension/llm/apple/ExecuTorchLLM/Exported/ExecuTorchLLMTextRunner.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ - (instancetype)initWithModelPath:(NSString*)modelPath
4444
_tokenizerPath = [tokenizerPath copy];
4545
_specialTokens = std::make_unique<std::vector<std::string>>();
4646
for (NSString *token in specialTokens) {
47-
_specialTokens->emplace_back(token.UTF8String);
47+
_specialTokens->emplace_back(token.UTF8String ?: "");
4848
}
4949
}
5050
return self;
@@ -57,8 +57,8 @@ - (BOOL)isLoaded {
5757
- (BOOL)loadWithError:(NSError**)error {
5858
if (![self isLoaded]) {
5959
_runner = llm::create_text_llm_runner(
60-
_modelPath.UTF8String,
61-
llm::load_tokenizer(_tokenizerPath.UTF8String, std::move(_specialTokens))
60+
_modelPath.UTF8String ?: "",
61+
llm::load_tokenizer(_tokenizerPath.UTF8String ?: "", std::move(_specialTokens))
6262
);
6363
if (!_runner) {
6464
if (error) {
@@ -89,7 +89,7 @@ - (BOOL)generateWithPrompt:(NSString*)prompt
8989
return NO;
9090
}
9191
auto status = _runner->generate(
92-
prompt.UTF8String,
92+
prompt.UTF8String ?: "",
9393
config.nativeConfig,
9494
[callback](const std::string& token) {
9595
if (callback) {

0 commit comments

Comments
 (0)