Skip to content

Commit 2fd1ef7

Browse files
committed
rename ane
1 parent e468802 commit 2fd1ef7

File tree

8 files changed

+96
-85
lines changed

8 files changed

+96
-85
lines changed

tools/mtmd/CMakeLists.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ add_library(mtmd
1818
# 在Apple平台上添加ANE相关文件
1919
if(APPLE)
2020
target_sources(mtmd PRIVATE
21-
ane.h
22-
ane.mm
23-
ane_minicpm4v3b_vision_f16_b1.h
24-
ane_minicpm4v3b_vision_f16_b1.m
21+
ane/ane.h
22+
ane/ane.mm
23+
ane/ane_minicpmv4_vit_f16.h
24+
ane/ane_minicpmv4_vit_f16.m
2525
)
2626

2727
# 为Objective-C文件启用ARC
28-
set_source_files_properties(ane.mm PROPERTIES COMPILE_FLAGS "-fobjc-arc")
29-
set_source_files_properties(ane_minicpm4v3b_vision_f16_b1.m PROPERTIES COMPILE_FLAGS "-fobjc-arc")
28+
set_source_files_properties(ane/ane.mm PROPERTIES COMPILE_FLAGS "-fobjc-arc")
29+
set_source_files_properties(ane/ane_minicpmv4_vit_f16.m PROPERTIES COMPILE_FLAGS "-fobjc-arc")
3030
endif()
3131

3232
target_link_libraries (mtmd PUBLIC ggml llama common)
@@ -65,7 +65,7 @@ set(MTMD_PUBLIC_HEADERS
6565
# 在Apple平台上添加ANE公共头文件
6666
if(APPLE)
6767
list(APPEND MTMD_PUBLIC_HEADERS
68-
${CMAKE_CURRENT_SOURCE_DIR}/ane.h
68+
${CMAKE_CURRENT_SOURCE_DIR}/ane/ane.h
6969
)
7070
endif()
7171

File renamed without changes.

tools/mtmd/ane.mm renamed to tools/mtmd/ane/ane.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#import <CoreML/CoreML.h>
22
#import <Accelerate/Accelerate.h>
33
#import "ane.h"
4-
#import "ane_minicpm4v3b_vision_f16_b1.h"
4+
#import "ane_minicpmv4_vit_f16.h"
55
#include <stdlib.h>
66

77
#if __cplusplus
@@ -14,12 +14,12 @@
1414
NSFileManager *fileManager = [NSFileManager defaultManager];
1515
// 获取应用的 Documents 目录的 URL
1616
NSURL *documentsURL = [[fileManager URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] firstObject];
17-
NSString *pathString = [documentsURL.absoluteString stringByAppendingString:@"ane_minicpm4v3b_vision_f16_b1.mlmodelc"];
17+
NSString *pathString = [documentsURL.absoluteString stringByAppendingString:@"ane_minicpmv4_vit_f16.mlmodelc"];
1818
NSURL *modelURL = [NSURL URLWithString:pathString];
1919

2020
NSLog(modelURL.absoluteString);
2121

22-
const void* model = CFBridgingRetain([[ane_minicpm4v3b_vision_f16_b1 alloc] initWithContentsOfURL:modelURL error:nil]);
22+
const void* model = CFBridgingRetain([[ane_minicpmv4_vit_f16 alloc] initWithContentsOfURL:modelURL error:nil]);
2323
return model;
2424
}
2525

@@ -31,7 +31,7 @@ void predictWith(const void* model, float* embed, float* encoderOutput) {
3131
deallocator: nil
3232
error: nil];
3333

34-
ane_minicpm4v3b_vision_f16_b1Output *modelOutput = [(__bridge id)model predictionFromInput:inMultiArray error:nil];
34+
ane_minicpmv4_vit_f16Output *modelOutput = [(__bridge id)model predictionFromInput:inMultiArray error:nil];
3535

3636
MLMultiArray *outMA = modelOutput.output;
3737

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// ane_minicpm4v3b_vision_f16_b1.h
2+
// ane_minicpmv4_vit_f16.h
33
//
44
// This file was automatically generated and should not be edited.
55
//
@@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
1313

1414
/// Model Prediction Input Type
1515
API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)) __attribute__((visibility("hidden")))
16-
@interface ane_minicpm4v3b_vision_f16_b1Input : NSObject<MLFeatureProvider>
16+
@interface ane_minicpmv4_vit_f16Input : NSObject<MLFeatureProvider>
1717

