Skip to content

Commit fda9b9a

Browse files
authored
Refactor LLaMATests to initialize config inline
1 parent dbf40fa commit fda9b9a

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

extension/benchmark/apple/Benchmark/Tests/LLaMA/LLaMATests.mm

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,16 @@ @implementation LLaMATests
9797
XCTFail("Load failed with error %zi", error.code);
9898
return;
9999
}
100-
ExecuTorchLLMGenerationConfig *config =
101-
[[ExecuTorchLLMGenerationConfig alloc] initWithBlock:^(ExecuTorchLLMGenerationConfig *config) {
102-
config.sequenceLength = 50;
103-
}];
104100
TokensPerSecondMetric *tokensPerSecondMetric = [TokensPerSecondMetric new];
105101
[testCase measureWithMetrics:@[ tokensPerSecondMetric, [XCTClockMetric new], [XCTMemoryMetric new] ]
106102
block:^{
107103
tokensPerSecondMetric.tokenCount = 0;
108104
BOOL status = [runner generateWithPrompt:@"Once upon a time"
109-
config:config
105+
config:[[ExecuTorchLLMGenerationConfig alloc] initWithBlock:^(ExecuTorchLLMGenerationConfig *config) {
106+
config.sequenceLength = 50;
107+
}]
110108
tokenCallback:^(NSString *token) {
111-
tokensPerSecondMetric.tokenCount++;
109+
++tokensPerSecondMetric.tokenCount;
112110
}
113111
error:NULL];
114112
XCTAssertTrue(status);

0 commit comments

Comments
 (0)