Skip to content

Commit 4b5ebf7

Browse files
bsoyluogluDannyYuyang-quic
authored andcommitted
Remove protocols and make executorch runtime bridge standalone
Differential Revision: D71420184 Pull Request resolved: pytorch#9398
1 parent b183bc3 commit 4b5ebf7

File tree

17 files changed

+14
-309
lines changed

17 files changed

+14
-309
lines changed

extension/apple/ExecutorchRuntime/ExecutorchRuntime/ExecutorchRuntime.swift

Lines changed: 0 additions & 34 deletions
This file was deleted.

extension/apple/ExecutorchRuntime/ExecutorchRuntime/__tests__/ExecutorchRuntimeTests.swift

Lines changed: 0 additions & 30 deletions
This file was deleted.

extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/Exported/Data/ExecutorchRuntimeTensorValue.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
#import <executorch/extension/module/module.h>
1111
#import <executorch/runtime/core/evalue.h>
1212
#endif
13-
#import <ModelRunnerDataKit/ModelRunnerDataKit-Swift.h>
13+
#import <RuntimeBridgingCore/RuntimeBridgingCore-Swift.h>
1414

1515
NS_ASSUME_NONNULL_BEGIN
1616

17-
@interface ExecutorchRuntimeTensorValue : NSObject <ModelRuntimeTensorValueBridging>
17+
@interface ExecutorchRuntimeTensorValue : NSObject
1818

1919
- (instancetype)init NS_UNAVAILABLE;
2020
+ (instancetype)new NS_UNAVAILABLE;
@@ -28,6 +28,9 @@ NS_ASSUME_NONNULL_BEGIN
2828
- (torch::executor::Tensor)backedValue;
2929
#endif
3030

31+
#pragma mark -
32+
- (ModelRuntimeTensorValueBridgingTuple * _Nullable)floatRepresentationAndReturnError:(NSError * _Nullable * _Nullable)error SWIFT_WARN_UNUSED_RESULT;
33+
3134
@end
3235

3336
NS_ASSUME_NONNULL_END

extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/Exported/Data/ExecutorchRuntimeValue.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
#import <executorch/runtime/core/evalue.h>
1212
#endif
1313

14-
#import <ModelRunnerDataKit/ModelRunnerDataKit-Swift.h>
14+
#import <RuntimeBridgingCore/RuntimeBridgingCore-Swift.h>
1515

1616
#import "ExecutorchRuntimeTensorValue.h"
1717

1818
NS_ASSUME_NONNULL_BEGIN
1919

20-
@interface ExecutorchRuntimeValue : NSObject <ModelRuntimeValueBridging>
20+
@interface ExecutorchRuntimeValue : NSObject
2121

2222
- (instancetype)init NS_UNAVAILABLE;
2323
+ (instancetype)new NS_UNAVAILABLE;
@@ -29,6 +29,9 @@ NS_ASSUME_NONNULL_BEGIN
2929
- (torch::executor::EValue)getBackedValue;
3030
#endif
3131

32+
#pragma mark -
33+
- (ExecutorchRuntimeTensorValue *_Nullable)asTensorValueAndReturnError:(NSError * _Nullable * _Nullable)error SWIFT_WARN_UNUSED_RESULT;
34+
3235
@end
3336

3437
NS_ASSUME_NONNULL_END

extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/Exported/Data/ExecutorchRuntimeValue.mm

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,7 @@ - (instancetype)initWithTensor:(ExecutorchRuntimeTensorValue *)tensorValue
4141
return self;
4242
}
4343

