Skip to content

Commit eef7b44

Browse files
authored
Lay out ObjC/Swift bindings skeleton (#8826)
1 parent a5f9210 commit eef7b44

File tree

12 files changed

+198
-0
lines changed

12 files changed

+198
-0
lines changed

extension/apple/ExecuTorch/Exported/ExecuTorch.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9+
#import "ExecuTorchError.h"
910
#import "ExecuTorchLog.h"
11+
#import "ExecuTorchModule.h"
12+
#import "ExecuTorchTensor.h"
13+
#import "ExecuTorchValue.h"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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 <Foundation/Foundation.h>
10+
11+
NS_ASSUME_NONNULL_BEGIN
12+
13+
FOUNDATION_EXPORT NSErrorDomain const ExecuTorchErrorDomain NS_SWIFT_NAME(ErrorDomain);
14+
15+
NS_ASSUME_NONNULL_END
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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 "ExecuTorchError.h"
10+
11+
NSErrorDomain const ExecuTorchErrorDomain = @"org.pytorch.executorch.error";
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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 "ExecuTorchValue.h"
10+
11+
NS_ASSUME_NONNULL_BEGIN
12+
13+
NS_SWIFT_NAME(Module)
14+
__attribute__((deprecated("This API is experimental.")))
15+
@interface ExecuTorchModule : NSObject
16+
17+
+ (instancetype)new NS_UNAVAILABLE;
18+
- (instancetype)init NS_UNAVAILABLE;
19+
20+
@end
21+
22+
NS_ASSUME_NONNULL_END
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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 "ExecuTorchModule.h"
10+
11+
#import "ExecuTorchError.h"
12+
13+
#import <executorch/extension/module/module.h>
14+
#import <executorch/extension/tensor/tensor.h>
15+
16+
@implementation ExecuTorchModule {
17+
std::unique_ptr<executorch::extension::Module> _module;
18+
}
19+
20+
@end
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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 <Foundation/Foundation.h>
10+
11+
NS_ASSUME_NONNULL_BEGIN
12+
13+
NS_SWIFT_NAME(Tensor)
14+
__attribute__((deprecated("This API is experimental.")))
15+
@interface ExecuTorchTensor : NSObject
16+
17+
+ (instancetype)new NS_UNAVAILABLE;
18+
- (instancetype)init NS_UNAVAILABLE;
19+
20+
@end
21+
22+
NS_ASSUME_NONNULL_END
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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 "ExecuTorchTensor.h"
10+
11+
#import "ExecuTorchError.h"
12+
13+
#import <executorch/extension/tensor/tensor.h>
14+
15+
@implementation ExecuTorchTensor {
16+
::executorch::extension::TensorPtr _tensor;
17+
}
18+
19+
@end
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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 "ExecuTorchTensor.h"
10+
11+
NS_ASSUME_NONNULL_BEGIN
12+
13+
NS_SWIFT_NAME(Value)
14+
__attribute__((deprecated("This API is experimental.")))
15+
@interface ExecuTorchValue : NSObject
16+
17+
@end
18+
19+
NS_ASSUME_NONNULL_END
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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 "ExecuTorchValue.h"
10+
11+
@implementation ExecuTorchValue
12+
13+
@end
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
@testable import ExecuTorch
10+
11+
import XCTest
12+
13+
class ModuleTest: XCTestCase {
14+
func test() throws {
15+
let bundle = Bundle(for: type(of: self))
16+
guard let modelPath = bundle.path(forResource: "add", ofType: "pte") else {
17+
XCTFail("Couldn't find the model file")
18+
return
19+
}
20+
}
21+
}
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+
@testable import ExecuTorch
10+
11+
import XCTest
12+
13+
class TensorTest: XCTestCase {
14+
func test() {
15+
}
16+
}
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+
@testable import ExecuTorch
10+
11+
import XCTest
12+
13+
class ValueTest: XCTestCase {
14+
func test() {
15+
}
16+
}

0 commit comments

Comments
 (0)