!28010 Log deprecated warning message to offline profiling function

Merge pull request !28010 from ougongchang/add_warning
This commit is contained in:
i-robot 2021-12-22 06:17:08 +00:00 committed by Gitee
commit 5cd53b2eed
3 changed files with 28 additions and 15 deletions

View File

@ -369,14 +369,14 @@ void ProfilingUtils::InsertProfilingTraceIterEnd(const AnfNodePtr &anf_node,
void ProfilingUtils::SetGraphKernelName(uint32_t graph_id, const std::vector<std::string> &kernel_names) {
auto ret = graph_kernel_name_.try_emplace(graph_id, kernel_names);
if (!ret.second) {
MS_LOG(ERROR) << "[profiling]graph " << graph_id << " kernel names already exist";
MS_LOG(WARNING) << "[profiling] graph " << graph_id << " kernel names already exist";
}
}
void ProfilingUtils::SetGraphProfilingCNode(uint32_t graph_id, const std::vector<CNodePtr> &profiling_cnode_list) {
auto ret = graph_profiling_cnode_.try_emplace(graph_id, profiling_cnode_list);
if (!ret.second) {
MS_LOG(ERROR) << "[profiling]graph " << graph_id << " profiling cnode list already exist";
MS_LOG(WARNING) << "[profiling] graph " << graph_id << " profiling cnode list already exist";
}
}
@ -400,8 +400,8 @@ void ProfilingUtils::ReportProfilingData(const std::vector<uint32_t> &task_ids,
uint32_t graph_id) {
auto ret = graph_profiling_cnode_.find(graph_id);
if (ret == graph_profiling_cnode_.end()) {
MS_LOG(ERROR) << "Graph id not found in graph_profiling_cnode_, graph id is " << graph_id
<< ", will not report this graph profiling data.";
MS_LOG(WARNING) << "Graph id not found in graph_profiling_cnode_, graph id is " << graph_id
<< ", will not report this graph profiling data.";
return;
}
@ -415,8 +415,8 @@ void ProfilingUtils::ReportProfilingData(const std::vector<uint32_t> &task_ids,
// Report profiling point
auto point_iter = graph_point_.find(graph_id);
if (point_iter == graph_point_.end()) {
MS_LOG(ERROR) << "Graph id not found in graph_point, will not report this graph step point data, graph id is: "
<< graph_id;
MS_LOG(WARNING) << "Graph id not found in graph_point, will not report this graph step point data, graph id is: "
<< graph_id;
return;
}
reporter.ReportStepPoint(point_iter->second);

View File

@ -51,7 +51,7 @@ class FrameworkParser:
Thr parser for parsing framework files.
Args:
profiling_path (str): The profiling path which should be contain CANN profiling data.
profiling_path (str): The profiling path which should contain CANN profiling data.
rank_id (str): The rank ID.
output_path (str): The directory of the parsed file. Default: `./`.
"""
@ -190,6 +190,9 @@ class FrameworkParser:
for data_type in FileDataType.members():
if data_type not in framework_path_dict:
logger.warning("Can not find %s file when parse profiler framework file.", data_type)
if data_type.startswith('vm'):
raise RuntimeError("The current profiler file is generated by MindSpore 1.5 or earlier. Use "
"MindSpore 1.5 or the matching MindSpore version to parse the profiler file.")
continue
framework_path_dict[data_type].sort()

View File

@ -49,6 +49,11 @@ from mindspore.nn.cell import Cell
INIT_OP_NAME = 'Default/InitDataSetQueue'
def deprecated(name, version):
msg = f"The {name} is deprecated from MindSpore {version} and will be removed in a future version."
logger.warning(msg)
def _environment_check():
if c_expression.security.enable_security():
raise RuntimeError("Profiler is not supported if compiled with \'-s on\'")
@ -58,9 +63,7 @@ def _environment_check():
class ProfileOption(Enum):
"""
Profile Option Enum which be used in Profiler.profile.
"""
"""This Class is deprecated. Profile Option Enum which be used in Profiler.profile."""
trainable_parameters = 0
@ -74,16 +77,20 @@ class Profiler:
Args:
output_path (str): Output data path.
optypes_not_deal (str): (Ascend only) Op type names, determine the data of which optype should be collected
and analysed, will deal with all op if null. Different op types should be separated by comma.
ascend_job_id (str): (Ascend only) The directory where the profiling files to be parsed are located.
This parameter is used to support offline parsing.
optypes_not_deal (str): This parameter is deprecated. (Ascend only) Op type names, determine the data of
which optype should be collected and analysed, will deal with all op if null.
Different op types should be separated by comma.
ascend_job_id (str): This parameter is deprecated. (Ascend only) The directory where the profiling files
to be parsed are located. This parameter is used to support offline parsing.
profile_communication (bool): Whether to collect communication performance data in a multi devices training,
collect when True. Default is False. Setting this parameter has no effect during single device training.
profile_memory (bool): Whether to collect tensor memory data, collect when True. Default is False.
start_profile (bool): The start_profile parameter controls whether to enable or disable performance data
collection based on conditions. The default value is True.
Raises:
RuntimeError: If ascend_job_id is transferred with data that does not match the current MindSpore version.
Examples:
>>> import numpy as np
>>> from mindspore import nn, context
@ -229,6 +236,8 @@ class Profiler:
def _parse_parameter_for_ascend(self, **kwargs):
"""Parse parameter in Proflier when the device target is Ascend."""
if 'optypes_not_deal' in kwargs:
deprecated('optypes_not_deal', '1.6')
optypes_not_deal = kwargs.pop("optypes_not_deal", "Variable")
if not isinstance(optypes_not_deal, str):
raise TypeError("The parameter optypes_not_deal must be str.")
@ -236,6 +245,7 @@ class Profiler:
self._ascend_job_id = kwargs.pop("ascend_job_id", "")
if self._ascend_job_id:
deprecated('ascend_job_id', '1.6')
self._ascend_job_id = validate_and_normalize_path(self._ascend_job_id)
if not os.path.exists(self._ascend_job_id):
msg = f"Invalid ascend_job_id: {self._ascend_job_id}, Please pass the absolute path of the JOB dir"
@ -940,7 +950,7 @@ class Profiler:
Returns:
dict, the key is the option name, the value is the result of option.
"""
result = dict()
deprecated('profile', '1.6')
if not profile_option:
raise ValueError("The parameter profile_option must pass a value using ProfileOption.")