Skip to content

Commit 5d4d821

Browse files
authored
App skeleton.
Differential Revision: D62281653 Pull Request resolved: #5128
1 parent fb86e61 commit 5d4d821

File tree

7 files changed

+829
-0
lines changed

7 files changed

+829
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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>com.apple.security.app-sandbox</key>
6+
<true/>
7+
<key>com.apple.security.files.user-selected.read-only</key>
8+
<true/>
9+
<key>com.apple.developer.kernel.increased-memory-limit</key>
10+
<true/>
11+
</dict>
12+
</plist>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
import SwiftUI
10+
11+
@main
12+
struct BenchmarkApp: App {
13+
var body: some Scene {
14+
WindowGroup {}
15+
}
16+
}

extension/apple/Benchmark/Benchmark.xcodeproj/project.pbxproj

Lines changed: 535 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1540"
4+
version = "1.7">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES"
8+
buildArchitectures = "Automatic">
9+
<BuildActionEntries>
10+
<BuildActionEntry
11+
buildForTesting = "YES"
12+
buildForRunning = "YES"
13+
buildForProfiling = "YES"
14+
buildForArchiving = "YES"
15+
buildForAnalyzing = "YES">
16+
<BuildableReference
17+
BuildableIdentifier = "primary"
18+
BlueprintIdentifier = "03B2D3632C8A515A0046936E"
19+
BuildableName = "Benchmark.app"
20+
BlueprintName = "App"
21+
ReferencedContainer = "container:Benchmark.xcodeproj">
22+
</BuildableReference>
23+
</BuildActionEntry>
24+
</BuildActionEntries>
25+
</BuildAction>
26+
<TestAction
27+
buildConfiguration = "Release"
28+
selectedDebuggerIdentifier = ""
29+
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
30+
shouldUseLaunchSchemeArgsEnv = "YES">
31+
<TestPlans>
32+
<TestPlanReference
33+
reference = "container:Tests/Tests.xctestplan"
34+
default = "YES">
35+
</TestPlanReference>
36+
</TestPlans>
37+
<Testables>
38+
<TestableReference
39+
skipped = "NO"
40+
parallelizable = "YES">
41+
<BuildableReference
42+
BuildableIdentifier = "primary"
43+
BlueprintIdentifier = "03B2D3742C8A515C0046936E"
44+
BuildableName = "Tests.xctest"
45+
BlueprintName = "Tests"
46+
ReferencedContainer = "container:Benchmark.xcodeproj">
47+
</BuildableReference>
48+
</TestableReference>
49+
<TestableReference
50+
skipped = "NO"
51+
parallelizable = "YES">
52+
<BuildableReference
53+
BuildableIdentifier = "primary"
54+
BlueprintIdentifier = "03B2D37E2C8A515C0046936E"
55+
BuildableName = "BenchmarkUITests.xctest"
56+
BlueprintName = "BenchmarkUITests"
57+
ReferencedContainer = "container:Benchmark.xcodeproj">
58+
</BuildableReference>
59+
</TestableReference>
60+
</Testables>
61+
</TestAction>
62+
<LaunchAction
63+
buildConfiguration = "Debug"
64+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
65+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
66+
launchStyle = "0"
67+
useCustomWorkingDirectory = "NO"
68+
ignoresPersistentStateOnLaunch = "NO"
69+
debugDocumentVersioning = "YES"
70+
debugServiceExtension = "internal"
71+
allowLocationSimulation = "YES">
72+
<BuildableProductRunnable
73+
runnableDebuggingMode = "0">
74+
<BuildableReference
75+
BuildableIdentifier = "primary"
76+
BlueprintIdentifier = "03B2D3632C8A515A0046936E"
77+
BuildableName = "Benchmark.app"
78+
BlueprintName = "App"
79+
ReferencedContainer = "container:Benchmark.xcodeproj">
80+
</BuildableReference>
81+
</BuildableProductRunnable>
82+
</LaunchAction>
83+
<ProfileAction
84+
buildConfiguration = "Release"
85+
shouldUseLaunchSchemeArgsEnv = "YES"
86+
savedToolIdentifier = ""
87+
useCustomWorkingDirectory = "NO"
88+
debugDocumentVersioning = "YES">
89+
<BuildableProductRunnable
90+
runnableDebuggingMode = "0">
91+
<BuildableReference
92+
BuildableIdentifier = "primary"
93+
BlueprintIdentifier = "03B2D3632C8A515A0046936E"
94+
BuildableName = "Benchmark.app"
95+
BlueprintName = "App"
96+
ReferencedContainer = "container:Benchmark.xcodeproj">
97+
</BuildableReference>
98+
</BuildableProductRunnable>
99+
</ProfileAction>
100+
<AnalyzeAction
101+
buildConfiguration = "Debug">
102+
</AnalyzeAction>
103+
<ArchiveAction
104+
buildConfiguration = "Release"
105+
revealArchiveInOrganizer = "YES">
106+
</ArchiveAction>
107+
</Scheme>
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
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+
#import <XCTest/XCTest.h>
10+
11+
#import <objc/runtime.h>
12+
13+
#import <executorch/extension/module/module.h>
14+
#import <executorch/extension/tensor/tensor.h>
15+
16+
using namespace ::executorch::extension;
17+
using namespace ::executorch::runtime;
18+
19+
@interface Tests : XCTestCase
20+
@end
21+
22+
@implementation Tests
23+
24+
+ (void)initialize {
25+
if (self == [Tests class]) {
26+
NSString *modelsDir = [[NSBundle bundleForClass:[self class]].resourcePath
27+
stringByAppendingPathComponent:@"Models"];
28+
NSArray *models =
29+
[NSFileManager.defaultManager contentsOfDirectoryAtPath:modelsDir
30+
error:nil];
31+
for (NSString *model in models) {
32+
NSString *modelName = model.stringByDeletingPathExtension;
33+
NSString *modelPath = [modelsDir stringByAppendingPathComponent:model];
34+
XCTAssertGreaterThan(modelPath.length, 0);
35+
36+
SEL testLoadSelector = NSSelectorFromString(
37+
[NSString stringWithFormat:@"test_load_%@", modelName]);
38+
IMP testLoadImplementation = imp_implementationWithBlock(^(id _self) {
39+
auto __block module = std::make_unique<Module>(modelPath.UTF8String);
40+
[_self
41+
measureWithMetrics:@[ [XCTClockMetric new], [XCTMemoryMetric new] ]
42+
options:XCTMeasureOptions.defaultOptions
43+
block:^{
44+
XCTAssertEqual(module->load_method("forward"),
45+
Error::Ok);
46+
}];
47+
});
48+
class_addMethod(
49+
[self class], testLoadSelector, testLoadImplementation, "v@:");
50+
51+
SEL testForwardSelector = NSSelectorFromString(
52+
[NSString stringWithFormat:@"test_forward_%@", modelName]);
53+
IMP testForwardImplementation = imp_implementationWithBlock(^(id _self) {
54+
auto __block module = std::make_unique<Module>(modelPath.UTF8String);
55+
XCTAssertEqual(module->load_method("forward"), Error::Ok);
56+
57+
const auto method_meta = module->method_meta("forward");
58+
XCTAssertEqual(method_meta.error(), Error::Ok);
59+
60+
const auto num_inputs = method_meta->num_inputs();
61+
XCTAssertGreaterThan(num_inputs, 0);
62+
63+
std::vector<std::vector<uint8_t>> buffers;
64+
buffers.reserve(num_inputs);
65+
std::vector<TensorPtr> tensors;
66+
tensors.reserve(num_inputs);
67+
std::vector<EValue> __block inputs;
68+
inputs.reserve(num_inputs);
69+
70+
for (auto index = 0; index < num_inputs; ++index) {
71+
auto input_tag = method_meta->input_tag(index);
72+
XCTAssertEqual(input_tag.error(), Error::Ok);
73+
74+
switch (*input_tag) {
75+
case Tag::Tensor: {
76+
const auto tensor_meta = method_meta->input_tensor_meta(index);
77+
XCTAssertEqual(tensor_meta.error(), Error::Ok);
78+
79+
const auto sizes = tensor_meta->sizes();
80+
buffers.emplace_back(tensor_meta->nbytes(),
81+
0b01010101); // Set all bytes to be non-zero.
82+
tensors.emplace_back(from_blob(buffers.rbegin()->data(),
83+
{sizes.begin(), sizes.end()},
84+
tensor_meta->scalar_type()));
85+
inputs.emplace_back(tensors.back());
86+
} break;
87+
default:
88+
XCTFail("Unsupported tag %i at input %d", *input_tag, index);
89+
}
90+
}
91+
[_self
92+
measureWithMetrics:@[ [XCTClockMetric new], [XCTMemoryMetric new] ]
93+
options:XCTMeasureOptions.defaultOptions
94+
block:^{
95+
XCTAssertEqual(module->forward(inputs).error(),
96+
Error::Ok);
97+
}];
98+
});
99+
class_addMethod(
100+
[self class], testForwardSelector, testForwardImplementation, "v@:");
101+
}
102+
}
103+
}
104+
105+
@end
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
OTHER_LDFLAGS[sdk=iphonesimulator*] = $(inherited) \
2+
-force_load $(BUILT_PRODUCTS_DIR)/libexecutorch-simulator-release.a \
3+
-force_load $(BUILT_PRODUCTS_DIR)/libkernels_portable-simulator-release.a \
4+
-force_load $(BUILT_PRODUCTS_DIR)/libkernels_custom-simulator-release.a \
5+
-force_load $(BUILT_PRODUCTS_DIR)/libkernels_quantized-simulator-release.a \
6+
-force_load $(BUILT_PRODUCTS_DIR)/libbackend_coreml-simulator-release.a \
7+
-force_load $(BUILT_PRODUCTS_DIR)/libbackend_mps-simulator-release.a \
8+
-force_load $(BUILT_PRODUCTS_DIR)/libbackend_xnnpack-simulator-release.a
9+
10+
OTHER_LDFLAGS[sdk=iphoneos*] = $(inherited) \
11+
-force_load $(BUILT_PRODUCTS_DIR)/libexecutorch-ios-release.a \
12+
-force_load $(BUILT_PRODUCTS_DIR)/libkernels_portable-ios-release.a \
13+
-force_load $(BUILT_PRODUCTS_DIR)/libkernels_custom-ios-release.a \
14+
-force_load $(BUILT_PRODUCTS_DIR)/libkernels_quantized-ios-release.a \
15+
-force_load $(BUILT_PRODUCTS_DIR)/libbackend_coreml-ios-release.a \
16+
-force_load $(BUILT_PRODUCTS_DIR)/libbackend_mps-ios-release.a \
17+
-force_load $(BUILT_PRODUCTS_DIR)/libbackend_xnnpack-ios-release.a
18+
19+
OTHER_LDFLAGS[sdk=macos*] = $(inherited) \
20+
-force_load $(BUILT_PRODUCTS_DIR)/libexecutorch-macos-release.a \
21+
-force_load $(BUILT_PRODUCTS_DIR)/libkernels_portable-macos-release.a \
22+
-force_load $(BUILT_PRODUCTS_DIR)/libkernels_custom-macos-release.a \
23+
-force_load $(BUILT_PRODUCTS_DIR)/libkernels_quantized-macos-release.a \
24+
-force_load $(BUILT_PRODUCTS_DIR)/libbackend_coreml-macos-release.a \
25+
-force_load $(BUILT_PRODUCTS_DIR)/libbackend_mps-macos-release.a \
26+
-force_load $(BUILT_PRODUCTS_DIR)/libbackend_xnnpack-macos-release.a
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"configurations" : [
3+
{
4+
"id" : "0430A5ED-FD8D-444E-9933-740E01CCD53C",
5+
"name" : "Test Scheme Action",
6+
"options" : {
7+
8+
}
9+
}
10+
],
11+
"defaultOptions" : {
12+
"targetForVariableExpansion" : {
13+
"containerPath" : "container:Benchmark.xcodeproj",
14+
"identifier" : "03B2D3632C8A515A0046936E",
15+
"name" : "App"
16+
}
17+
},
18+
"testTargets" : [
19+
{
20+
"target" : {
21+
"containerPath" : "container:Benchmark.xcodeproj",
22+
"identifier" : "03B2D3742C8A515C0046936E",
23+
"name" : "Tests"
24+
}
25+
}
26+
],
27+
"version" : 1
28+
}

0 commit comments

Comments
 (0)