Class Serialization
Defined in File serialization.h
Class Documentation
-
class Serialization
The Serialization class is used to summarize methods for reading and writing model files.
Public Static Functions
-
static inline Status Load(const void *model_data, size_t data_size, ModelType model_type, Graph *graph, const Key &dec_key = {}, const std::string &dec_mode = kDecModeAesGcm)
Loads a model file from memory buffer.
- Parameters
model_data – [in] A buffer filled by model file.
data_size – [in] The size of the buffer.
model_type – [in] The Type of model file, options are ModelType::kMindIR, ModelType::kOM.
graph – [out] The output parameter, an object saves graph data.
dec_key – [in] The decryption key, key length is 16, 24, or 32. Not supported on MindSpore Lite.
dec_mode – [in] The decryption mode, optional options are AES-GCM, AES-CBC. Not supported on MindSpore Lite.
- Returns
Status.
-
static inline Status Load(const std::string &file, ModelType model_type, Graph *graph, const Key &dec_key = {}, const std::string &dec_mode = kDecModeAesGcm)
Loads a model file from path.
- Parameters
file – [in] The path of model file.
model_type – [in] The Type of model file, options are ModelType::kMindIR, ModelType::kOM.
graph – [out] The output parameter, an object saves graph data.
dec_key – [in] The decryption key, key length is 16, 24, or 32. Not supported on MindSpore Lite.
dec_mode – [in] The decryption mode, optional options are AES-GCM, AES-CBC. Not supported on MindSpore Lite.
- Returns
Status.
-
static inline Status Load(const std::vector<std::string> &files, ModelType model_type, std::vector<Graph> *graphs, const Key &dec_key = {}, const std::string &dec_mode = kDecModeAesGcm)
Load multiple models from multiple files, MindSpore Lite does not provide this feature.
- Parameters
files – [in] The path of model files.
model_type – [in] The Type of model file, options are ModelType::kMindIR, ModelType::kOM.
graphs – [out] The output parameter, an object saves graph data.
dec_key – [in] The decryption key, key length is 16, 24, or 32.
dec_mode – [in] The decryption mode, optional options are AES-GCM, AES-CBC.
- Returns
Status.
-
static Status SetParameters(const std::map<std::string, Buffer> ¶meters, Model *model)
Configure model parameters, MindSpore Lite does not provide this feature.
- Parameters
parameters – [in] The parameters.
model – [in] The model.
- Returns
Status.
-
static Status ExportModel(const Model &model, ModelType model_type, Buffer *model_data)
Export training model from memory buffer, MindSpore Lite does not provide this feature.
- Parameters
model – [in] The model data.
model_type – [in] The model file type.
model_data – [out] The model parameter data.
- Returns
Status.
-
static inline Status ExportModel(const Model &model, ModelType model_type, const std::string &model_file, QuantizationType quantization_type = kNoQuant, bool export_inference_only = true, std::vector<std::string> output_tensor_name = {})
Export training model from file.
- Parameters
model – [in] The model data.
model_type – [in] The model file type.
model_file – [in] The exported model file.
quantization_type – [in] The quantification type.
export_inference_only – [in] Whether to export a reasoning only model.
output_tensor_name – [in] The set the name of the output tensor of the exported reasoning model, default as empty, and export the complete reasoning model.
- Returns
Status.
-
static inline Status Load(const void *model_data, size_t data_size, ModelType model_type, Graph *graph, const Key &dec_key = {}, const std::string &dec_mode = kDecModeAesGcm)