1be168c0dSopenharmony_ci/** 2be168c0dSopenharmony_ci * Copyright 2021 Huawei Technologies Co., Ltd 3be168c0dSopenharmony_ci * 4be168c0dSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 5be168c0dSopenharmony_ci * you may not use this file except in compliance with the License. 6be168c0dSopenharmony_ci * You may obtain a copy of the License at 7be168c0dSopenharmony_ci * 8be168c0dSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 9be168c0dSopenharmony_ci * 10be168c0dSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 11be168c0dSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 12be168c0dSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13be168c0dSopenharmony_ci * See the License for the specific language governing permissions and 14be168c0dSopenharmony_ci * limitations under the License. 15be168c0dSopenharmony_ci */ 16be168c0dSopenharmony_ci 17be168c0dSopenharmony_ci/** 18be168c0dSopenharmony_ci * @addtogroup MindSpore 19be168c0dSopenharmony_ci * @{ 20be168c0dSopenharmony_ci * 21be168c0dSopenharmony_ci * @brief 提供MindSpore Lite的模型推理相关接口。 22be168c0dSopenharmony_ci * 23be168c0dSopenharmony_ci * @Syscap SystemCapability.Ai.MindSpore 24be168c0dSopenharmony_ci * @since 9 25be168c0dSopenharmony_ci */ 26be168c0dSopenharmony_ci 27be168c0dSopenharmony_ci/** 28be168c0dSopenharmony_ci * @file model.h 29be168c0dSopenharmony_ci * 30be168c0dSopenharmony_ci * @brief 提供了模型相关接口,可以用于模型创建、模型推理等。 31be168c0dSopenharmony_ci * 32be168c0dSopenharmony_ci * @library libmindspore_lite_ndk.so 33be168c0dSopenharmony_ci * @since 9 34be168c0dSopenharmony_ci */ 35be168c0dSopenharmony_ci#ifndef MINDSPORE_INCLUDE_C_API_MODEL_C_H 36be168c0dSopenharmony_ci#define MINDSPORE_INCLUDE_C_API_MODEL_C_H 37be168c0dSopenharmony_ci 38be168c0dSopenharmony_ci#include "mindspore/tensor.h" 39be168c0dSopenharmony_ci#include "mindspore/context.h" 40be168c0dSopenharmony_ci#include "mindspore/status.h" 41be168c0dSopenharmony_ci 42be168c0dSopenharmony_ci#ifdef __cplusplus 43be168c0dSopenharmony_ciextern "C" { 44be168c0dSopenharmony_ci#endif 45be168c0dSopenharmony_ci 46be168c0dSopenharmony_citypedef void *OH_AI_ModelHandle; 47be168c0dSopenharmony_ci 48be168c0dSopenharmony_citypedef void *OH_AI_TrainCfgHandle; 49be168c0dSopenharmony_ci 50be168c0dSopenharmony_citypedef struct OH_AI_TensorHandleArray { 51be168c0dSopenharmony_ci size_t handle_num; 52be168c0dSopenharmony_ci OH_AI_TensorHandle *handle_list; 53be168c0dSopenharmony_ci} OH_AI_TensorHandleArray; 54be168c0dSopenharmony_ci 55be168c0dSopenharmony_ci#define OH_AI_MAX_SHAPE_NUM 32 56be168c0dSopenharmony_citypedef struct OH_AI_ShapeInfo { 57be168c0dSopenharmony_ci size_t shape_num; 58be168c0dSopenharmony_ci int64_t shape[OH_AI_MAX_SHAPE_NUM]; 59be168c0dSopenharmony_ci} OH_AI_ShapeInfo; 60be168c0dSopenharmony_ci 61be168c0dSopenharmony_citypedef struct OH_AI_CallBackParam { 62be168c0dSopenharmony_ci char *node_name; 63be168c0dSopenharmony_ci char *node_type; 64be168c0dSopenharmony_ci} OH_AI_CallBackParam; 65be168c0dSopenharmony_ci 66be168c0dSopenharmony_citypedef bool (*OH_AI_KernelCallBack)(const OH_AI_TensorHandleArray inputs, const OH_AI_TensorHandleArray outputs, 67be168c0dSopenharmony_ci const OH_AI_CallBackParam kernel_Info); 68be168c0dSopenharmony_ci 69be168c0dSopenharmony_ci/** 70be168c0dSopenharmony_ci * @brief Create a model object. 71be168c0dSopenharmony_ci * @return Model object handle. 72be168c0dSopenharmony_ci * @since 9 73be168c0dSopenharmony_ci */ 74be168c0dSopenharmony_ciOH_AI_API OH_AI_ModelHandle OH_AI_ModelCreate(); 75be168c0dSopenharmony_ci 76be168c0dSopenharmony_ci/** 77be168c0dSopenharmony_ci * @brief Destroy the model object. 78be168c0dSopenharmony_ci * @param model Model object handle address. 79be168c0dSopenharmony_ci * @since 9 80be168c0dSopenharmony_ci */ 81be168c0dSopenharmony_ciOH_AI_API void OH_AI_ModelDestroy(OH_AI_ModelHandle *model); 82be168c0dSopenharmony_ci 83be168c0dSopenharmony_ci/** 84be168c0dSopenharmony_ci * @brief Build the model from model file buffer so that it can run on a device. 85be168c0dSopenharmony_ci * @param model Model object handle. 86be168c0dSopenharmony_ci * @param model_data Define the buffer read from a model file. 87be168c0dSopenharmony_ci * @param data_size Define bytes number of model file buffer. 88be168c0dSopenharmony_ci * @param model_type Define The type of model file. 89be168c0dSopenharmony_ci * @param model_context Define the context used to store options during execution. 90be168c0dSopenharmony_ci * @return OH_AI_Status. 91be168c0dSopenharmony_ci * @since 9 92be168c0dSopenharmony_ci */ 93be168c0dSopenharmony_ciOH_AI_API OH_AI_Status OH_AI_ModelBuild(OH_AI_ModelHandle model, const void *model_data, size_t data_size, 94be168c0dSopenharmony_ci OH_AI_ModelType model_type, const OH_AI_ContextHandle model_context); 95be168c0dSopenharmony_ci 96be168c0dSopenharmony_ci/** 97be168c0dSopenharmony_ci * @brief Load and build the model from model path so that it can run on a device. 98be168c0dSopenharmony_ci * @param model Model object handle. 99be168c0dSopenharmony_ci * @param model_path Define the model file path. 100be168c0dSopenharmony_ci * @param model_type Define The type of model file. 101be168c0dSopenharmony_ci * @param model_context Define the context used to store options during execution. 102be168c0dSopenharmony_ci * @return OH_AI_Status. 103be168c0dSopenharmony_ci * @since 9 104be168c0dSopenharmony_ci */ 105be168c0dSopenharmony_ciOH_AI_API OH_AI_Status OH_AI_ModelBuildFromFile(OH_AI_ModelHandle model, const char *model_path, 106be168c0dSopenharmony_ci OH_AI_ModelType model_type, const OH_AI_ContextHandle model_context); 107be168c0dSopenharmony_ci 108be168c0dSopenharmony_ci/** 109be168c0dSopenharmony_ci * @brief Resizes the shapes of inputs. 110be168c0dSopenharmony_ci * @param model Model object handle. 111be168c0dSopenharmony_ci * @param inputs The array that includes all input tensor handles. 112be168c0dSopenharmony_ci * @param shape_infos Defines the new shapes of inputs, should be consistent with inputs. 113be168c0dSopenharmony_ci * @param shape_info_num The num of shape_infos. 114be168c0dSopenharmony_ci * @return OH_AI_Status. 115be168c0dSopenharmony_ci * @since 9 116be168c0dSopenharmony_ci */ 117be168c0dSopenharmony_ciOH_AI_API OH_AI_Status OH_AI_ModelResize(OH_AI_ModelHandle model, const OH_AI_TensorHandleArray inputs, 118be168c0dSopenharmony_ci OH_AI_ShapeInfo *shape_infos, size_t shape_info_num); 119be168c0dSopenharmony_ci 120be168c0dSopenharmony_ci/** 121be168c0dSopenharmony_ci * @brief Inference model. 122be168c0dSopenharmony_ci * @param model Model object handle. 123be168c0dSopenharmony_ci * @param inputs The array that includes all input tensor handles. 124be168c0dSopenharmony_ci * @param outputs The array that includes all output tensor handles. 125be168c0dSopenharmony_ci * @param before CallBack before predict. 126be168c0dSopenharmony_ci * @param after CallBack after predict. 127be168c0dSopenharmony_ci * @return OH_AI_Status. 128be168c0dSopenharmony_ci * @since 9 129be168c0dSopenharmony_ci */ 130be168c0dSopenharmony_ciOH_AI_API OH_AI_Status OH_AI_ModelPredict(OH_AI_ModelHandle model, const OH_AI_TensorHandleArray inputs, 131be168c0dSopenharmony_ci OH_AI_TensorHandleArray *outputs, const OH_AI_KernelCallBack before, 132be168c0dSopenharmony_ci const OH_AI_KernelCallBack after); 133be168c0dSopenharmony_ci 134be168c0dSopenharmony_ci/** 135be168c0dSopenharmony_ci * @brief Obtains all input tensor handles of the model. 136be168c0dSopenharmony_ci * @param model Model object handle. 137be168c0dSopenharmony_ci * @return The array that includes all input tensor handles. 138be168c0dSopenharmony_ci * @since 9 139be168c0dSopenharmony_ci */ 140be168c0dSopenharmony_ciOH_AI_API OH_AI_TensorHandleArray OH_AI_ModelGetInputs(const OH_AI_ModelHandle model); 141be168c0dSopenharmony_ci 142be168c0dSopenharmony_ci/** 143be168c0dSopenharmony_ci * @brief Obtains all output tensor handles of the model. 144be168c0dSopenharmony_ci * @param model Model object handle. 145be168c0dSopenharmony_ci * @return The array that includes all output tensor handles. 146be168c0dSopenharmony_ci * @since 9 147be168c0dSopenharmony_ci */ 148be168c0dSopenharmony_ciOH_AI_API OH_AI_TensorHandleArray OH_AI_ModelGetOutputs(const OH_AI_ModelHandle model); 149be168c0dSopenharmony_ci 150be168c0dSopenharmony_ci/** 151be168c0dSopenharmony_ci * @brief Obtains the input tensor handle of the model by name. 152be168c0dSopenharmony_ci * @param model Model object handle. 153be168c0dSopenharmony_ci * @param tensor_name The name of tensor. 154be168c0dSopenharmony_ci * @return The input tensor handle with the given name, if the name is not found, an NULL is returned. 155be168c0dSopenharmony_ci * @since 9 156be168c0dSopenharmony_ci */ 157be168c0dSopenharmony_ciOH_AI_API OH_AI_TensorHandle OH_AI_ModelGetInputByTensorName(const OH_AI_ModelHandle model, const char *tensor_name); 158be168c0dSopenharmony_ci 159be168c0dSopenharmony_ci/** 160be168c0dSopenharmony_ci * @brief Obtains the output tensor handle of the model by name. 161be168c0dSopenharmony_ci * @param model Model object handle. 162be168c0dSopenharmony_ci * @param tensor_name The name of tensor. 163be168c0dSopenharmony_ci * @return The output tensor handle with the given name, if the name is not found, an NULL is returned. 164be168c0dSopenharmony_ci * @since 9 165be168c0dSopenharmony_ci */ 166be168c0dSopenharmony_ciOH_AI_API OH_AI_TensorHandle OH_AI_ModelGetOutputByTensorName(const OH_AI_ModelHandle model, const char *tensor_name); 167be168c0dSopenharmony_ci 168be168c0dSopenharmony_ci/** 169be168c0dSopenharmony_ci * @brief Create a TrainCfg object. Only valid for Lite Train. 170be168c0dSopenharmony_ci * @return TrainCfg object handle. 171be168c0dSopenharmony_ci * @since 11 172be168c0dSopenharmony_ci */ 173be168c0dSopenharmony_ciOH_AI_API OH_AI_TrainCfgHandle OH_AI_TrainCfgCreate(); 174be168c0dSopenharmony_ci 175be168c0dSopenharmony_ci/** 176be168c0dSopenharmony_ci * @brief Destroy the train_cfg object. Only valid for Lite Train. 177be168c0dSopenharmony_ci * @param train_cfg TrainCfg object handle. 178be168c0dSopenharmony_ci * @since 11 179be168c0dSopenharmony_ci */ 180be168c0dSopenharmony_ciOH_AI_API void OH_AI_TrainCfgDestroy(OH_AI_TrainCfgHandle *train_cfg); 181be168c0dSopenharmony_ci 182be168c0dSopenharmony_ci/** 183be168c0dSopenharmony_ci * @brief Obtains part of the name that identify a loss kernel. Only valid for Lite Train. 184be168c0dSopenharmony_ci * @param train_cfg TrainCfg object handle. 185be168c0dSopenharmony_ci * @param num The num of loss_name. 186be168c0dSopenharmony_ci * @return loss_name. 187be168c0dSopenharmony_ci * @since 11 188be168c0dSopenharmony_ci */ 189be168c0dSopenharmony_ciOH_AI_API char **OH_AI_TrainCfgGetLossName(OH_AI_TrainCfgHandle train_cfg, size_t *num); 190be168c0dSopenharmony_ci 191be168c0dSopenharmony_ci/** 192be168c0dSopenharmony_ci * @brief Set part of the name that identify a loss kernel. Only valid for Lite Train. 193be168c0dSopenharmony_ci * @param train_cfg TrainCfg object handle. 194be168c0dSopenharmony_ci * @param loss_name Define part of the name that identify a loss kernel. 195be168c0dSopenharmony_ci * @param num The num of loss_name. 196be168c0dSopenharmony_ci * @since 11 197be168c0dSopenharmony_ci */ 198be168c0dSopenharmony_ciOH_AI_API void OH_AI_TrainCfgSetLossName(OH_AI_TrainCfgHandle train_cfg, const char **loss_name, size_t num); 199be168c0dSopenharmony_ci 200be168c0dSopenharmony_ci/** 201be168c0dSopenharmony_ci * @brief Obtains optimization level of the train_cfg. Only valid for Lite Train. 202be168c0dSopenharmony_ci * @param train_cfg TrainCfg object handle. 203be168c0dSopenharmony_ci * @return OH_AI_OptimizationLevel. 204be168c0dSopenharmony_ci * @since 11 205be168c0dSopenharmony_ci */ 206be168c0dSopenharmony_ciOH_AI_API OH_AI_OptimizationLevel OH_AI_TrainCfgGetOptimizationLevel(OH_AI_TrainCfgHandle train_cfg); 207be168c0dSopenharmony_ci 208be168c0dSopenharmony_ci/** 209be168c0dSopenharmony_ci * @brief Set optimization level of the train_cfg. Only valid for Lite Train. 210be168c0dSopenharmony_ci * @param train_cfg TrainCfg object handle. 211be168c0dSopenharmony_ci * @param level The optimization level of train_cfg. 212be168c0dSopenharmony_ci * @since 11 213be168c0dSopenharmony_ci */ 214be168c0dSopenharmony_ciOH_AI_API void OH_AI_TrainCfgSetOptimizationLevel(OH_AI_TrainCfgHandle train_cfg, OH_AI_OptimizationLevel level); 215be168c0dSopenharmony_ci 216be168c0dSopenharmony_ci/** 217be168c0dSopenharmony_ci * @brief Build the train model from model buffer so that it can run on a device. Only valid for Lite Train. 218be168c0dSopenharmony_ci * @param model Model object handle. 219be168c0dSopenharmony_ci * @param model_data Define the buffer read from a model file. 220be168c0dSopenharmony_ci * @param data_size Define bytes number of model file buffer. 221be168c0dSopenharmony_ci * @param model_type Define The type of model file. 222be168c0dSopenharmony_ci * @param model_context Define the context used to store options during execution. 223be168c0dSopenharmony_ci * @param train_cfg Define the config used by training. 224be168c0dSopenharmony_ci * @return OH_AI_Status. 225be168c0dSopenharmony_ci * @since 11 226be168c0dSopenharmony_ci */ 227be168c0dSopenharmony_ciOH_AI_API OH_AI_Status OH_AI_TrainModelBuild(OH_AI_ModelHandle model, const void *model_data, size_t data_size, 228be168c0dSopenharmony_ci OH_AI_ModelType model_type, const OH_AI_ContextHandle model_context, 229be168c0dSopenharmony_ci const OH_AI_TrainCfgHandle train_cfg); 230be168c0dSopenharmony_ci 231be168c0dSopenharmony_ci/** 232be168c0dSopenharmony_ci * @brief Build the train model from model file buffer so that it can run on a device. Only valid for Lite Train. 233be168c0dSopenharmony_ci * @param model Model object handle. 234be168c0dSopenharmony_ci * @param model_path Define the model path. 235be168c0dSopenharmony_ci * @param model_type Define The type of model file. 236be168c0dSopenharmony_ci * @param model_context Define the context used to store options during execution. 237be168c0dSopenharmony_ci * @param train_cfg Define the config used by training. 238be168c0dSopenharmony_ci * @return OH_AI_Status. 239be168c0dSopenharmony_ci * @since 11 240be168c0dSopenharmony_ci */ 241be168c0dSopenharmony_ciOH_AI_API OH_AI_Status OH_AI_TrainModelBuildFromFile(OH_AI_ModelHandle model, const char *model_path, 242be168c0dSopenharmony_ci OH_AI_ModelType model_type, 243be168c0dSopenharmony_ci const OH_AI_ContextHandle model_context, 244be168c0dSopenharmony_ci const OH_AI_TrainCfgHandle train_cfg); 245be168c0dSopenharmony_ci 246be168c0dSopenharmony_ci/** 247be168c0dSopenharmony_ci * @brief Train model by step. Only valid for Lite Train. 248be168c0dSopenharmony_ci * @param model Model object handle. 249be168c0dSopenharmony_ci * @param before CallBack before predict. 250be168c0dSopenharmony_ci * @param after CallBack after predict. 251be168c0dSopenharmony_ci * @return OH_AI_Status. 252be168c0dSopenharmony_ci * @since 11 253be168c0dSopenharmony_ci */ 254be168c0dSopenharmony_ciOH_AI_API OH_AI_Status OH_AI_RunStep(OH_AI_ModelHandle model, const OH_AI_KernelCallBack before, 255be168c0dSopenharmony_ci const OH_AI_KernelCallBack after); 256be168c0dSopenharmony_ci 257be168c0dSopenharmony_ci/** 258be168c0dSopenharmony_ci * @brief Sets the Learning Rate of the training. Only valid for Lite Train. 259be168c0dSopenharmony_ci * @param learning_rate to set. 260be168c0dSopenharmony_ci * @return OH_AI_Status of operation. 261be168c0dSopenharmony_ci * @since 11 262be168c0dSopenharmony_ci */ 263be168c0dSopenharmony_ciOH_AI_API OH_AI_Status OH_AI_ModelSetLearningRate(OH_AI_ModelHandle model, float learning_rate); 264be168c0dSopenharmony_ci 265be168c0dSopenharmony_ci/** 266be168c0dSopenharmony_ci * @brief Obtains the Learning Rate of the optimizer. Only valid for Lite Train. 267be168c0dSopenharmony_ci * @param model Model object handle. 268be168c0dSopenharmony_ci * @return Learning rate. 0.0 if no optimizer was found. 269be168c0dSopenharmony_ci * @since 11 270be168c0dSopenharmony_ci */ 271be168c0dSopenharmony_ciOH_AI_API float OH_AI_ModelGetLearningRate(OH_AI_ModelHandle model); 272be168c0dSopenharmony_ci 273be168c0dSopenharmony_ci/** 274be168c0dSopenharmony_ci * @brief Obtains all weights tensors of the model. Only valid for Lite Train. 275be168c0dSopenharmony_ci * @param model Model object handle. 276be168c0dSopenharmony_ci * @return The vector that includes all gradient tensors. 277be168c0dSopenharmony_ci * @since 11 278be168c0dSopenharmony_ci */ 279be168c0dSopenharmony_ciOH_AI_API OH_AI_TensorHandleArray OH_AI_ModelGetWeights(OH_AI_ModelHandle model); 280be168c0dSopenharmony_ci 281be168c0dSopenharmony_ci/** 282be168c0dSopenharmony_ci * @brief update weights tensors of the model. Only valid for Lite Train. 283be168c0dSopenharmony_ci * @param new_weights A vector new weights. 284be168c0dSopenharmony_ci * @return OH_AI_Status 285be168c0dSopenharmony_ci * @since 11 286be168c0dSopenharmony_ci */ 287be168c0dSopenharmony_ciOH_AI_API OH_AI_Status OH_AI_ModelUpdateWeights(OH_AI_ModelHandle model, const OH_AI_TensorHandleArray new_weights); 288be168c0dSopenharmony_ci 289be168c0dSopenharmony_ci/** 290be168c0dSopenharmony_ci * @brief Get the model running mode. 291be168c0dSopenharmony_ci * @param model Model object handle. 292be168c0dSopenharmony_ci * @return Is Train Mode or not. 293be168c0dSopenharmony_ci * @since 11 294be168c0dSopenharmony_ci */ 295be168c0dSopenharmony_ciOH_AI_API bool OH_AI_ModelGetTrainMode(OH_AI_ModelHandle model); 296be168c0dSopenharmony_ci 297be168c0dSopenharmony_ci/** 298be168c0dSopenharmony_ci * @brief Set the model running mode. Only valid for Lite Train. 299be168c0dSopenharmony_ci * @param model Model object handle. 300be168c0dSopenharmony_ci * @param train True means model runs in Train Mode, otherwise Eval Mode. 301be168c0dSopenharmony_ci * @return OH_AI_Status. 302be168c0dSopenharmony_ci * @since 11 303be168c0dSopenharmony_ci */ 304be168c0dSopenharmony_ciOH_AI_API OH_AI_Status OH_AI_ModelSetTrainMode(OH_AI_ModelHandle model, bool train); 305be168c0dSopenharmony_ci 306be168c0dSopenharmony_ci/** 307be168c0dSopenharmony_ci * @brief Setup training with virtual batches. Only valid for Lite Train. 308be168c0dSopenharmony_ci * @param model Model object handle. 309be168c0dSopenharmony_ci * @param virtual_batch_multiplier Virtual batch multiplier, use any number < 1 to disable. 310be168c0dSopenharmony_ci * @param lr Learning rate to use for virtual batch, -1 for internal configuration. 311be168c0dSopenharmony_ci * @param momentum Batch norm momentum to use for virtual batch, -1 for internal configuration. 312be168c0dSopenharmony_ci * @return OH_AI_Status. 313be168c0dSopenharmony_ci * @since 11 314be168c0dSopenharmony_ci */ 315be168c0dSopenharmony_ciOH_AI_API OH_AI_Status OH_AI_ModelSetupVirtualBatch(OH_AI_ModelHandle model, int virtual_batch_multiplier, float lr, 316be168c0dSopenharmony_ci float momentum); 317be168c0dSopenharmony_ci 318be168c0dSopenharmony_ci/** 319be168c0dSopenharmony_ci * @brief Export training model from file. Only valid for Lite Train. 320be168c0dSopenharmony_ci * @param model The model data. 321be168c0dSopenharmony_ci * @param model_type The model file type. 322be168c0dSopenharmony_ci * @param model_file The exported model file. 323be168c0dSopenharmony_ci * @param quantization_type The quantification type. 324be168c0dSopenharmony_ci * @param export_inference_only Whether to export a reasoning only model. 325be168c0dSopenharmony_ci * @param output_tensor_name The set the name of the output tensor of the exported reasoning model, default as 326be168c0dSopenharmony_ci * empty, and export the complete reasoning model. 327be168c0dSopenharmony_ci * @param num The number of output_tensor_name. 328be168c0dSopenharmony_ci * @return OH_AI_Status. 329be168c0dSopenharmony_ci * @since 11 330be168c0dSopenharmony_ci */ 331be168c0dSopenharmony_ciOH_AI_API OH_AI_Status OH_AI_ExportModel(OH_AI_ModelHandle model, OH_AI_ModelType model_type, const char *model_file, 332be168c0dSopenharmony_ci OH_AI_QuantizationType quantization_type, bool export_inference_only, 333be168c0dSopenharmony_ci char **output_tensor_name, size_t num); 334be168c0dSopenharmony_ci 335be168c0dSopenharmony_ci/** 336be168c0dSopenharmony_ci * @brief Export training model from buffer. Only valid for Lite Train. 337be168c0dSopenharmony_ci * @param model The model data. 338be168c0dSopenharmony_ci * @param model_type The model file type. 339be168c0dSopenharmony_ci * @param model_data The exported model buffer. 340be168c0dSopenharmony_ci * @param data_size The exported model buffer size. 341be168c0dSopenharmony_ci * @param quantization_type The quantification type. 342be168c0dSopenharmony_ci * @param export_inference_only Whether to export a reasoning only model. 343be168c0dSopenharmony_ci * @param output_tensor_name The set the name of the output tensor of the exported reasoning model, default as 344be168c0dSopenharmony_ci * empty, and export the complete reasoning model. 345be168c0dSopenharmony_ci * @param num The number of output_tensor_name. 346be168c0dSopenharmony_ci * @return OH_AI_Status. 347be168c0dSopenharmony_ci * @since 11 348be168c0dSopenharmony_ci */ 349be168c0dSopenharmony_ciOH_AI_API OH_AI_Status OH_AI_ExportModelBuffer(OH_AI_ModelHandle model, OH_AI_ModelType model_type, char **model_data, 350be168c0dSopenharmony_ci size_t *data_size, OH_AI_QuantizationType quantization_type, 351be168c0dSopenharmony_ci bool export_inference_only, char **output_tensor_name, size_t num); 352be168c0dSopenharmony_ci 353be168c0dSopenharmony_ci/** 354be168c0dSopenharmony_ci * @brief Export model's weights, which can be used in micro only. Only valid for Lite Train. 355be168c0dSopenharmony_ci * @param model The model data. 356be168c0dSopenharmony_ci * @param model_type The model file type. 357be168c0dSopenharmony_ci * @param weight_file The path of exported weight file. 358be168c0dSopenharmony_ci * @param is_inference Whether to export weights from a reasoning model. Currently, only support this is `true`. 359be168c0dSopenharmony_ci * @param enable_fp16 Float-weight is whether to be saved in float16 format. 360be168c0dSopenharmony_ci * @param changeable_weights_name The set the name of these weight tensors, whose shape is changeable. 361be168c0dSopenharmony_ci * @param num The number of changeable_weights_name. 362be168c0dSopenharmony_ci * @return OH_AI_Status. 363be168c0dSopenharmony_ci * @since 11 364be168c0dSopenharmony_ci */ 365be168c0dSopenharmony_ciOH_AI_API OH_AI_Status OH_AI_ExportWeightsCollaborateWithMicro(OH_AI_ModelHandle model, OH_AI_ModelType model_type, 366be168c0dSopenharmony_ci const char *weight_file, bool is_inference, 367be168c0dSopenharmony_ci bool enable_fp16, char **changeable_weights_name, 368be168c0dSopenharmony_ci size_t num); 369be168c0dSopenharmony_ci 370be168c0dSopenharmony_ci#ifdef __cplusplus 371be168c0dSopenharmony_ci} 372be168c0dSopenharmony_ci#endif 373be168c0dSopenharmony_ci#endif // MINDSPORE_INCLUDE_C_API_MODEL_C_H 374