1818
/// input as 1 × 1024 × 1152 3-dimensional array of floats
1919
@property (readwrite, nonatomic, strong) MLMultiArray * input;
@@ -24,7 +24,7 @@ API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)) __attribute__((v
2424

2525
/// Model Prediction Output Type
2626
API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)) __attribute__((visibility("hidden")))
27-
@interface ane_minicpm4v3b_vision_f16_b1Output : NSObject<MLFeatureProvider>
27+
@interface ane_minicpmv4_vit_f16Output : NSObject<MLFeatureProvider>
2828

2929
/// output as 1 × 1024 × 1152 3-dimensional array of floats
3030
@property (readwrite, nonatomic, strong) MLMultiArray * output;
@@ -35,7 +35,7 @@ API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)) __attribute__((v
3535

3636
/// Class for model loading and prediction
3737
API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)) __attribute__((visibility("hidden")))
38-
@interface ane_minicpm4v3b_vision_f16_b1 : NSObject
38+
@interface ane_minicpmv4_vit_f16 : NSObject
3939
@property (readonly, nonatomic, nullable) MLModel * model;
4040

4141
/**
@@ -44,111 +44,111 @@ API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)) __attribute__((v
4444
+ (nullable NSURL *)URLOfModelInThisBundle;
4545

4646
/**
47-
Initialize ane_minicpm4v3b_vision_f16_b1 instance from an existing MLModel object.
47+
Initialize ane_minicpmv4_vit_f16 instance from an existing MLModel object.
4848
49-
Usually the application does not use this initializer unless it makes a subclass of ane_minicpm4v3b_vision_f16_b1.
49+
Usually the application does not use this initializer unless it makes a subclass of ane_minicpmv4_vit_f16.
5050
Such application may want to use `-[MLModel initWithContentsOfURL:configuration:error:]` and `+URLOfModelInThisBundle` to create a MLModel object to pass-in.
5151
*/
5252
- (instancetype)initWithMLModel:(MLModel *)model NS_DESIGNATED_INITIALIZER;
5353

5454
/**
55-
Initialize ane_minicpm4v3b_vision_f16_b1 instance with the model in this bundle.
55+
Initialize ane_minicpmv4_vit_f16 instance with the model in this bundle.
5656
*/
5757
- (nullable instancetype)init;
5858

5959
/**
60-
Initialize ane_minicpm4v3b_vision_f16_b1 instance with the model in this bundle.
60+
Initialize ane_minicpmv4_vit_f16 instance with the model in this bundle.
6161
6262
@param configuration The model configuration object
6363
@param error If an error occurs, upon return contains an NSError object that describes the problem. If you are not interested in possible errors, pass in NULL.
6464
*/
6565
- (nullable instancetype)initWithConfiguration:(MLModelConfiguration *)configuration error:(NSError * _Nullable __autoreleasing * _Nullable)error;
6666

6767
/**
68-
Initialize ane_minicpm4v3b_vision_f16_b1 instance from the model URL.
68+
Initialize ane_minicpmv4_vit_f16 instance from the model URL.
6969
70-
@param modelURL URL to the .mlmodelc directory for ane_minicpm4v3b_vision_f16_b1.
70+
@param modelURL URL to the .mlmodelc directory for ane_minicpmv4_vit_f16.
7171
@param error If an error occurs, upon return contains an NSError object that describes the problem. If you are not interested in possible errors, pass in NULL.
7272
*/
7373
- (nullable instancetype)initWithContentsOfURL:(NSURL *)modelURL error:(NSError * _Nullable __autoreleasing * _Nullable)error;
7474

7575
/**
76-
Initialize ane_minicpm4v3b_vision_f16_b1 instance from the model URL.
76+
Initialize ane_minicpmv4_vit_f16 instance from the model URL.
7777
78-
@param modelURL URL to the .mlmodelc directory for ane_minicpm4v3b_vision_f16_b1.
78+
@param modelURL URL to the .mlmodelc directory for ane_minicpmv4_vit_f16.
7979
@param configuration The model configuration object
8080
@param error If an error occurs, upon return contains an NSError object that describes the problem. If you are not interested in possible errors, pass in NULL.
8181
*/
8282
- (nullable instancetype)initWithContentsOfURL:(NSURL *)modelURL configuration:(MLModelConfiguration *)configuration error:(NSError * _Nullable __autoreleasing * _Nullable)error;
8383