44-
- (nullable NSString *)stringValueAndReturnError:(NSError * _Nullable * _Nullable)error
45-
{
46-
if (error) {
47-
*error = [ModelRuntimeValueErrorFactory unsupportedType:@"ExecutorchRuntimeValue doesn't support strings"];
48-
}
49-
return nil;
50-
}
51-
52-
- (nullable id<ModelRuntimeTensorValueBridging>)tensorValueAndReturnError:(NSError * _Nullable * _Nullable)error
44+
- (nullable ExecutorchRuntimeTensorValue *)asTensorValueAndReturnError:(NSError * _Nullable * _Nullable)error
5345
{
5446
if (_value.isTensor()) {
5547
return [[ExecutorchRuntimeTensorValue alloc] initWithTensor:_value.toTensor() error:error];
@@ -68,12 +60,4 @@ - (EValue)getBackedValue
6860
return _value;
6961
}
7062

71-
- (NSArray<id<ModelRuntimeValueBridging>> *)arrayValueAndReturnError:(NSError * _Nullable * _Nullable)error
72-
{
73-
if (error) {
74-
*error = [ModelRuntimeValueErrorFactory unsupportedType:@"EValue doesn't support arrays"];
75-
}
76-
return nil;
77-
}
78-
7963
@end

extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/__tests__/ExecutorchRuntimeEngineTests.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ - (void)testValidModel
5151
XCTAssertEqual(output.count, 1);
5252
NSError *tensorValueError = nil;
5353
NSError *floatRepresentationError = nil;
54-
const auto resultTensorValue = [[output.firstObject tensorValueAndReturnError:&tensorValueError]
54+
const auto resultTensorValue = [[output.firstObject asTensorValueAndReturnError:&tensorValueError]
5555
floatRepresentationAndReturnError:&floatRepresentationError];
5656

5757
XCTAssertNil(tensorValueError);

extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/__tests__/ExecutorchRuntimeValueTests.mm

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#import <XCTest/XCTest.h>
1010

1111
#import <ExecutorchRuntimeBridge/ExecutorchRuntimeValue.h>
12-
#import <ModelRunnerDataKit/ModelRunnerDataKit-Swift.h>
1312
#import <executorch/extension/module/module.h>
1413

1514
using torch::executor::EValue;
@@ -21,16 +20,6 @@ @interface ExecutorchRuntimeValueTests : XCTestCase
2120

2221
@implementation ExecutorchRuntimeValueTests
2322

24-
- (void)testStringValueWithError
25-
{
26-
ExecutorchRuntimeValue *value = [[ExecutorchRuntimeValue alloc] initWithEValue:EValue((int64_t)1)];
27-
XCTAssertNil([value stringValueAndReturnError:nil]);
28-
NSError *error = nil;
29-
XCTAssertNil([value stringValueAndReturnError:&error]);
30-
XCTAssertNotNil(error);
31-
XCTAssertEqualObjects([error description], @"Unsupported type: ExecutorchRuntimeValue doesn't support strings");
32-
}
33-
3423
- (void)testTensorValue
3524
{
3625
NSMutableArray *data = [NSMutableArray new];
@@ -63,9 +52,9 @@ - (void)testTensorValueWithFloatArrayWithError
6352
- (void)testTensorValueWithError
6453
{
6554
ExecutorchRuntimeValue *value = [[ExecutorchRuntimeValue alloc] initWithEValue:EValue((int64_t)1)];
66-
XCTAssertNil([value tensorValueAndReturnError:nil]);
55+
XCTAssertNil([value asTensorValueAndReturnError:nil]);
6756
NSError *error = nil;
68-
XCTAssertNil([value tensorValueAndReturnError:&error]);
57+
XCTAssertNil([value asTensorValueAndReturnError:&error]);
6958
XCTAssertNotNil(error);
7059
XCTAssertEqualObjects([error description], @"Invalid type: Tag::4, expected Tag::Tensor");
7160
}

extension/apple/ExecutorchRuntimeValueSupport/ExecutorchRuntimeValueSupport/ExecutorchRuntimeValueSupport.swift

Lines changed: 0 additions & 45 deletions
This file was deleted.

extension/apple/ExecutorchRuntimeValueSupport/ExecutorchRuntimeValueSupport/__tests__/ExecutorchRuntimeValueSupportTests.swift

Lines changed: 0 additions & 48 deletions
This file was deleted.

extension/apple/ModelRunnerDataKit/ModelRunnerDataKit/ModelRuntime.swift

Lines changed: 0 additions & 20 deletions
This file was deleted.

extension/apple/ModelRunnerDataKit/ModelRunnerDataKit/Tensor/ModelRuntimeTensorValue.swift

Lines changed: 0 additions & 23 deletions
This file was deleted.

extension/apple/ModelRunnerDataKit/ModelRunnerDataKit/Tensor/ModelRuntimeTensorValueFactory.swift

Lines changed: 0 additions & 13 deletions
This file was deleted.

extension/apple/ModelRunnerDataKit/ModelRunnerDataKit/Value/ModelRuntimeValue.swift

Lines changed: 0 additions & 28 deletions
This file was deleted.

extension/apple/ModelRunnerDataKit/ModelRunnerDataKit/Value/ModelRuntimeValueBridging.swift

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)