Skip to content

Commit 0b78b72

Browse files
committed
data path support for ios
1 parent fe84495 commit 0b78b72

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

extension/apple/ExecuTorch/Exported/ExecuTorchModule.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,21 @@ NS_SWIFT_NAME(Module)
123123
__attribute__((deprecated("This API is experimental.")))
124124
@interface ExecuTorchModule : NSObject
125125

126+
/**
127+
* Initializes a module with a file path, data path and a specified load mode.
128+
*
129+
* @param filePath A string representing the path to the ExecuTorch program file.
130+
* @param dataFilePath A string representing the path to a .ptd file with
131+
* external tensors and external data.
132+
* @param loadMode A value from ExecuTorchModuleLoadMode that determines the
133+
* file loading behavior.
134+
* @return An initialized ExecuTorchModule instance.
135+
*/
136+
- (instancetype)initWithFilePath:(NSString *)filePath
137+
dataFilePath:(NSString *)dataPath
138+
loadMode:(ExecuTorchModuleLoadMode)loadMode
139+
NS_DESIGNATED_INITIALIZER;
140+
126141
/**
127142
* Initializes a module with a file path and a specified load mode.
128143
*

extension/apple/ExecuTorch/Exported/ExecuTorchModule.mm

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,22 @@ @implementation ExecuTorchModule {
249249
NSMutableDictionary<NSString *, NSMutableArray<ExecuTorchValue *> *> *_outputs;
250250
}
251251

252+
- (instancetype)initWithFilePath:(NSString *)filePath
253+
dataFilePath:(NSString *)dataFilePath
254+
loadMode:(ExecuTorchModuleLoadMode)loadMode {
255+
self = [super init];
256+
if (self) {
257+
_module = std::make_unique<Module>(
258+
filePath.UTF8String,
259+
dataFilePath.UTF8String,
260+
static_cast<Module::LoadMode>(loadMode)
261+
);
262+
_inputs = [NSMutableDictionary new];
263+
_outputs = [NSMutableDictionary new];
264+
}
265+
return self;
266+
}
267+
252268
- (instancetype)initWithFilePath:(NSString *)filePath
253269
loadMode:(ExecuTorchModuleLoadMode)loadMode {
254270
self = [super init];

0 commit comments

Comments
 (0)