8484
/**
85-
Construct ane_minicpm4v3b_vision_f16_b1 instance asynchronously with configuration.
85+
Construct ane_minicpmv4_vit_f16 instance asynchronously with configuration.
8686
Model loading may take time when the model content is not immediately available (e.g. encrypted model). Use this factory method especially when the caller is on the main thread.
8787
8888
@param configuration The model configuration
89-
@param handler When the model load completes successfully or unsuccessfully, the completion handler is invoked with a valid ane_minicpm4v3b_vision_f16_b1 instance or NSError object.
89+
@param handler When the model load completes successfully or unsuccessfully, the completion handler is invoked with a valid ane_minicpmv4_vit_f16 instance or NSError object.
9090
*/
91-
+ (void)loadWithConfiguration:(MLModelConfiguration *)configuration completionHandler:(void (^)(ane_minicpm4v3b_vision_f16_b1 * _Nullable model, NSError * _Nullable error))handler;
91+
+ (void)loadWithConfiguration:(MLModelConfiguration *)configuration completionHandler:(void (^)(ane_minicpmv4_vit_f16 * _Nullable model, NSError * _Nullable error))handler;
9292

9393
/**
94-
Construct ane_minicpm4v3b_vision_f16_b1 instance asynchronously with URL of .mlmodelc directory and optional configuration.
94+
Construct ane_minicpmv4_vit_f16 instance asynchronously with URL of .mlmodelc directory and optional configuration.
9595
9696
Model loading may take time when the model content is not immediately available (e.g. encrypted model). Use this factory method especially when the caller is on the main thread.
9797
9898
@param modelURL The model URL.
9999
@param configuration The model configuration
100-
@param handler When the model load completes successfully or unsuccessfully, the completion handler is invoked with a valid ane_minicpm4v3b_vision_f16_b1 instance or NSError object.
100+
@param handler When the model load completes successfully or unsuccessfully, the completion handler is invoked with a valid ane_minicpmv4_vit_f16 instance or NSError object.
101101
*/
102-
+ (void)loadContentsOfURL:(NSURL *)modelURL configuration:(MLModelConfiguration *)configuration completionHandler:(void (^)(ane_minicpm4v3b_vision_f16_b1 * _Nullable model, NSError * _Nullable error))handler;
102+
+ (void)loadContentsOfURL:(NSURL *)modelURL configuration:(MLModelConfiguration *)configuration completionHandler:(void (^)(ane_minicpmv4_vit_f16 * _Nullable model, NSError * _Nullable error))handler;
103103

104104
/**
105105
Make a prediction using the standard interface
106-
@param input an instance of ane_minicpm4v3b_vision_f16_b1Input to predict from
106+
@param input an instance of ane_minicpmv4_vit_f16Input to predict from
107107
@param error If an error occurs, upon return contains an NSError object that describes the problem. If you are not interested in possible errors, pass in NULL.
108-
@return the prediction as ane_minicpm4v3b_vision_f16_b1Output
108+
@return the prediction as ane_minicpmv4_vit_f16Output
109109
*/
110-
- (nullable ane_minicpm4v3b_vision_f16_b1Output *)predictionFromFeatures:(ane_minicpm4v3b_vision_f16_b1Input *)input error:(NSError * _Nullable __autoreleasing * _Nullable)error;
110+
- (nullable ane_minicpmv4_vit_f16Output *)predictionFromFeatures:(ane_minicpmv4_vit_f16Input *)input error:(NSError * _Nullable __autoreleasing * _Nullable)error;
111111

112112
/**
113113
Make a prediction using the standard interface
114-
@param input an instance of ane_minicpm4v3b_vision_f16_b1Input to predict from
114+
@param input an instance of ane_minicpmv4_vit_f16Input to predict from
115115
@param options prediction options
116116
@param error If an error occurs, upon return contains an NSError object that describes the problem. If you are not interested in possible errors, pass in NULL.
117-
@return the prediction as ane_minicpm4v3b_vision_f16_b1Output
117+
@return the prediction as ane_minicpmv4_vit_f16Output
118118
*/
119-
- (nullable ane_minicpm4v3b_vision_f16_b1Output *)predictionFromFeatures:(ane_minicpm4v3b_vision_f16_b1Input *)input options:(MLPredictionOptions *)options error:(NSError * _Nullable __autoreleasing * _Nullable)error;
119+
- (nullable ane_minicpmv4_vit_f16Output *)predictionFromFeatures:(ane_minicpmv4_vit_f16Input *)input options:(MLPredictionOptions *)options error:(NSError * _Nullable __autoreleasing * _Nullable)error;
120120

