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) throws
Parameters
path
The path to the checkpoint directory.
error
Optional 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) throws
Parameters
path
The path to the checkpoint directory.
includeOptimizerState
Flag to indicate whether to save the optimizer state or not.
error
Optional 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) throws
Parameters
name
The name of the property.
value
The value of the property.
error
Optional 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) throws
Parameters
name
The name of the property.
value
The value of the property.
error
Optional 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) throws
Parameters
name
The name of the property.
value
The value of the property.
error
Optional 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 -> Int64
Parameters
name
The name of the property.
error
Optional 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 -> Float
Parameters
name
The name of the property.
error
Optional 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
name
The name of the property.
error
Optional error information set if an error occurs.
Return Value
The value of the property.