diff --git a/docs/api/api_python/mindspore.dataset.config.rst b/docs/api/api_python/mindspore.dataset.config.rst index 593bd1c7b21..11cf80a2db0 100644 --- a/docs/api/api_python/mindspore.dataset.config.rst +++ b/docs/api/api_python/mindspore.dataset.config.rst @@ -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日志查看调优配置。 **异常:** diff --git a/mindspore/python/mindspore/dataset/core/config.py b/mindspore/python/mindspore/dataset/core/config.py index 37502ff6342..fc648ace7a1 100644 --- a/mindspore/python/mindspore/dataset/core/config.py +++ b/mindspore/python/mindspore/dataset/core/config.py @@ -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()