121121
/**
122122
Make an asynchronous prediction using the standard interface
123-
@param input an instance of ane_minicpm4v3b_vision_f16_b1Input to predict from
123+
@param input an instance of ane_minicpmv4_vit_f16Input to predict from
124124
@param completionHandler a block that will be called upon completion of the prediction. error will be nil if no error occurred.
125125
*/
126-
- (void)predictionFromFeatures:(ane_minicpm4v3b_vision_f16_b1Input *)input completionHandler:(void (^)(ane_minicpm4v3b_vision_f16_b1Output * _Nullable output, NSError * _Nullable error))completionHandler API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0)) __attribute__((visibility("hidden")));
126+
- (void)predictionFromFeatures:(ane_minicpmv4_vit_f16Input *)input completionHandler:(void (^)(ane_minicpmv4_vit_f16Output * _Nullable output, NSError * _Nullable error))completionHandler API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0)) __attribute__((visibility("hidden")));
127127

128128
/**
129129
Make an asynchronous prediction using the standard interface
130-
@param input an instance of ane_minicpm4v3b_vision_f16_b1Input to predict from
130+
@param input an instance of ane_minicpmv4_vit_f16Input to predict from
131131
@param options prediction options
132132
@param completionHandler a block that will be called upon completion of the prediction. error will be nil if no error occurred.
133133
*/
134-
- (void)predictionFromFeatures:(ane_minicpm4v3b_vision_f16_b1Input *)input options:(MLPredictionOptions *)options completionHandler:(void (^)(ane_minicpm4v3b_vision_f16_b1Output * _Nullable output, NSError * _Nullable error))completionHandler API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0)) __attribute__((visibility("hidden")));
134+
- (void)predictionFromFeatures:(ane_minicpmv4_vit_f16Input *)input options:(MLPredictionOptions *)options completionHandler:(void (^)(ane_minicpmv4_vit_f16Output * _Nullable output, NSError * _Nullable error))completionHandler API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0)) __attribute__((visibility("hidden")));
135135

136136
/**
137137
Make a prediction using the convenience interface
138138
@param input 1 × 1024 × 1152 3-dimensional array of floats
139139
@param error If an error occurs, upon return contains an NSError object that describes the problem. If you are not interested in possible errors, pass in NULL.
140-
@return the prediction as ane_minicpm4v3b_vision_f16_b1Output
140+
@return the prediction as ane_minicpmv4_vit_f16Output
141141
*/
142-
- (nullable ane_minicpm4v3b_vision_f16_b1Output *)predictionFromInput:(MLMultiArray *)input error:(NSError * _Nullable __autoreleasing * _Nullable)error;
142+
- (nullable ane_minicpmv4_vit_f16Output *)predictionFromInput:(MLMultiArray *)input error:(NSError * _Nullable __autoreleasing * _Nullable)error;
143143

144144
/**
145145
Batch prediction
146-
@param inputArray array of ane_minicpm4v3b_vision_f16_b1Input instances to obtain predictions from
146+
@param inputArray array of ane_minicpmv4_vit_f16Input instances to obtain predictions from
147147
@param options prediction options
148148
@param error If an error occurs, upon return contains an NSError object that describes the problem. If you are not interested in possible errors, pass in NULL.
149-
@return the predictions as NSArray<ane_minicpm4v3b_vision_f16_b1Output *>
149+
@return the predictions as NSArray<ane_minicpmv4_vit_f16Output *>
150150
*/
151-
- (nullable NSArray<ane_minicpm4v3b_vision_f16_b1Output *> *)predictionsFromInputs:(NSArray<ane_minicpm4v3b_vision_f16_b1Input*> *)inputArray options:(MLPredictionOptions *)options error:(NSError * _Nullable __autoreleasing * _Nullable)error;
151+
- (nullable NSArray<ane_minicpmv4_vit_f16Output *> *)predictionsFromInputs:(NSArray<ane_minicpmv4_vit_f16Input*> *)inputArray options:(MLPredictionOptions *)options error:(NSError * _Nullable __autoreleasing * _Nullable)error;
152152
@end
153153

154154
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)