File tree Expand file tree Collapse file tree 2 files changed +42
-1
lines changed
extension/apple/ExecuTorch/Exported Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -22,10 +22,33 @@ typedef NS_ENUM(NSInteger, ExecuTorchModuleLoadMode) {
2222 ExecuTorchModuleLoadModeMmapUseMlockIgnoreErrors,
2323} NS_SWIFT_NAME(ModuleLoadMode);
2424
25+ /* *
26+ * Represents a module that encapsulates an ExecuTorch program.
27+ * This class is a facade for loading programs and executing methods within them.
28+ */
2529NS_SWIFT_NAME (Module)
2630__attribute__((deprecated(" This API is experimental." )))
2731@interface ExecuTorchModule : NSObject
2832
33+ /* *
34+ * Initializes a module with a file path and a specified load mode.
35+ *
36+ * @param filePath A string representing the path to the ExecuTorch program file.
37+ * @param loadMode A value from ExecuTorchModuleLoadMode that determines the file loading behavior.
38+ * @return An initialized ExecuTorchModule instance.
39+ */
40+ - (instancetype )initWithFilePath:(NSString *)filePath
41+ loadMode:(ExecuTorchModuleLoadMode)loadMode
42+ NS_DESIGNATED_INITIALIZER;
43+
44+ /* *
45+ * Initializes a module with a file path using the default load mode (File mode).
46+ *
47+ * @param filePath A string representing the path to the ExecuTorch program file.
48+ * @return An initialized ExecuTorchModule instance.
49+ */
50+ - (instancetype )initWithFilePath:(NSString *)filePath;
51+
2952+ (instancetype )new NS_UNAVAILABLE;
3053- (instancetype )init NS_UNAVAILABLE;
3154
Original file line number Diff line number Diff line change 1313#import < executorch/extension/module/module.h>
1414#import < executorch/extension/tensor/tensor.h>
1515
16+ using namespace executorch ::extension;
17+
1618@implementation ExecuTorchModule {
17- std::unique_ptr<executorch::extension::Module> _module;
19+ std::unique_ptr<Module> _module;
20+ }
21+
22+ - (instancetype )initWithFilePath : (NSString *)filePath
23+ loadMode : (ExecuTorchModuleLoadMode)loadMode {
24+ self = [super init ];
25+ if (self) {
26+ _module = std::make_unique<Module>(
27+ filePath.UTF8String ,
28+ static_cast <Module::LoadMode>(loadMode)
29+ );
30+ }
31+ return self;
32+ }
33+
34+ - (instancetype )initWithFilePath : (NSString *)filePath {
35+ return [self initWithFilePath: filePath loadMode: ExecuTorchModuleLoadModeFile];
1836}
1937
2038@end
You can’t perform that action at this time.
0 commit comments