-
Notifications
You must be signed in to change notification settings - Fork 0
/
CoreML.framework.h
1727 lines (1295 loc) · 53.1 KB
/
CoreML.framework.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ========== CoreML.framework/Headers/MLMultiArray.h
//
// MLMultiArray.h
// CoreML
//
// Copyright © 2017 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreML/MLExport.h>
NS_ASSUME_NONNULL_BEGIN
/*!
* Allowed data types for multidimensional arrays
*/
typedef NS_ENUM(NSInteger, MLMultiArrayDataType) {
MLMultiArrayDataTypeDouble = 0x10000 | 64,
MLMultiArrayDataTypeFloat32 = 0x10000 | 32,
MLMultiArrayDataTypeInt32 = 0x20000 | 32
} API_AVAILABLE(macos(10.13), ios(11.0), watchos(4.0), tvos(11.0));
/*!
* Multidimensional Array
*/
API_AVAILABLE(macos(10.13), ios(11.0), watchos(4.0), tvos(11.0))
ML_EXPORT
@interface MLMultiArray : NSObject
/// Unsafe pointer to underlying buffer holding the data
@property (readonly, nonatomic) void *dataPointer;
/// Type of element held
@property (readonly, nonatomic) MLMultiArrayDataType dataType;
/// An array containing the sizes of each dimension in the multiarray
@property (readonly, nonatomic) NSArray<NSNumber *> *shape;
/*!
* An array containing the stride in memory for each dimension.
* The element referred to by a multidimensional index is located at an offset equal to
* sum_d index[d]*strides[d]. This offset is in the units of the specified dataType.
*/
@property (readonly, nonatomic) NSArray<NSNumber *> *strides;
/// Count of total number of elements
@property (readonly, nonatomic) NSInteger count;
@end
@interface MLMultiArray (Creation)
/// Create by C-style contiguous array by allocating and managing the necessary memory
- (nullable instancetype)initWithShape:(NSArray<NSNumber *> *)shape
dataType:(MLMultiArrayDataType)dataType
error:(NSError **)error;
/// Create by wrapping existing data
- (nullable instancetype)initWithDataPointer:(void *)dataPointer
shape:(NSArray<NSNumber *> *)shape
dataType:(MLMultiArrayDataType)dataType
strides:(NSArray<NSNumber *> *)strides
deallocator:(void (^_Nullable)(void *bytes))deallocator
error:(NSError **)error;
@end
@interface MLMultiArray (NSNumberDataAccess)
/// Get a value by its linear index (assumes C-style index ordering)
- (NSNumber *)objectAtIndexedSubscript:(NSInteger)idx;
/// Get a value by its multidimensional index (NSArray<NSNumber *>)
- (NSNumber *)objectForKeyedSubscript:(NSArray<NSNumber *> *)key;
/// Set a value by its linear index (assumes C-style index ordering)
- (void)setObject:(NSNumber *)obj atIndexedSubscript:(NSInteger)idx;
/// Set a value by subindicies (NSArray<NSNumber *>)
- (void)setObject:(NSNumber *)obj forKeyedSubscript:(NSArray<NSNumber *> *)key;
@end
NS_ASSUME_NONNULL_END
// ========== CoreML.framework/Headers/MLMetricKey.h
//
// MLMetricKey.h
// CoreML
//
// Copyright © 2019 Apple Inc. All rights reserved.
//
#import <CoreML/CoreML.h>
NS_ASSUME_NONNULL_BEGIN
/*!
* A class to specify list of supported model update metrics.
*/
ML_EXPORT
API_AVAILABLE(macos(10.15), ios(13.0))
@interface MLMetricKey : MLKey
// Float metric indicating the current loss
@property (class, readonly, nonatomic) MLMetricKey *lossValue;
// Int64 metric indicating the index of the epoch
@property (class, readonly, nonatomic) MLMetricKey *epochIndex;
// Int64 metric indicating the index of mini batches in the current epoch
@property (class, readonly, nonatomic) MLMetricKey *miniBatchIndex;
// cannot construct MLMetricKey without parameters.
- (instancetype)init NS_UNAVAILABLE;
// cannot construct MLMetricKey without parameters.
+ (id)new NS_UNAVAILABLE;
@end
NS_ASSUME_NONNULL_END
// ========== CoreML.framework/Headers/MLFeatureType.h
//
// MLFeatureType.h
// CoreML
//
// Copyright © 2017 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
/*!
* Supported data type enumeration
*/
typedef NS_ENUM(NSInteger, MLFeatureType) {
MLFeatureTypeInvalid = 0,
/// Discrete values, sometimes used to hold numeric encoding of a categorical value
MLFeatureTypeInt64 = 1,
/// Continuous values
MLFeatureTypeDouble = 2,
// Text or categorical strings
MLFeatureTypeString = 3,
/// CVPixelBufferRef
MLFeatureTypeImage = 4,
/// MLMultiArray
MLFeatureTypeMultiArray = 5,
/// Numerically weighted hashable objects (e.g. word counts)
MLFeatureTypeDictionary = 6,
/// MLSequence. Ordered collection of feature values with the same type
MLFeatureTypeSequence API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0)) = 7,
} API_AVAILABLE(macos(10.13), ios(11.0), watchos(4.0), tvos(11.0));
// ========== CoreML.framework/Headers/MLCustomLayer.h
//
// MLCustomLayer.h
// CoreML
//
// Copyright © 2017 Apple Inc. All rights reserved.
#import <Foundation/Foundation.h>
#import <CoreML/MLMultiArray.h>
NS_ASSUME_NONNULL_BEGIN
@protocol MTLTexture;
@protocol MTLCommandBuffer;
/*
* Protocol for specifying a custom layer implementation.
*/
API_AVAILABLE(macos(10.13.2), ios(11.2), watchos(4.2), tvos(11.2))
@protocol MLCustomLayer
/*
* Initialize the custom layer implementation. The dictionary contains the contents of the
* 'parameters' map from the model specification. This function is called once on model load.
* We expect the implementation to return 'nil' and set an error in the event of failure
* initializing the object.
*/
- (nullable instancetype)initWithParameterDictionary:(NSDictionary<NSString *, id> *)parameters
error:(NSError **)error;
/*
* The data encoded in the 'weights' field of the model specification will be loaded and made
* available to the implementation here, with one entry of the array for each entry in the 'repeated'
* weights field in the Core ML neural network specification . This is called when the model is loaded,
* but is a separate call from the initialization. The pointer to weights should be stored, but modifying
* or copying its contents can significantly increase an app's memory footprint. The implementation
* should return 'YES' on success, or return 'NO' and set an error in the event of a failure.
*/
- (BOOL)setWeightData:(NSArray<NSData *> *)weights
error:(NSError **)error;
/*
* For the given input shapes, the implementation needs to return the output shape produced by this layer.
* This will be called at least once at load time, and will be called any time the size of the inputs changes
* in a call to predict. Consumes and returns 5D arrays of shapes in the usual Core ML convention - (Sequence,
* Batch, Channel Height, Width). See the Core ML neural network protobuf specification for more details
* about how layers use these dimensions. This will get called at load and run time. In the event of an error
* the implementation should return 'nil' and set an error.
*/
- (nullable NSArray<NSArray<NSNumber *> *> *)outputShapesForInputShapes:(NSArray<NSArray<NSNumber *> *> *)inputShapes
error:(NSError **)error;
/*
* For the given inputs, populate the provide output memory. This will be called for each evaluation performed
* on the CPU. The inputs and outputs will have the shapes of the most recent call to outputShapesForInputShapes.
* The memory for both input and output arrays are preallocated, and should not be copied or moved. The
* implementation should not alter the inputs. Should return 'YES' on sucess, or 'NO' and set the error on
* failure.
*/
- (BOOL)evaluateOnCPUWithInputs:(NSArray<MLMultiArray *> *)inputs
outputs:(NSArray<MLMultiArray *> *)outputs
error:(NSError **)error;
@optional
/*
* Optional selector for encoding a shader implementing the custom layer to a command buffer.
* The execution of the buffer will occur inside Core ML. Providing this function does not guarantee
* GPU evaluation for each prediction. If not provided, the execution of this layer will always be
* on the CPU. Should return 'YES' on sucessfully encoding, or 'NO' and set an error if the encoding
* fails.
*/
- (BOOL)encodeToCommandBuffer:(id<MTLCommandBuffer>)commandBuffer
inputs:(NSArray<id<MTLTexture>> *)inputs
outputs:(NSArray<id<MTLTexture>> *)outputs
error:(NSError **)error;
@end
NS_ASSUME_NONNULL_END
// ========== CoreML.framework/Headers/MLImageSize.h
//
// MLImageSize.h
// CoreML
//
// Copyright © 2018 Apple Inc. All rights reserved.
#import <Foundation/Foundation.h>
#import <CoreML/MLExport.h>
NS_ASSUME_NONNULL_BEGIN
API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0))
ML_EXPORT
@interface MLImageSize : NSObject <NSSecureCoding>
@property (readonly) NSInteger pixelsWide;
@property (readonly) NSInteger pixelsHigh;
@end
NS_ASSUME_NONNULL_END
// ========== CoreML.framework/Headers/MLUpdateProgressEvent.h
//
// MLUpdateProgressEvent.h
// CoreML
//
// Copyright © 2019 Apple Inc. All rights reserved.
//
#import <CoreML/CoreML.h>
NS_ASSUME_NONNULL_BEGIN
/*!
* Events on which update task is capable of invoking progress handler.
*
* @note MLUpdateProgressEventMiniBatchEnd may induce performance problems
* during pipeline execution.
*/
API_AVAILABLE(macos(10.15), ios(13.0))
typedef NS_OPTIONS(NSInteger, MLUpdateProgressEvent) {
MLUpdateProgressEventTrainingBegin = 1 << 0,
MLUpdateProgressEventEpochEnd = 1 << 1,
MLUpdateProgressEventMiniBatchEnd = 1 << 2,
};
NS_ASSUME_NONNULL_END
// ========== CoreML.framework/Headers/MLMultiArrayConstraint.h
//
// MLMultiArrayConstraint.h
// CoreML
//
// Copyright © 2017 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreML/MLMultiArray.h>
#import <CoreML/MLMultiArrayShapeConstraint.h>
#import <CoreML/MLExport.h>
NS_ASSUME_NONNULL_BEGIN
/*!
* Constraint describing expected MLMultiArray properties
*/
API_AVAILABLE(macos(10.13), ios(11.0), watchos(4.0), tvos(11.0))
ML_EXPORT
@interface MLMultiArrayConstraint : NSObject <NSSecureCoding>
// Required or default shape of multiarray
@property (readonly, nonatomic) NSArray<NSNumber *> *shape;
// Required dataType
@property (readonly, nonatomic) MLMultiArrayDataType dataType;
// Detailed shape constraint
@property (readonly, nonatomic) MLMultiArrayShapeConstraint *shapeConstraint API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0));
@end
NS_ASSUME_NONNULL_END
// ========== CoreML.framework/Headers/MLUpdateProgressHandlers.h
//
// MLUpdateProgressHandlers.h
// CoreML
//
// Copyright © 2019 Apple Inc. All rights reserved.
//
#import <CoreML/CoreML.h>
NS_ASSUME_NONNULL_BEGIN
@class MLUpdateContext;
/*!
* Allows applications to register for progress and completion handlers.
*/
ML_EXPORT
API_AVAILABLE(macos(10.15), ios(13.0))
@interface MLUpdateProgressHandlers : NSObject
- (instancetype)initForEvents:(MLUpdateProgressEvent)interestedEvents
progressHandler:(nullable void (^)(MLUpdateContext * context))progressHandler
completionHandler:(void (^)(MLUpdateContext * context))completionHandler;
// cannot construct MLUpdateTask without parameters.
- (instancetype)init NS_UNAVAILABLE;
// cannot construct MLUpdateTask without parameters.
+ (id)new NS_UNAVAILABLE;
@end
NS_ASSUME_NONNULL_END
// ========== CoreML.framework/Headers/MLMultiArrayShapeConstraint.h
//
// MLMultiArrayShapeConstraint.h
// CoreML
//
// Copyright © 2018 Apple Inc. All rights reserved.
#import <Foundation/Foundation.h>
#import <CoreML/MLMultiArrayShapeConstraintType.h>
#import <CoreML/MLExport.h>
NS_ASSUME_NONNULL_BEGIN
API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0))
ML_EXPORT
@interface MLMultiArrayShapeConstraint : NSObject <NSSecureCoding>
@property (readonly, nonatomic) MLMultiArrayShapeConstraintType type;
// Size of each dimension i must fall within sizeRangeForDimension[i].rangeValue
@property (readonly, nonatomic) NSArray<NSValue *> * sizeRangeForDimension;
// If type == MLMultiArrayShapeConstraintTypeEnumerated then
// only shapes in this set are allowed
@property (readonly, nonatomic) NSArray<NSArray<NSNumber *> *> * enumeratedShapes;
@end
NS_ASSUME_NONNULL_END
// ========== CoreML.framework/Headers/CoreML.h
//
// CoreML.h
// CoreML
//
// Copyright © 2017 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreML/MLFeatureType.h>
#import <CoreML/MLFeatureValue.h>
#import <CoreML/MLFeatureValue+MLImageConversion.h>
#import <CoreML/MLFeatureDescription.h>
#import <CoreML/MLFeatureProvider.h>
#import <CoreML/MLDictionaryFeatureProvider.h>
#import <CoreML/MLBatchProvider.h>
#import <CoreML/MLArrayBatchProvider.h>
#import <CoreML/MLMultiArray.h>
#import <CoreML/MLSequence.h>
#import <CoreML/MLMultiArrayConstraint.h>
#import <CoreML/MLImageConstraint.h>
#import <CoreML/MLDictionaryConstraint.h>
#import <CoreML/MLSequenceConstraint.h>
#import <CoreML/MLImageSize.h>
#import <CoreML/MLImageSizeConstraint.h>
#import <CoreML/MLImageSizeConstraintType.h>
#import <CoreML/MLMultiArrayShapeConstraint.h>
#import <CoreML/MLMultiArrayShapeConstraintType.h>
#import <CoreML/MLModel.h>
#import <CoreML/MLModelDescription.h>
#import <CoreML/MLModelMetadataKeys.h>
#import <CoreML/MLPredictionOptions.h>
#import <CoreML/MLModelConfiguration.h>
#import <CoreML/MLModel+MLModelCompilation.h>
#import <CoreML/MLModelError.h>
#import <CoreML/MLCustomLayer.h>
#import <CoreML/MLCustomModel.h>
#import <CoreML/MLExport.h>
#import <CoreML/MLKey.h>
#import <CoreML/MLTask.h>
#import <CoreML/MLUpdateTask.h>
#import <CoreML/MLWritable.h>
#import <CoreML/MLUpdateProgressEvent.h>
#import <CoreML/MLUpdateContext.h>
#import <CoreML/MLUpdateProgressHandlers.h>
#import <CoreML/MLMetricKey.h>
#import <CoreML/MLNumericConstraint.h>
#import <CoreML/MLParameterDescription.h>
#import <CoreML/MLParameterKey.h>
// ========== CoreML.framework/Headers/MLImageSizeConstraint.h
//
// MLImageSizeConstraint.h
// CoreML
//
// Copyright © 2018 Apple Inc. All rights reserved.
#import <Foundation/Foundation.h>
#import <CoreML/MLImageSize.h>
#import <CoreML/MLImageSizeConstraintType.h>
#import <CoreML/MLExport.h>
NS_ASSUME_NONNULL_BEGIN
API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0))
ML_EXPORT
@interface MLImageSizeConstraint : NSObject <NSSecureCoding>
@property (readonly, nonatomic) MLImageSizeConstraintType type;
// Image size must fall within this range
@property (readonly, nonatomic) NSRange pixelsWideRange;
@property (readonly, nonatomic) NSRange pixelsHighRange;
// If type == MLImageSizeConstraintTypeEnumerated
// then the only image sizes present in this set are allowed.
@property (readonly, nonatomic) NSArray<MLImageSize *> *enumeratedImageSizes;
@end
NS_ASSUME_NONNULL_END
// ========== CoreML.framework/Headers/MLParameterDescription.h
//
// MLParameterDescription.h
// CoreML
//
// Copyright © 2019 Apple Inc. All rights reserved.
//
#import <CoreML/CoreML.h>
NS_ASSUME_NONNULL_BEGIN
@class MLNumericConstraint;
/*!
* Describes a model parameter along with a default value and any applicable constaint on the values.
*/
ML_EXPORT
API_AVAILABLE(macos(10.15), ios(13.0))
@interface MLParameterDescription : NSObject
// Name and type of the parameter
@property (readonly, nonatomic) MLParameterKey *key;
// Default value of the parameter
@property (readonly, nonatomic) id defaultValue;
// Any applicable constraint on the parameter value
@property (readonly, nonatomic) MLNumericConstraint *numericConstraint;
@end
NS_ASSUME_NONNULL_END
// ========== CoreML.framework/Headers/MLUpdateTask.h
//
// MLUpdateTask.h
// CoreML
//
// Copyright © 2019 Apple Inc. All rights reserved.
//
#import <CoreML/CoreML.h>
NS_ASSUME_NONNULL_BEGIN
@class MLUpdateContext;
@class MLUpdateProgressHandlers;
/*!
* Main class for setting up and controlling a model update. It provides some utility class methods for performing an update synchronously as well as class constructors for configuring an update and give developers control for the execution of that update.
*/
ML_EXPORT
API_AVAILABLE(macos(10.15), ios(13.0))
@interface MLUpdateTask : MLTask
// Update via task control with completion handler
+ (nullable instancetype)updateTaskForModelAtURL:(NSURL *)modelURL
trainingData:(id<MLBatchProvider>)trainingData
configuration:(nullable MLModelConfiguration *)configuration
completionHandler:(void (^)(MLUpdateContext * context))completionHandler
error:(NSError * _Nullable * _Nullable)error;
// Update via task control and custom progress callbacks
+ (nullable instancetype)updateTaskForModelAtURL:(NSURL *)modelURL
trainingData:(id<MLBatchProvider>)trainingData
configuration:(nullable MLModelConfiguration *)configuration
progressHandlers:(MLUpdateProgressHandlers *)progressHandlers
error:(NSError * _Nullable * _Nullable)error;
// Request a resume with new parameters. Should be used within a progressHandler
- (void)resumeWithParameters:(NSDictionary<MLParameterKey *, id> *)updateParameters;
// cannot construct MLUpdateTask without parameters.
- (instancetype)init NS_UNAVAILABLE;
// cannot construct MLUpdateTask without parameters.
+ (id)new NS_UNAVAILABLE;
@end
NS_ASSUME_NONNULL_END
// ========== CoreML.framework/Headers/MLFeatureDescription.h
//
// MLFeatureDescription.h
// CoreML
//
// Copyright © 2017 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreML/MLFeatureType.h>
#import <CoreML/MLFeatureValue.h>
#import <CoreML/MLDictionaryConstraint.h>
#import <CoreML/MLMultiArrayConstraint.h>
#import <CoreML/MLImageConstraint.h>
#import <CoreML/MLSequenceConstraint.h>
#import <CoreML/MLExport.h>
NS_ASSUME_NONNULL_BEGIN
/*!
* Description of a feature
*/
API_AVAILABLE(macos(10.13), ios(11.0), watchos(4.0), tvos(11.0))
ML_EXPORT
@interface MLFeatureDescription : NSObject<NSCopying, NSSecureCoding>
/// Name of feature
@property (readonly, nonatomic, copy) NSString *name;
/// Type of data
@property (readonly, nonatomic) MLFeatureType type;
/// Whether this feature can take an undefined value or not
@property (readonly, nonatomic, getter=isOptional) BOOL optional;
/// Check if MLFeatureValue is valid based on this description
- (BOOL)isAllowedValue:(MLFeatureValue *)value;
@end
/*!
* Feature value constraints for specific types
*/
API_AVAILABLE(macos(10.13), ios(11.0), watchos(4.0), tvos(11.0))
@interface MLFeatureDescription (MLFeatureValueConstraints)
/// Constraint when type == MLFeatureTypeMultiArray, nil otherwise
@property (readonly, nullable, nonatomic) MLMultiArrayConstraint *multiArrayConstraint;
/// Constraint when type == MLFeatureTypeImage, nil otherwise
@property (readonly, nullable, nonatomic) MLImageConstraint *imageConstraint;
/// Constraint when type == MLFeatureTypeDictionary, nil otherwise
@property (readonly, nullable, nonatomic) MLDictionaryConstraint *dictionaryConstraint;
/// Constraint when type == MLFeatureTypeSequence, nil otherwise
@property (readonly, nullable, nonatomic) MLSequenceConstraint *sequenceConstraint API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0));
@end
NS_ASSUME_NONNULL_END
// ========== CoreML.framework/Headers/MLParameterKey.h
//
// MLParameterKey.h
// CoreML
//
// Copyright © 2019 Apple Inc. All rights reserved.
//
#import <CoreML/CoreML.h>
NS_ASSUME_NONNULL_BEGIN
/*!
* A class to specify list of supported model update parameters.
*/
ML_EXPORT
API_AVAILABLE(macos(10.15), ios(13.0))
@interface MLParameterKey : MLKey<NSSecureCoding>
// Double parameter used to control the learning rate of an optimizer. Adjustable in progress
@property (class, readonly, nonatomic) MLParameterKey *learningRate;
// Double parameter used to control the momentum of gradient based optimizers. Adjustable in progress
@property (class, readonly, nonatomic) MLParameterKey *momentum;
// Int64 parameter used to specify the size of a miniBatch used by optimizer. Not adjustable in progress
@property (class, readonly, nonatomic) MLParameterKey *miniBatchSize;
// Double parameter used to control the beta1 of Adam optimizer. Adjustable in progress
@property (class, readonly, nonatomic) MLParameterKey *beta1;
// Double parameter used to control the beta2 of Adam optimizer. Adjustable in progress
@property (class, readonly, nonatomic) MLParameterKey *beta2;
// Double parameter used to control the epsilon of Adam optimizer. Adjustable in progress
@property (class, readonly, nonatomic) MLParameterKey *eps;
// Int64 parameter used to specify the number of epochs used by optimizer. Not adjustable in progress
@property (class, readonly, nonatomic) MLParameterKey *epochs;
// Bool parameter used to specify whether an update should remove examples (applicable to kNN). Not adjustable in progress
@property (class, readonly, nonatomic) MLParameterKey *removeExamples;
// cannot construct MLParameterKey without parameters.
- (instancetype)init NS_UNAVAILABLE;
// cannot construct MLParameterKey without parameters.
+ (id)new NS_UNAVAILABLE;
@end
@interface MLParameterKey (MLLinkedModelParameters)
// String parameter used to specify the name of a linked model
@property (class, readonly, nonatomic) MLParameterKey *linkedModelFileName;
// String parameteru sed to specify the search path for a linked model
@property (class, readonly, nonatomic) MLParameterKey *linkedModelSearchPath;
@end
NS_ASSUME_NONNULL_END
// ========== CoreML.framework/Headers/MLWritable.h
//
// MLWritable.h
// CoreML
//
// Copyright © 2019 Apple Inc. All rights reserved.
//
#import <CoreML/CoreML.h>
NS_ASSUME_NONNULL_BEGIN
ML_EXPORT
API_AVAILABLE(macos(10.15), ios(13.0))
@protocol MLWritable <NSObject>
// Writes the model to disk and returns YES if the write is successful.
- (BOOL)writeToURL:(NSURL *)url error:(NSError * _Nullable * _Nullable)error;
@end
NS_ASSUME_NONNULL_END
// ========== CoreML.framework/Headers/MLDictionaryConstraint.h
//
// MLDictionaryConstraint.h
// CoreML
//
// Copyright © 2017 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreML/MLFeatureType.h>
#import <CoreML/MLExport.h>
NS_ASSUME_NONNULL_BEGIN
/*!
* MLDictionaryConstraint
*
* Constraint describing expected NSDictionary properties
*/
API_AVAILABLE(macos(10.13), ios(11.0), watchos(4.0), tvos(11.0))
ML_EXPORT
@interface MLDictionaryConstraint : NSObject <NSSecureCoding>
/// Required key type, described as MLFeatureType
@property (readonly, nonatomic) MLFeatureType keyType;
@end
NS_ASSUME_NONNULL_END
// ========== CoreML.framework/Headers/MLNumericConstraint.h
//
// MLNumericConstraint.h
// CoreML
//
// Copyright © 2019 Apple Inc. All rights reserved.
//
#import <CoreML/CoreML.h>
NS_ASSUME_NONNULL_BEGIN
/*!
* Allows enforcement of constraints on the values of update parameters.
*/
ML_EXPORT
API_AVAILABLE(macos(10.15), ios(13.0))
@interface MLNumericConstraint : NSObject
// Minimum value of the parameter can take.
@property (readonly, nonatomic) NSNumber *minNumber;
// Maximum value of the parameter can take.
@property (readonly, nonatomic) NSNumber *maxNumber;
// If not nil, list of restricted set of values the parameter can take.
@property (readonly, nonatomic, nullable) NSSet<NSNumber *> *enumeratedNumbers;
@end
NS_ASSUME_NONNULL_END
// ========== CoreML.framework/Headers/MLDictionaryFeatureProvider.h
//
// MLDictionaryFeatureProvider.h
// CoreML
//
// Copyright © 2017 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreML/MLFeatureProvider.h>
#import <CoreML/MLFeatureValue.h>
#import <CoreML/MLExport.h>
NS_ASSUME_NONNULL_BEGIN
/*!
* A concrete convenience class conforming to MLFeatureProvider.
*/
API_AVAILABLE(macos(10.13), ios(11.0), watchos(4.0), tvos(11.0))
ML_EXPORT
@interface MLDictionaryFeatureProvider : NSObject<MLFeatureProvider, NSFastEnumeration>
/// Dictionary holding the feature values
@property (readonly, nonatomic) NSDictionary<NSString *, MLFeatureValue *> *dictionary;
/*!
* Create from a generic dictionary by converting all values to MLFeatureValues
* or from a dictionary with values already stored as MLFeatureValues.
*
* An error results if the values are not or cannot be represented as MLFeatureValues.
*/
- (nullable instancetype)initWithDictionary:(NSDictionary<NSString *, id> *)dictionary
error:(NSError **)error;
/// Get the value for specified feature
- (nullable MLFeatureValue *)objectForKeyedSubscript:(NSString *)featureName;
@end
NS_ASSUME_NONNULL_END
// ========== CoreML.framework/Headers/MLFeatureValue.h
//
// MLFeatureValue.h
// CoreML
//
// Copyright © 2017 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreML/MLFeatureType.h>
#import <CoreML/MLMultiArray.h>
#import <CoreML/MLSequence.h>
#import <CoreVideo/CVPixelBuffer.h>
#import <CoreML/MLExport.h>
NS_ASSUME_NONNULL_BEGIN
/*!
* An immutable variant holding a data value of a supported MLFeatureType
*
* MLFeatureValue does not support type conversion in its accessor properties. It
* can also have a missing or undefined value of a well defined type.
*/
API_AVAILABLE(macos(10.13), ios(11.0), watchos(4.0), tvos(11.0))
ML_EXPORT
@interface MLFeatureValue : NSObject<NSCopying>
/// Type of the value for which the corresponding property below is held
@property (readonly, nonatomic) MLFeatureType type;
/// True if the value represents a missing or undefined value
@property (readonly, nonatomic, getter=isUndefined) BOOL undefined;
/// Populated value if the type is MLFeatureTypeInt64
@property (readonly, nonatomic) int64_t int64Value;
/// Populated value if the type is MLFeatureTypeDouble
@property (readonly, nonatomic) double doubleValue;
/// Populated value if the type is MLFeatureTypeString
@property (readonly, nonatomic, copy) NSString *stringValue;
/// Populated value if the type is MLFeatureTypeMultiArray
@property (readonly, nullable, nonatomic) MLMultiArray *multiArrayValue;
/// Populated value if the type is MLFeatureTypeDictionary
@property (readonly, nonatomic) NSDictionary<id, NSNumber *> *dictionaryValue;
/// Populated value if the type is MLFeatureTypeImage
@property (readonly, nullable, nonatomic) CVPixelBufferRef imageBufferValue;
/// Populated value if the type is MLFeatureTypeSequence
@property (readonly, nullable, nonatomic) MLSequence *sequenceValue API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0));
/// Hold an object with the specified value
+ (instancetype)featureValueWithInt64:(int64_t)value;
+ (instancetype)featureValueWithDouble:(double)value;
+ (instancetype)featureValueWithString:(NSString *)value;
+ (instancetype)featureValueWithMultiArray:(MLMultiArray *)value;
+ (instancetype)featureValueWithPixelBuffer:(CVPixelBufferRef)value;
+ (instancetype)featureValueWithSequence:(MLSequence *)sequence API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0));
/// Represent an undefined value of a specified type
+ (instancetype)undefinedFeatureValueWithType:(MLFeatureType)type;
/*!
* For encoding a sparse feature set or for encoding probabilities. Input keys that are not
* NSNumber * or NSString * are rejected on construction and return a MLModelErrorFeatureTypeMismatch
* error. Further validation for consistency occurs on evaluation
*/
+ (nullable instancetype)featureValueWithDictionary:(NSDictionary<id, NSNumber *> *)value
error:(NSError **)error;
- (BOOL)isEqualToFeatureValue:(MLFeatureValue *)value;
@end
NS_ASSUME_NONNULL_END
// ========== CoreML.framework/Headers/MLImageSizeConstraintType.h
//
// MLImageSizeConstraintType.h
// CoreML
//
// Copyright © 2018 Apple Inc. All rights reserved.
#import <Foundation/Foundation.h>
typedef NS_ENUM(NSInteger, MLImageSizeConstraintType) {
MLImageSizeConstraintTypeUnspecified = 0, // Any image size is allowed
MLImageSizeConstraintTypeEnumerated = 2, // Limited to an enumerated set of image sizes
MLImageSizeConstraintTypeRange = 3, // Allow full width and height ranges
} API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0));
// ========== CoreML.framework/Headers/MLSequence.h
//
// MLSequence.h
// CoreML
//
// Copyright © 2018 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreML/MLFeatureType.h>
#import <CoreML/MLExport.h>
NS_ASSUME_NONNULL_BEGIN
/**
* An immutable container holding an ordered collection of feature values
* of the same type.
*/
API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0))
ML_EXPORT
@interface MLSequence : NSObject
/// Type of values held
@property (readonly, nonatomic) MLFeatureType type;
/// Empty sequence of a sepcific type
+ (instancetype)emptySequenceWithType:(MLFeatureType)type;
/// String sequences, property will be empty array if type is MLFeatureTypeString
+ (instancetype)sequenceWithStringArray:(NSArray<NSString *> *)stringValues;
@property (readonly, nonatomic) NSArray<NSString *> *stringValues;
/// int64 sequence, propery will be empty array if type is MLFeatureTypeInt64
+ (instancetype)sequenceWithInt64Array:(NSArray<NSNumber *> *)int64Values;
@property (readonly, nonatomic) NSArray<NSNumber *> *int64Values;
@end
NS_ASSUME_NONNULL_END
// ========== CoreML.framework/Headers/MLUpdateContext.h
//
// MLUpdateContext.h
// CoreML
//
// Copyright © 2019 Apple Inc. All rights reserved.
//
#import <CoreML/CoreML.h>
NS_ASSUME_NONNULL_BEGIN
@class MLUpdateTask;
@class MLMetricKey;
@protocol MLWritable;
/*!
* Provides context for the update process when the progress or completion handlers are invoked.
*/
ML_EXPORT
API_AVAILABLE(macos(10.15), ios(13.0))
@interface MLUpdateContext : NSObject
// Reference to the update task that invokved the progress or completion handlers.
@property (readonly, nonatomic) MLUpdateTask *task;
// Reference to the updated model that can be used for additional validation or evaluation.
@property (readonly, nonatomic) MLModel<MLWritable> *model;
// Indicates the event the progress handler invocation corresponds to. This will be one of the events app registered via MLUpdateProgressHandlers.interestedEvents.
@property (readonly, nonatomic) MLUpdateProgressEvent event;
// Metrics computed on the training input during the update process.
@property (readonly, nonatomic) NSDictionary <MLMetricKey *, id> *metrics;
// A snapshot of parameters (including their values) used during the update process.
@property (readonly, nonatomic) NSDictionary <MLParameterKey *, id> *parameters;
@end
NS_ASSUME_NONNULL_END
// ========== CoreML.framework/Headers/MLModelMetadataKeys.h