1// 2// ETCoreMLStrings.mm 3// 4// Copyright © 2024 Apple Inc. All rights reserved. 5// 6// Please refer to the license found in the LICENSE file in the root directory of the source tree. 7 8 9#import "ETCoreMLStrings.h" 10 11@implementation ETCoreMLStrings 12 13+ (NSString *)productName { 14 static NSString * const ETCoreMLProductName = @"executorchcoreml"; 15 return ETCoreMLProductName; 16} 17 18+ (NSString *)productIdentifier { 19 static NSString * const ETCoreMLProductIdentifier = @"com.apple.executorchcoreml"; 20 return ETCoreMLProductIdentifier; 21} 22 23+ (NSString *)delegateIdentifier { 24 static NSString * const ETCoreMLDelegateIdentifier = @"CoreMLBackend"; 25 return ETCoreMLDelegateIdentifier; 26} 27 28+ (NSString *)configPlistName { 29 static NSString * const ETCoreMLDelegateConfigPlistName = @"com.apple.executorchcoreml_config"; 30 return ETCoreMLDelegateConfigPlistName; 31} 32 33+ (NSString *)computeUnitsKeyName { 34 static NSString * const ETCoreMLComputeUnitsName = @"compute_units"; 35 return ETCoreMLComputeUnitsName; 36} 37 38+ (NSString *)compiledModelExtensionName { 39 static NSString * const ETCoreMLCompiledModelExtensionName = @"mlmodelc"; 40 return ETCoreMLCompiledModelExtensionName; 41} 42 43+ (NSString *)modelExtensionName { 44 static NSString * const ETCoreMLModelExtensionName = @"mlpackage"; 45 return ETCoreMLModelExtensionName; 46} 47 48+ (NSString *)metadataFileRelativePath { 49 static NSString * const ETCoreMLMetadataFileRelativePath = @"metadata.json"; 50 return ETCoreMLMetadataFileRelativePath; 51} 52 53+ (NSString *)modelFileRelativePath { 54 static NSString * const ETCoreMLModelFileRelativePath = @"model.mlpackage"; 55 return ETCoreMLModelFileRelativePath; 56} 57 58+ (NSString *)compiledModelFileRelativePath { 59 static NSString * const ETCoreMLCompiledModelFileRelativePath = @"model.mlmodelc"; 60 return ETCoreMLCompiledModelFileRelativePath; 61} 62 63+ (NSString *)cpuComputeUnitName { 64 static NSString * const ETCoreMLCPUComputeUnitName = @"cpu_only"; 65 return ETCoreMLCPUComputeUnitName; 66} 67 68+ (NSString *)cpuAndGpuComputeUnitsName { 69 static NSString * const ETCoreMLCPUAndGPUComputeUnitsName = @"cpu_and_gpu"; 70 return ETCoreMLCPUAndGPUComputeUnitsName; 71} 72 73+ (NSString *)cpuAndNeuralEngineComputeUnitsName { 74 static NSString * const ETCoreMLCPUAndNeuralEngineComputeUnitsName = @"cpu_and_ne"; 75 return ETCoreMLCPUAndNeuralEngineComputeUnitsName; 76} 77 78+ (NSString *)allComputeUnitsName { 79 static NSString * const ETCoreMLAllComputeUnitsName = @"all"; 80 return ETCoreMLAllComputeUnitsName; 81} 82 83+ (NSString *)databaseName { 84 static NSString * const ETCoreMLDatabaseName = @"assets.db"; 85 return ETCoreMLDatabaseName; 86} 87 88+ (NSString *)debugInfoFileRelativePath { 89 static NSString * const ETCoreMLDebugInfoFileRelativePath = @"debug_info.json"; 90 return ETCoreMLDebugInfoFileRelativePath; 91} 92 93+ (NSString *)debugSymbolToOperationPathKeyName { 94 static NSString * const ETCoreMLDebugSymbolToOperationPathKeyName = @"debugSymbolToOperationPath"; 95 return ETCoreMLDebugSymbolToOperationPathKeyName; 96} 97 98+ (NSString *)debugSymbolToHandlesKeyName { 99 static NSString * const ETCoreMLDebugSymbolToHandlesKeyName = @"debugSymbolToHandles"; 100 return ETCoreMLDebugSymbolToHandlesKeyName; 101} 102 103+ (nullable NSString *)assetsDirectoryPath { 104 static dispatch_once_t onceToken; 105 static NSString *result = nil; 106 dispatch_once(&onceToken, ^{ 107 NSArray<NSString *> *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); 108 if (paths.count > 0) { 109 result = [paths.lastObject stringByAppendingPathComponent:self.productName]; 110 } 111 }); 112 113 return result; 114} 115 116+ (nullable NSString *)trashDirectoryPath { 117 static dispatch_once_t onceToken; 118 static NSString *result = nil; 119 dispatch_once(&onceToken, ^{ 120 result = [NSTemporaryDirectory() stringByAppendingPathComponent:self.productName]; 121 }); 122 123 return result; 124} 125 126+ (nullable NSString *)databaseDirectoryPath { 127 static dispatch_once_t onceToken; 128 static NSString *result = nil; 129 dispatch_once(&onceToken, ^{ 130 NSArray<NSString *> *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); 131 if (paths.count > 0) { 132 result = [paths.lastObject stringByAppendingPathComponent:self.productName]; 133 } 134 }); 135 136 return result; 137} 138 139 140@end 141