!32744 change set_enable_autotune param_name

Merge pull request !32744 from luoyang/param_name
This commit is contained in:
i-robot 2022-04-09 02:43:31 +00:00 committed by Gitee
commit 77c421b9f1
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 22 additions and 13 deletions

View File

@ -223,7 +223,7 @@ API示例所需模块的导入代码如下
bool表示是否启用共享内存。
.. py:function:: mindspore.dataset.config.set_enable_autotune(enable, json_filepath=None)
.. py:function:: mindspore.dataset.config.set_enable_autotune(enable, filepath_prefix=None)
设置是否开启自动数据加速。默认情况下不开启自动数据加速。
@ -234,7 +234,9 @@ API示例所需模块的导入代码如下
**参数:**
- **enable** (bool) - 是否开启自动数据加速。
- **json_filepath** (str可选) - 优化后的全局配置的保存路径当路径存在同名文件时会自动覆盖。默认值None表示不保存配置文件但可以通过INFO日志查看调优配置。
- **filepath_prefix** (str可选) - 优化后的全局配置的保存路径+文件前缀。多卡环境时设备ID号与JSON扩展名会自动添加到 `filepath_prefix`
参数后面作为完整的文件路径单卡默认设备ID号为0。例如设置 `filepath_prefix="/path/to/some/dir/prefixname"` 设备ID为1的训练进程
生成的调优文件将被命名为 `/path/to/some/dir/prefixname_1.json` 。默认值None表示不保存配置文件但可以通过INFO日志查看调优配置。
**异常:**

View File

@ -26,6 +26,12 @@ if(ENABLE_PYTHON)
python/pybind_register.cc
)
target_include_directories(APItoPython PRIVATE ${pybind11_INCLUDE_DIRS})
if(ENABLE_CACHE)
add_dependencies(APItoPython engine-cache-server)
else()
add_dependencies(APItoPython engine-cache-client)
endif()
endif()
add_library(cpp-API OBJECT

View File

@ -437,7 +437,7 @@ def load(file):
_config.load(file)
def set_enable_autotune(enable, json_filepath_prefix=None):
def set_enable_autotune(enable, filepath_prefix=None):
"""
Set whether to enable AutoTune. AutoTune is disabled by default.
@ -450,9 +450,10 @@ def set_enable_autotune(enable, json_filepath_prefix=None):
Args:
enable (bool): Whether to enable AutoTune.
json_filepath_prefix (str, optional): The prefix filepath to save the optimized global configuration.
The rank id and the json extension will be appended to the json_filepath_prefix string.
For example, if json_filepath_prefix="/path/to/some/dir/prefixname" and rank_id is 1, then the path
filepath_prefix (str, optional): The prefix filepath to save the optimized global configuration.
The rank id and the json extension will be appended to the filepath_prefix string in multi-device training,
rank id will be set to 0 in standalone training.
For example, if filepath_prefix="/path/to/some/dir/prefixname" and rank_id is 1, then the path
of the generated file will be "/path/to/some/dir/prefixname_1.json"
If the file already exists, it will be automatically overwritten. Default: None,
means not to save the configuration file, but the tuned result still can be checked through INFO log.
@ -498,21 +499,21 @@ def set_enable_autotune(enable, json_filepath_prefix=None):
if not isinstance(enable, bool):
raise TypeError("enable must be of type bool.")
save_autoconfig = bool(enable and json_filepath_prefix is not None)
save_autoconfig = bool(enable and filepath_prefix is not None)
if json_filepath_prefix and not isinstance(json_filepath_prefix, str):
raise TypeError("json_filepath must be a str value but was: {}.".format(json_filepath_prefix))
if filepath_prefix and not isinstance(filepath_prefix, str):
raise TypeError("json_filepath must be a str value but was: {}.".format(filepath_prefix))
if enable and json_filepath_prefix == "":
if enable and filepath_prefix == "":
raise RuntimeError("The value of json_filepath cannot be the empty string.")
if not enable and json_filepath_prefix is not None:
if not enable and filepath_prefix is not None:
logger.warning("The value of json_filepath is ignored when enable is False.")
if enable and json_filepath_prefix is None:
if enable and filepath_prefix is None:
logger.warning("Dataset AutoTune is enabled but no json path is specified, check INFO log for tuned result.")
json_filepath = replace_none(json_filepath_prefix, "")
json_filepath = replace_none(filepath_prefix, "")
rank_id = _get_rank_id()