diff --git a/docs/lite/api/source_en/api_java/ascend_device_info.md b/docs/lite/api/source_en/api_java/ascend_device_info.md new file mode 100644 index 0000000000000000000000000000000000000000..6643479777f491f2558c2b4b54dc003adc528dab --- /dev/null +++ b/docs/lite/api/source_en/api_java/ascend_device_info.md @@ -0,0 +1,380 @@ +# AscendDeviceInfo + +[![View Source On Gitee](https://mindspore-website.obs.cn-north-4.myhuaweicloud.com/website-images/master/resource/_static/logo_source_en.svg)](https://gitee.com/mindspore/docs/blob/master/docs/lite/api/source_en/api_java/ascend_device_info.md) + +```java +import com.mindspore.config.AscendDeviceInfo; +``` + +The AscendDeviceInfo class is used to configure MindSpore Lite Ascend device options. + +## Public Member Functions + +| function | Supported At Cloud-side Inference | Supported At Device-side Inference | +| ------------------------------------------ |--------|--------| +| [int getDeviceID)](#getDeviceID) | √ | ✕ | +| [int getDeviceType](#getDeviceType) | √ | ✕ | +| [String getProvider](#getProvider) | √ | ✕ | +| [void setProvider(String provider)](#setProvider) | √ | ✕ | +| [void setDeviceID(int deviceId)](#setDeviceID) | √ | ✕ | +| [int getRankID()](#getRankID) | √ | ✕ | +| [void setRankID(int rankId)](#setRankID) | √ | ✕ | +| [String getInsertOpConfigPath()](#getInsertOpConfigPath) | √ | ✕ | +| [void setInsertOpConfigPath(String insertOpConfigPath)](#setInsertOpConfigPath) | √ | ✕ | +| [String getInputFormat()](#getInputFormat) | √ | ✕ | +| [void setInputFormat(String inputFormat)](#setInputFormat) | √ | ✕ | +| [String getInputShape()](#getInputShape) | √ | ✕ | +| [void setInputShape(String inputShape)](#setInputShape) | √ | ✕ | +| [HashMap> getInputShapeMap()](#getInputShapeMap) | √ | ✕ | +| [void setInputShapeMap(HashMap> inputShapeMap)](#setInputShapeMap) | √ | ✕ | +| [ArrayList getDynamicBatchSize()](#getDynamicBatchSize) | √ | ✕ | +| [void setDynamicBatchSize(ArrayList dynamicBatchSize)](#setDynamicBatchSize) | √ | ✕ | +| [String getDynamicImageSize()](#getDynamicImageSize) | √ | ✕ | +| [void setDynamicImageSize(String dynamicImageSize)](#setDynamicImageSize) | √ | ✕ | +| [int getOutputType()](#getOutputType) | √ | ✕ | +| [void setOutputType(int outputType)](#setOutputType) | √ | ✕ | +| [String getPrecisionMode()](#getPrecisionMode) | √ | ✕ | +| [void setPrecisionMode(String precisionMode)](#setPrecisionMode) | √ | ✕ | +| [String getOpSelectImplMode()](#getOpSelectImplMode) | √ | ✕ | +| [void setOpSelectImplMode(String opSelectImplMode)](#setOpSelectImplMode) | √ | ✕ | +| [String getFusionSwitchConfigPath()](#getFusionSwitchConfigPath) | √ | ✕ | +| [void setFusionSwitchConfigPath(String fusionSwitchConfigPath)](#setFusionSwitchConfigPath) | √ | ✕ | +| [String getBufferOptimizeMode()](#getBufferOptimizeMode) | √ | ✕ | +| [void setBufferOptimizeMode(String bufferOptimizeMode)](#setBufferOptimizeMode) | √ | ✕ | + +## getDeviceID + +```java +public int getDeviceID() +``` + +Get the Ascend device ID. + +- Returns + + the deviceId. + +## getDeviceType + +```java +public int getDeviceType() +``` + +Get the device type. + +- Returns + + the deviceType. + +## getProvider + +```java +public String getProvider() +``` + +Get Ascend device provider. + +- Returns + + the provider. + +## setProvider + +```java +public void setProvider(String provider) +``` + +Set Ascend device provider. + +- Parameters +- `provider`: provider the provider to set. + +## setDeviceID + +```java +public void setDeviceID(int deviceId) +``` + +Set the Ascend device ID. + +- Parameters +- `deviceId`: deviceId the deviceId to set. + +## getRankID + +```java +public int getRankID() +``` + +Get the logical ID of a distributed model in the cluster. + +- Returns + + the rankId. + +## setRankID + +```java +public void setRankID(int rankId) +``` + +Set the logical ID of a distributed model in the cluster. + +- Parameters + +- `rankId`: rankId the rankId to set. + +## getInsertOpConfigPath + +```java +public String getInsertOpConfigPath() +``` + +Get the AIPP configuration file path. + +- Returns + + the insertOpConfigPath. + +## setInsertOpConfigPath + +```java +public void setInsertOpConfigPath(String insertOpConfigPath) +``` + +Set the AIPP configuration file path. + +- Parameters + + - `insertOpConfigPath`: insertOpConfigPath AIPP configuration file path. + +## getInputFormat + +```java +public String getInputFormat() +``` + +Get the input format of the model. + +- Returns + + the inputFormat. + +## setInputFormat + +```java +public void setInputFormat(String inputFormat) +``` + +Set the input format of the model.Optional "NCHW", "NHWC", and "ND" + +- Parameters + +- `inputFormat`: inputFormat . + +## getInputShape + +```java +public String getInputShape() +``` + +Get the input shape of the model. + +- Returns + + the inputShape. + +## setInputShape + +```java +public void setInputShape(String inputShape) +``` + +Set the input shape of the model. e.g. "input_op_name1:1,2,3,4;input_op_name2:4,3,2,1;". + +- Parameters +- `inputShape`: inputShape Model input shape. + +## getInputShapeMap + +```java +public HashMap> getInputShapeMap() +``` + +Get the input shape mapping of the model. + +- Returns + + the inputShapeMap. + +## setInputShapeMap + +```java +public void setInputShapeMap(HashMap> inputShapeMap) +``` + +Model input shape. e.g. {{0, {1,2,3,4}}, {1, {4,3,2,1}}}。 + +- Parameters +- `inputShapeMap`: inputShapeMap the inputShapeMap to set. + +## getDynamicBatchSize + +```java +public ArrayList getDynamicBatchSize() +``` + +Get the dynamic batch sizes of the model. + +- Returns + + the dynamicBatchSize. + +## setDynamicBatchSize + +```java +public void setDynamicBatchSize(ArrayList dynamicBatchSize) +``` + +Dynamic batch sizes of model inputs. Ranges from 2 to 100. e.g. {1, 2} means batch size 1 and 2 are configured. + +- Parameters +- `dynamicBatchSize`: dynamicBatchSize the dynamicBatchSize to set. + +## getDynamicImageSize + +```java +public String getDynamicImageSize() +``` + +Get the dynamic image sizes of the model. + +- Returns + + the dynamicImageSize. + +## setDynamicImageSize + +```java +public void setDynamicImageSize(String dynamicImageSize) +``` + +Set the dynamic image sizes of the model. + +- Parameters +- `dynamicImageSize`: dynamicImageSize the dynamicImageSize to set. + +## getOutputType + +```java +public int getOutputType() +``` + +Get the output type of the model. + +- Returns + + the outputType. + +## setOutputType + +```java +public void setOutputType(int outputType) +``` + +Set the type of model outputs. can be DataType.kNumberTypeFloat32, DataType.kNumberTypeUInt8, or DataType.kNumberTypeFloat16. + +- Parameters +- `outputType`: outputType the outputType to set. + +## getPrecisionMode + +```java +public String getPrecisionMode() +``` + +Get the precision mode of the model. + +- Returns + + the precisionMode. + +## setPrecisionMode + +```java +public void setPrecisionMode(String precisionMode) +``` + +Set the precision mode. Optional "enforce_fp16", "preferred_fp32", "enforce_origin", "enforce_fp32", and "preferred_optimal". "enforce_fp16" is set as default. + +- Parameters +- `precisionMode`: precisionMode. + +## getOpSelectImplMode + +```java +public String getOpSelectImplMode() +``` + +Get the operator selection implementation mode of the model. + +- Returns + + the opSelectImplMode. + +## setOpSelectImplMode + +```java +public void setOpSelectImplMode(String opSelectImplMode) +``` + +Set the operator selection implementation mode of the model. Optional "high_performance" and "high_precision". "high_performace" is set as default. + +- Parameters +- `opSelectImplMode`: opSelectImplMode. + +## getFusionSwitchConfigPath + +```java +public String getFusionSwitchConfigPath() +``` + +Get fusion switch config file path. It controls which fusion passes to be turned off. + +- Returns + + the fusionSwitchConfigPath. + +## setFusionSwitchConfigPath + +```java +public void setFusionSwitchConfigPath(String fusionSwitchConfigPath) +``` + +Set fusion switch config file path. + +- Parameters +- `fusionSwitchConfigPath`: fusionSwitchConfigPath the fusionSwitchConfigPath to set. + +## getBufferOptimizeMode + +```java +public String getBufferOptimizeMode() +``` + +Set the buffer optimize mode. Optional "l1_optimize", "l2_optimize", or "off_optimize". "l2_optimize" is set as default. + +- Returns + + the bufferOptimizeMode. + +## setBufferOptimizeMode + +```java +public void setBufferOptimizeMode(String bufferOptimizeMode) +``` + +Set the buffer optimization mode of the model. + +- Parameters +- `bufferOptimizeMode`: bufferOptimizeMode the bufferOptimizeMode to set. \ No newline at end of file diff --git a/docs/lite/api/source_en/api_java/class_list.md b/docs/lite/api/source_en/api_java/class_list.md index e274fda95397cfd45d3ec972f8b6c8518626e701..81add4fee390e3b4ad5dbe8940421ae4c8746b96 100644 --- a/docs/lite/api/source_en/api_java/class_list.md +++ b/docs/lite/api/source_en/api_java/class_list.md @@ -10,10 +10,11 @@ | com.mindspore | [ModelParallelRunner](https://www.mindspore.cn/lite/api/en/master/api_java/model_parallel_runner.html) | Defines MindSpore Lite concurrent inference. | √ | ✕ | | com.mindspore.config | [RunnerConfig](https://www.mindspore.cn/lite/api/en/master/api_java/runner_config.html) | RunnerConfig defines configuration parameters for concurrent inference. | √ | ✕ | | com.mindspore | [Graph](https://www.mindspore.cn/lite/api/en/master/api_java/graph.html) | Graph defines the compute graph in MindSpore. | ✕ | √ | -| com.mindspore.config | [CpuBindMode](https://gitee.com/mindspore/mindspore-lite/blob/master/mindspore-lite/java/src/main/java/com/mindspore/config/CpuBindMode.java) | CpuBindMode defines the CPU binding mode. | √ | √ | -| com.mindspore.config | [DeviceType](https://gitee.com/mindspore/mindspore-lite/blob/master/mindspore-lite/java/src/main/java/com/mindspore/config/DeviceType.java) | DeviceType defines the back-end device type. | √ | √ | -| com.mindspore.config | [DataType](https://gitee.com/mindspore/mindspore-lite/blob/master/mindspore-lite/java/src/main/java/com/mindspore/config/DataType.java) | DataType defines the supported data types. | √ | √ | -| com.mindspore.config | [Version](https://gitee.com/mindspore/mindspore-lite/blob/master/mindspore-lite/java/src/main/java/com/mindspore/config/Version.java) | Version is used to obtain the version information of MindSpore. | ✕ | √ | -| com.mindspore.config | [ModelType](https://gitee.com/mindspore/mindspore-lite/blob/master/mindspore-lite/java/src/main/java/com/mindspore/config/ModelType.java) | ModelType defines the model file type. | √ | √ | -| com.mindspore.config | [AscendDeviceInfo](https://gitee.com/mindspore/mindspore-lite/blob/master/mindspore-lite/java/src/main/java/com/mindspore/config/AscendDeviceInfo.java) | The AscendDeviceInfo class is used to configure MindSpore Lite Ascend device options. | √ | ✕ | -| com.mindspore.config | [TrainCfg](https://gitee.com/mindspore/mindspore-lite/blob/master/mindspore-lite/java/src/main/java/com/mindspore/config/TrainCfg.java) | Configuration parameters used for model training on the device. | ✕ | √ | +| com.mindspore.config | [CpuBindMode](https://www.mindspore.cn/lite/api/en/master/api_java/mscontext.html#cpubindmode) | CpuBindMode defines the CPU binding mode. | √ | √ | +| com.mindspore.config | [DeviceType](https://www.mindspore.cn/lite/api/en/master/api_java/mscontext.html#devicetype) | DeviceType defines the back-end device type. | √ | √ | +| com.mindspore.config | [DataType](https://www.mindspore.cn/lite/api/en/master/api_java/mstensor.html#datatype) | DataType defines the supported data types. | √ | √ | +| com.mindspore.config | [Version](https://www.mindspore.cn/lite/api/en/master/api_java/Version.html) | Version is used to obtain the version information of MindSpore. | ✕ | √ | +| com.mindspore.config | [ModelType](https://www.mindspore.cn/lite/api/en/master/api_java/model.html#modeltype) | ModelType defines the model file type. | √ | √ | +| com.mindspore.config | [AscendDeviceInfo](https://www.mindspore.cn/lite/api/en/master/api_java/AscendDeviceInfo.html) | The AscendDeviceInfo class is used to configure MindSpore Lite Ascend device options. | √ | ✕ | +| com.mindspore.config | [TrainCfg](https://www.mindspore.cn/lite/api/en/master/api_java/TrainCfg.html) | Configuration parameters used for model training on the device. | ✕ | √ | + diff --git a/docs/lite/api/source_en/api_java/train_cfg.md b/docs/lite/api/source_en/api_java/train_cfg.md new file mode 100644 index 0000000000000000000000000000000000000000..8ec3065c55ce220bf8cb826e57fa4350fec239f2 --- /dev/null +++ b/docs/lite/api/source_en/api_java/train_cfg.md @@ -0,0 +1,84 @@ +# TrainCfg + +[![View Source On Gitee](https://mindspore-website.obs.cn-north-4.myhuaweicloud.com/website-images/master/resource/_static/logo_source_en.svg)](https://gitee.com/mindspore/docs/blob/master/docs/lite/api/source_en/api_java/train_cfg.md) + +```java +import com.mindspore.config.TrainCfg; +``` + +Configuration parameters used for model training on the device. + +## Public Member Functions + +| function | Supported At Cloud-side Inference | Supported At Device-side Inference | +| ------------------------------------------ |--------|--------| +| [boolean init()](#init) | ✕ | √ | +| [boolean init(String loss_name)](#init) | ✕ | √ | +| [void free()](#free) | ✕ | √ | +| [boolean addMixPrecisionCfg(boolean dynamicLossScale, float lossScale, int thresholdIterNum)](#addMixPrecisionCfg) | ✕ | √ | +| [long getTrainCfgPtr()](#getTrainCfgPtr) | ✕ | √ | + +## init + +```java +public boolean init() +``` + +Init train config. + +- Returns + + init status. + +```java +public boolean init(String loss_name) +``` + +Init train config specified loss name. + +- Parameters + +- `loss_name`: loss_name loss name used for split inference and train part. + +- Returns + + 初始化状态。 + +## free + +```java +public void free() +``` + +Free train config. + +## addMixPrecisionCfg + +```java +public boolean addMixPrecisionCfg(boolean dynamicLossScale, float lossScale, int thresholdIterNum) +``` + +Add mix precision config to train config. + +- Parameters +- `dynamicLossScale`: dynamicLossScale if dynamic or fix loss scale factor. + +- `lossScale`: loss scale factor. + +- `thresholdIterNum`: thresholdIterNum a threshold for modifying loss scale when dynamic loss scale is enabled. + +- Returns + + add status. + +## getTrainCfgPtr + +```java +public long getTrainCfgPtr() +``` + +Get train config pointer. + +- Returns + + train config pointer. diff --git a/docs/lite/api/source_en/api_java/version.md b/docs/lite/api/source_en/api_java/version.md new file mode 100644 index 0000000000000000000000000000000000000000..99903c00f88851d726b3c6e050568927be42da82 --- /dev/null +++ b/docs/lite/api/source_en/api_java/version.md @@ -0,0 +1,36 @@ +# Version + +[![View Source On Gitee](https://mindspore-website.obs.cn-north-4.myhuaweicloud.com/website-images/master/resource/_static/logo_source_en.svg)](https://gitee.com/mindspore/docs/blob/master/docs/lite/api/source_en/api_java/version.md) + +```java +import com.mindspore.config.Version; +``` + +Get MindSpore Lite version info. + +## Public Member Functions + +| function | Supported At Cloud-side Inference | Supported At Device-side Inference | +| ------------------------------------------ |--------|--------| +| [static void init()](#init) | √ | √ | +| [static native String version()](#version) | √ | √ | + +## init + +```java +public static void init() +``` + +Init function. + +## version + +```java +public static native String version() +``` + +Get MindSpore Lite version info. + +- Returns + + MindSpore Lite version info. diff --git a/docs/lite/api/source_en/index.rst b/docs/lite/api/source_en/index.rst index 522bcff0e167aa1bb42a2ec22d9c68a77aabe531..5c486f06cc88dd6c4058a7f792c5077af55b121f 100644 --- a/docs/lite/api/source_en/index.rst +++ b/docs/lite/api/source_en/index.rst @@ -378,4 +378,7 @@ Summary of MindSpore Lite API support api_java/graph api_java/runner_config api_java/model_parallel_runner + api_java/ascend_device_info + api_java/train_cfg + api_java/version api_java/lite_java_example diff --git a/docs/lite/api/source_zh_cn/api_java/ascend_device_info.md b/docs/lite/api/source_zh_cn/api_java/ascend_device_info.md new file mode 100644 index 0000000000000000000000000000000000000000..01ae3d34f5febc744b05bcbb245df17c83262282 --- /dev/null +++ b/docs/lite/api/source_zh_cn/api_java/ascend_device_info.md @@ -0,0 +1,380 @@ +# AscendDeviceInfo + +[![查看源文件](https://mindspore-website.obs.cn-north-4.myhuaweicloud.com/website-images/master/resource/_static/logo_source.svg)](https://gitee.com/mindspore/docs/blob/master/docs/lite/api/source_zh_cn/api_java/ascenddeviceinfo.md) + +```java +import com.mindspore.config.AscendDeviceInfo; +``` + +用于配置MindSpore Lite Ascend设备选项。 + +## 公有成员函数 + +| function | 云侧推理是否支持 | 端侧推理是否支持 | +| ------------------------------------------ |--------|--------| +| [int getDeviceID)](#getDeviceID) | √ | ✕ | +| [int getDeviceType](#getDeviceType) | √ | ✕ | +| [String getProvider](#getProvider) | √ | ✕ | +| [void setProvider(String provider)](#setProvider) | √ | ✕ | +| [void setDeviceID(int deviceId)](#setDeviceID) | √ | ✕ | +| [int getRankID()](#getRankID) | √ | ✕ | +| [void setRankID(int rankId)](#setRankID) | √ | ✕ | +| [String getInsertOpConfigPath()](#getInsertOpConfigPath) | √ | ✕ | +| [void setInsertOpConfigPath(String insertOpConfigPath)](#setInsertOpConfigPath) | √ | ✕ | +| [String getInputFormat()](#getInputFormat) | √ | ✕ | +| [void setInputFormat(String inputFormat)](#setInputFormat) | √ | ✕ | +| [String getInputShape()](#getInputShape) | √ | ✕ | +| [void setInputShape(String inputShape)](#setInputShape) | √ | ✕ | +| [HashMap> getInputShapeMap()](#getInputShapeMap) | √ | ✕ | +| [void setInputShapeMap(HashMap> inputShapeMap)](#setInputShapeMap) | √ | ✕ | +| [ArrayList getDynamicBatchSize()](#getDynamicBatchSize) | √ | ✕ | +| [void setDynamicBatchSize(ArrayList dynamicBatchSize)](#setDynamicBatchSize) | √ | ✕ | +| [String getDynamicImageSize()](#getDynamicImageSize) | √ | ✕ | +| [void setDynamicImageSize(String dynamicImageSize)](#setDynamicImageSize) | √ | ✕ | +| [int getOutputType()](#getOutputType) | √ | ✕ | +| [void setOutputType(int outputType)](#setOutputType) | √ | ✕ | +| [String getPrecisionMode()](#getPrecisionMode) | √ | ✕ | +| [void setPrecisionMode(String precisionMode)](#setPrecisionMode) | √ | ✕ | +| [String getOpSelectImplMode()](#getOpSelectImplMode) | √ | ✕ | +| [void setOpSelectImplMode(String opSelectImplMode)](#setOpSelectImplMode) | √ | ✕ | +| [String getFusionSwitchConfigPath()](#getFusionSwitchConfigPath) | √ | ✕ | +| [void setFusionSwitchConfigPath(String fusionSwitchConfigPath)](#setFusionSwitchConfigPath) | √ | ✕ | +| [String getBufferOptimizeMode()](#getBufferOptimizeMode) | √ | ✕ | +| [void setBufferOptimizeMode(String bufferOptimizeMode)](#setBufferOptimizeMode) | √ | ✕ | + +## getDeviceID + +```java +public int getDeviceID() +``` + +获取昇腾设备ID。 + +- 返回值 + + 设备ID。 + +## getDeviceType + +```java +public int getDeviceType() +``` + +获取昇腾设备类型。 + +- 返回值 + + 设备类型。 + +## getProvider + +```java +public String getProvider() +``` + +获取模型后端类型。 + +- 返回值 + + 模型后端类型。 + +## setProvider + +```java +public void setProvider(String provider) +``` + +设置模型后端类型。 + +- 参数 +- `provider`: 要设置的模型后端类型。 + +## setDeviceID + +```java +public void setDeviceID(int deviceId) +``` + +设置昇腾设备ID。 + +- 参数 +- `deviceId`: 要设置的设备ID。 + +## getRankID + +```java +public int getRankID() +``` + +获取集群中分布式模型的逻辑ID。 + +- 返回值 + + 逻辑ID。 + +## setRankID + +```java +public void setRankID(int rankId) +``` + +设置集群中分布式模型的逻辑ID。 + +- 参数 + +- `rankId`: 要设置的逻辑ID。 + +## getInsertOpConfigPath + +```java +public String getInsertOpConfigPath() +``` + +获取AIPP配置文件路径。 + +- 返回值 + + 配置文件路径。 + +## setInsertOpConfigPath + +```java +public void setInsertOpConfigPath(String insertOpConfigPath) +``` + +设置AIPP配置文件路径。 + +- 参数 + + - `insertOpConfigPath`: 要设置的AIPP配置文件路径。 + +## getInputFormat + +```java +public String getInputFormat() +``` + +获取模型的输入格式。 + +- 返回值 + + 输入格式。 + +## setInputFormat + +```java +public void setInputFormat(String inputFormat) +``` + +设置模型的输入格式。可选"NCHW","NHWC"和"ND"。 + +- 参数 + +- `inputFormat`: 要设置的输入格式。 + +## getInputShape + +```java +public String getInputShape() +``` + +获取模型的输入形状。 + +- 返回值 + + 输入形状。 + +## setInputShape + +```java +public void setInputShape(String inputShape) +``` + +设置模型的输入形状。例如"input_op_name1:1,2,3,4;input_op_name2:4,3,2,1;"。 + +- 参数 +- `inputShape`: 模型输入形状。 + +## getInputShapeMap + +```java +public HashMap> getInputShapeMap() +``` + +获取模型的输入形状映射。 + +- 返回值 + + 输入形状映射。 + +## setInputShapeMap + +```java +public void setInputShapeMap(HashMap> inputShapeMap) +``` + +设置模型的输入形状。例如{{0, {1,2,3,4}}, {1, {4,3,2,1}}}。 + +- 参数 +- `inputShapeMap`: 要设置的输入形状映射。 + +## getDynamicBatchSize + +```java +public ArrayList getDynamicBatchSize() +``` + +获取模型的动态batch大小。 + +- 返回值 + + 动态batch大小。 + +## setDynamicBatchSize + +```java +public void setDynamicBatchSize(ArrayList dynamicBatchSize) +``` + +设置模型的动态batch大小。取值范围为 2 到 100。例如 {1, 2} 表示batch大小配置为 1 和 2。 + +- 参数 +- `dynamicBatchSize`: 要设置的动态batch大小。 + +## getDynamicImageSize + +```java +public String getDynamicImageSize() +``` + +获取模型的动态图像尺寸。 + +- 返回值 + + 动态图像尺寸。 + +## setDynamicImageSize + +```java +public void setDynamicImageSize(String dynamicImageSize) +``` + +设置模型的动态图像尺寸。 + +- 参数 +- `dynamicImageSize`: 要设置的动态图像尺寸。 + +## getOutputType + +```java +public int getOutputType() +``` + +获取模型的输出类型。 + +- 返回值 + + 输出类型。 + +## setOutputType + +```java +public void setOutputType(int outputType) +``` + +设置模型的输出类型。可以是 DataType.kNumberTypeFloat32、DataType.kNumberTypeUInt8 或 DataType.kNumberTypeFloat16。 + +- 参数 +- `outputType`: 要设置的输出类型。 + +## getPrecisionMode + +```java +public String getPrecisionMode() +``` + +获取模型的精度模式。 + +- 返回值 + + 精度模式。 + +## setPrecisionMode + +```java +public void setPrecisionMode(String precisionMode) +``` + +设置模型的精度模式。可选"enforce_fp16"、"preferred_fp32"、"enforce_origin"、"enforce_fp32" 和 "preferred_optimal","enforce_fp16" 为默认值。 + +- 参数 +- `precisionMode`: 要设置的精度模式。 + +## getOpSelectImplMode + +```java +public String getOpSelectImplMode() +``` + +获取模型的算子选择实现方式。 + +- 返回值 + + 算子实现方式。 + +## setOpSelectImplMode + +```java +public void setOpSelectImplMode(String opSelectImplMode) +``` + +设置模型的算子选择实现方式。可选“high_performance”和“high_precision”,默认设置为“high_performace”。 + +- 参数 +- `opSelectImplMode`: 算子实现方式。 + +## getFusionSwitchConfigPath + +```java +public String getFusionSwitchConfigPath() +``` + +获取融合开关配置文件路径,它控制要关闭哪些融合pass。 + +- 返回值 + + 融合开关配置文件路径。 + +## setFusionSwitchConfigPath + +```java +public void setFusionSwitchConfigPath(String fusionSwitchConfigPath) +``` + +设置融合开关配置文件路径。 + +- 参数 +- `fusionSwitchConfigPath`: 要设置的融合开关配置文件路径。 + +## getBufferOptimizeMode + +```java +public String getBufferOptimizeMode() +``` + +获取缓冲区优化模式。可选“l1_optimize”、“l2_optimize”或“off_optimize”。“l2_optimize”设置为默认值。 + +- 返回值 + + 缓冲区优化模式。 + +## setBufferOptimizeMode + +```java +public void setBufferOptimizeMode(String bufferOptimizeMode) +``` + +设置缓冲区优化模式。 + +- 参数 +- `bufferOptimizeMode`: 要设置的缓冲区优化模式。 \ No newline at end of file diff --git a/docs/lite/api/source_zh_cn/api_java/class_list.md b/docs/lite/api/source_zh_cn/api_java/class_list.md index e9ae7e8699eab275a87d39ac8caa86d8ec09e666..6137934998551407823cb15d7fff2f07254e6fd3 100644 --- a/docs/lite/api/source_zh_cn/api_java/class_list.md +++ b/docs/lite/api/source_zh_cn/api_java/class_list.md @@ -10,11 +10,11 @@ | com.mindspore | [ModelParallelRunner](https://www.mindspore.cn/lite/api/zh-CN/master/api_java/model_parallel_runner.html) | 定义了MindSpore Lite并发推理。 | √ | ✕ | | com.mindspore.config | [RunnerConfig](https://www.mindspore.cn/lite/api/zh-CN/master/api_java/runner_config.html) | RunnerConfig 定义并发推理的配置参数。 | √ | ✕ | | com.mindspore | [Graph](https://www.mindspore.cn/lite/api/zh-CN/master/api_java/graph.html) | Model定义了MindSpore中的计算图。 | ✕ | √ | -| com.mindspore.config | [CpuBindMode](https://gitee.com/mindspore/mindspore-lite/blob/master/mindspore-lite/java/src/main/java/com/mindspore/config/CpuBindMode.java) | CpuBindMode定义了CPU绑定模式。 | √ | √ | -| com.mindspore.config | [DeviceType](https://gitee.com/mindspore/mindspore-lite/blob/master/mindspore-lite/java/src/main/java/com/mindspore/config/DeviceType.java) | DeviceType定义了后端设备类型。 | √ | √ | -| com.mindspore.config | [DataType](https://gitee.com/mindspore/mindspore-lite/blob/master/mindspore-lite/java/src/main/java/com/mindspore/config/DataType.java) | DataType定义了所支持的数据类型。 | √ | √ | -| com.mindspore.config | [Version](https://gitee.com/mindspore/mindspore-lite/blob/master/mindspore-lite/java/src/main/java/com/mindspore/config/Version.java) | Version用于获取MindSpore的版本信息。 | √ | √ | -| com.mindspore.config | [ModelType](https://gitee.com/mindspore/mindspore-lite/blob/master/mindspore-lite/java/src/main/java/com/mindspore/config/ModelType.java) | ModelType 定义了模型文件的类型。 | √ | √ | -| com.mindspore.config | [AscendDeviceInfo](https://gitee.com/mindspore/mindspore-lite/blob/master/mindspore-lite/java/src/main/java/com/mindspore/config/AscendDeviceInfo.java) | MindSpore Lite用于昇腾硬件推理的配置参数。 | √ | ✕ | -| com.mindspore.config | [TrainCfg](https://gitee.com/mindspore/mindspore-lite/blob/master/mindspore-lite/java/src/main/java/com/mindspore/config/TrainCfg.java) | 用于端上模型训练的配置参数。 | ✕ | √ | +| com.mindspore.config | [CpuBindMode](https://www.mindspore.cn/lite/api/zh-CN/master/api_java/mscontext.html#cpubindmode) | CpuBindMode定义了CPU绑定模式。 | √ | √ | +| com.mindspore.config | [DeviceType](https://www.mindspore.cn/lite/api/zh-CN/master/api_java/mscontext.html#devicetype) | DeviceType定义了后端设备类型。 | √ | √ | +| com.mindspore.config | [DataType](https://www.mindspore.cn/lite/api/zh-CN/master/api_java/mstensor.html#datatype) | DataType定义了所支持的数据类型。 | √ | √ | +| com.mindspore.config | [Version](https://www.mindspore.cn/lite/api/zh-CN/master/api_java/version.html) | Version用于获取MindSpore的版本信息。 | √ | √ | +| com.mindspore.config | [ModelType](https://www.mindspore.cn/lite/api/zh-CN/master/api_java/model.html#modeltype) | ModelType 定义了模型文件的类型。 | √ | √ | +| com.mindspore.config | [AscendDeviceInfo](https://www.mindspore.cn/lite/api/zh-CN/master/api_java/ascend_device_info.html) | MindSpore Lite用于昇腾硬件推理的配置参数。 | √ | ✕ | +| com.mindspore.config | [TrainCfg](https://www.mindspore.cn/lite/api/zh-CN/master/api_java/train_cfg.html) | 用于端上模型训练的配置参数。 | ✕ | √ | diff --git a/docs/lite/api/source_zh_cn/api_java/train_cfg.md b/docs/lite/api/source_zh_cn/api_java/train_cfg.md new file mode 100644 index 0000000000000000000000000000000000000000..29b113c6202308e96d4fe7ebc3898f285bcf8bbb --- /dev/null +++ b/docs/lite/api/source_zh_cn/api_java/train_cfg.md @@ -0,0 +1,84 @@ +# TrainCfg + +[![查看源文件](https://mindspore-website.obs.cn-north-4.myhuaweicloud.com/website-images/master/resource/_static/logo_source.svg)](https://gitee.com/mindspore/docs/blob/master/docs/lite/api/source_zh_cn/api_java/traincfg.md) + +```java +import com.mindspore.config.TrainCfg; +``` + +用于端上模型训练的配置参数。 + +## 公有成员函数 + +| function | 云侧推理是否支持 | 端侧推理是否支持 | +| ------------------------------------------ |--------|--------| +| [boolean init()](#init) | ✕ | √ | +| [boolean init(String loss_name)](#init) | ✕ | √ | +| [void free()](#free) | ✕ | √ | +| [boolean addMixPrecisionCfg(boolean dynamicLossScale, float lossScale, int thresholdIterNum)](#addMixPrecisionCfg) | ✕ | √ | +| [long getTrainCfgPtr()](#getTrainCfgPtr) | ✕ | √ | + +## init + +```java +public boolean init() +``` + +初始化训练配置。 + +- 返回值 + + 初始化状态。 + +```java +public boolean init(String loss_name) +``` + +初始化训练配置指定损失函数名称。 + +- 参数 + +- `loss_name`:用于分割推理和训练部分的损失函数名称。 + +- 返回值 + + 初始化状态。 + +## free + +```java +public void free() +``` + +释放训练配置。 + +## addMixPrecisionCfg + +```java +public boolean addMixPrecisionCfg(boolean dynamicLossScale, float lossScale, int thresholdIterNum) +``` + +将混合精度配置添加到训练配置中。 + +- 参数 +- `dynamicLossScale`: 是动态还是静态损失比例因子。 + +- `lossScale`:损失比例因子 。 + +- `thresholdIterNum`: 启用dynamicLossScale时修改损失比例因子的阈值。 + +- 返回值 + + 添加状态。 + +## getTrainCfgPtr + +```java +public long getTrainCfgPtr() +``` + +获取训练配置指针。 + +- 返回值 + + 训练配置指针。 diff --git a/docs/lite/api/source_zh_cn/api_java/version.md b/docs/lite/api/source_zh_cn/api_java/version.md new file mode 100644 index 0000000000000000000000000000000000000000..150a616b4ed6eed4a55cb04b1a8e77cc71919a8b --- /dev/null +++ b/docs/lite/api/source_zh_cn/api_java/version.md @@ -0,0 +1,36 @@ +# Version + +[![查看源文件](https://mindspore-website.obs.cn-north-4.myhuaweicloud.com/website-images/master/resource/_static/logo_source.svg)](https://gitee.com/mindspore/docs/blob/master/docs/lite/api/source_zh_cn/api_java/version.md) + +```java +import com.mindspore.config.Version; +``` + +获取MindSpore Lite 版本信息。 + +## 公有成员函数 + +| function | 云侧推理是否支持 | 端侧推理是否支持 | +| ------------------------------------------ |--------|--------| +| [static void init()](#init) | √ | √ | +| [static native String version()](#version) | √ | √ | + +## init + +```java +public static void init() +``` + +初始化函数。 + +## version + +```java +public static native String version() +``` + +获取MindSpore Lite 版本信息。 + +- 返回值 + + MindSpore Lite的版本信息。 diff --git a/docs/lite/api/source_zh_cn/index.rst b/docs/lite/api/source_zh_cn/index.rst index 2f8ac789cf42e5661eecbde2ec89f9c97c87e783..c7e8c326ff732a4c017f39948e60086a4b9187bd 100644 --- a/docs/lite/api/source_zh_cn/index.rst +++ b/docs/lite/api/source_zh_cn/index.rst @@ -370,6 +370,9 @@ MindSpore Lite API 支持情况汇总 api_java/graph api_java/runner_config api_java/model_parallel_runner + api_java/ascend_device_info + api_java/train_cfg + api_java/version api_java/lite_java_example .. toctree::