Skip to content

Commit fa07ed9

Browse files
authored
Add support for data path in iOS (#13620)
^ Add constructor for the equivalent module constructor
1 parent 6666be1 commit fa07ed9

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

extension/apple/ExecuTorch/Exported/ExecuTorchModule.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,30 @@ __attribute__((deprecated("This API is experimental.")))
124124
@interface ExecuTorchModule : NSObject
125125

126126
/**
127-
* Initializes a module with a file path and a specified load mode.
127+
* Initializes a module with a file path, data path and a specified load mode.
128128
*
129129
* @param filePath A string representing the path to the ExecuTorch program file.
130-
* @param loadMode A value from ExecuTorchModuleLoadMode that determines the file loading behavior.
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.
131134
* @return An initialized ExecuTorchModule instance.
132135
*/
133136
- (instancetype)initWithFilePath:(NSString *)filePath
137+
dataFilePath:(NSString *)dataPath
134138
loadMode:(ExecuTorchModuleLoadMode)loadMode
135139
NS_DESIGNATED_INITIALIZER;
136140

141+
/**
142+
* Initializes a module with a file path and a specified load mode.
143+
*
144+
* @param filePath A string representing the path to the ExecuTorch program file.
145+
* @param loadMode A value from ExecuTorchModuleLoadMode that determines the file loading behavior.
146+
* @return An initialized ExecuTorchModule instance.
147+
*/
148+
- (instancetype)initWithFilePath:(NSString *)filePath
149+
loadMode:(ExecuTorchModuleLoadMode)loadMode;
150+
137151
/**
138152
* Initializes a module with a file path using the default load mode (File mode).
139153
*

extension/apple/ExecuTorch/Exported/ExecuTorchModule.mm

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,13 @@ @implementation ExecuTorchModule {
250250
}
251251

252252
- (instancetype)initWithFilePath:(NSString *)filePath
253+
dataFilePath:(NSString *)dataFilePath
253254
loadMode:(ExecuTorchModuleLoadMode)loadMode {
254255
self = [super init];
255256
if (self) {
256257
_module = std::make_unique<Module>(
257258
filePath.UTF8String,
259+
dataFilePath.UTF8String,
258260
static_cast<Module::LoadMode>(loadMode)
259261
);
260262
_inputs = [NSMutableDictionary new];
@@ -263,8 +265,16 @@ - (instancetype)initWithFilePath:(NSString *)filePath
263265
return self;
264266
}
265267

268+
- (instancetype)initWithFilePath:(NSString *)filePath
269+
loadMode:(ExecuTorchModuleLoadMode)loadMode {
270+
return [self initWithFilePath:filePath
271+
dataFilePath:@""
272+
loadMode:loadMode];
273+
}
266274
- (instancetype)initWithFilePath:(NSString *)filePath {
267-
return [self initWithFilePath:filePath loadMode:ExecuTorchModuleLoadModeFile];
275+
return [self initWithFilePath:filePath
276+
dataFilePath:@""
277+
loadMode:ExecuTorchModuleLoadModeFile];
268278
}
269279

270280
- (BOOL)loadWithVerification:(ExecuTorchVerification)verification

0 commit comments

Comments
 (0)