ORTCheckpoint
Objective-C
@interface ORTCheckpoint : NSObject
Swift
class ORTCheckpoint : NSObject
An ORT checkpoint is a snapshot of the state of a model at a given point in time.
This class holds the entire training session state that includes model parameters,
their gradients, optimizer parameters, and user properties. The ORTTrainingSession leverages the
ORTCheckpoint by accessing and updating the contained training state.
Available since 1.16.
Note
This class is only available when the training APIs are enabled.-
Unavailable
Declaration
Objective-C
- (instancetype)init NS_UNAVAILABLE; -
Creates a checkpoint from directory on disk.
Declaration
Objective-C
- (nullable instancetype)initWithPath:(nonnull NSString *)path error:(NSError *_Nullable *_Nullable)error;Swift
init(path: String) throwsParameters
pathThe path to the checkpoint directory.
errorOptional error information set if an error occurs.
Return Value
The instance, or nil if an error occurs.
-
Saves a checkpoint to directory on disk.
Declaration
Objective-C
- (BOOL)saveCheckpointToPath:(nonnull NSString *)path withOptimizerState:(BOOL)includeOptimizerState error:(NSError *_Nullable *_Nullable)error;Swift
func save(toPath path: String, withOptimizerState includeOptimizerState: Bool) throwsParameters
pathThe path to the checkpoint directory.
includeOptimizerStateFlag to indicate whether to save the optimizer state or not.
errorOptional error information set if an error occurs.
Return Value
Whether the checkpoint was saved successfully.
-
Adds an int property to this checkpoint.
Declaration
Objective-C
- (BOOL)addIntPropertyWithName:(nonnull NSString *)name value:(int64_t)value error:(NSError *_Nullable *_Nullable)error;Swift
func addIntProperty(withName name: String, value: Int64) throwsParameters
nameThe name of the property.
valueThe value of the property.
errorOptional error information set if an error occurs.
Return Value
Whether the property was added successfully.
-
Adds a float property to this checkpoint.
Declaration
Objective-C
- (BOOL)addFloatPropertyWithName:(nonnull NSString *)name value:(float)value error:(NSError *_Nullable *_Nullable)error;Swift
func addFloatProperty(withName name: String, value: Float) throwsParameters
nameThe name of the property.
valueThe value of the property.
errorOptional error information set if an error occurs.
Return Value
Whether the property was added successfully.
-
Adds a string property to this checkpoint.
Declaration
Objective-C
- (BOOL)addStringPropertyWithName:(nonnull NSString *)name value:(nonnull NSString *)value error:(NSError *_Nullable *_Nullable)error;Swift
func addStringProperty(withName name: String, value: String) throwsParameters
nameThe name of the property.
valueThe value of the property.
errorOptional error information set if an error occurs.
Return Value
Whether the property was added successfully.
-
Gets an int property from this checkpoint.
Declaration
Objective-C
- (int64_t)getIntPropertyWithName:(nonnull NSString *)name error:(NSError *_Nullable *_Nullable)error;Swift
func getIntProperty(withName name: String) throws -> Int64Parameters
nameThe name of the property.
errorOptional error information set if an error occurs.
Return Value
The value of the property or 0 if an error occurs.
-
Gets a float property from this checkpoint.
Declaration
Objective-C
- (float)getFloatPropertyWithName:(nonnull NSString *)name error:(NSError *_Nullable *_Nullable)error;Swift
func getFloatProperty(withName name: String) throws -> FloatParameters
nameThe name of the property.
errorOptional error information set if an error occurs.
Return Value
The value of the property or 0.0f if an error occurs.
-
Gets a string property from this checkpoint.
Declaration
Objective-C
- (nullable NSString *)getStringPropertyWithName:(nonnull NSString *)name error:(NSError *_Nullable *_Nullable) error;Swift
func getStringProperty(withName name: String) throws -> String?Parameters
nameThe name of the property.
errorOptional error information set if an error occurs.
Return Value
The value of the property.
View on GitHub
ORTCheckpoint Class Reference