| @@ -41,6 +41,7 @@ if (ENABLE_OPEN_SRC) | |||||
| message(FATAL_ERROR "Running on a unsupported architecture: ${SYSTEM_TYPE}, build terminated") | message(FATAL_ERROR "Running on a unsupported architecture: ${SYSTEM_TYPE}, build terminated") | ||||
| endif() | endif() | ||||
| set(GE_LIB_PATH ${GE_LIB_PATH}/${GE_SYS_ARCH}) | set(GE_LIB_PATH ${GE_LIB_PATH}/${GE_SYS_ARCH}) | ||||
| set(STATIC_ACL_LIB ${GE_LIB_PATH}) | |||||
| find_module(slog libslog.so ${GE_LIB_PATH}) | find_module(slog libslog.so ${GE_LIB_PATH}) | ||||
| find_module(mmpa libmmpa.so ${GE_LIB_PATH}) | find_module(mmpa libmmpa.so ${GE_LIB_PATH}) | ||||
| find_module(msprof libmsprof.so ${GE_LIB_PATH}) | find_module(msprof libmsprof.so ${GE_LIB_PATH}) | ||||
| @@ -53,7 +54,6 @@ if (ENABLE_OPEN_SRC) | |||||
| find_module(ascend_hal_stub libascend_hal.so ${GE_LIB_PATH}) | find_module(ascend_hal_stub libascend_hal.so ${GE_LIB_PATH}) | ||||
| find_module(error_manager_static liberror_manager.a ${GE_LIB_PATH}) | find_module(error_manager_static liberror_manager.a ${GE_LIB_PATH}) | ||||
| find_module(msprofiler libmsprofiler.a ${GE_LIB_PATH}) | find_module(msprofiler libmsprofiler.a ${GE_LIB_PATH}) | ||||
| find_module(ascendcl_static libascendcl.a ${GE_LIB_PATH}) | |||||
| else() | else() | ||||
| if(DEFINED ENV{ASCEND_CUSTOM_PATH}) | if(DEFINED ENV{ASCEND_CUSTOM_PATH}) | ||||
| set(ASCEND_DIR $ENV{ASCEND_CUSTOM_PATH}) | set(ASCEND_DIR $ENV{ASCEND_CUSTOM_PATH}) | ||||
| @@ -66,6 +66,7 @@ if (ENABLE_OPEN_SRC) | |||||
| set(ASCEND_RUNTIME_DIR ${ASCEND_DIR}/fwkacllib/lib64) | set(ASCEND_RUNTIME_DIR ${ASCEND_DIR}/fwkacllib/lib64) | ||||
| set(ASCEND_ATC_DIR ${ASCEND_DIR}/atc/lib64) | set(ASCEND_ATC_DIR ${ASCEND_DIR}/atc/lib64) | ||||
| set(ASCEND_ACL_DIR ${ASCEND_DIR}/acllib/lib64) | set(ASCEND_ACL_DIR ${ASCEND_DIR}/acllib/lib64) | ||||
| set(STATIC_ACL_LIB ${ASCEND_ACL_DIR}) | |||||
| find_module(slog libslog.so ${ASCEND_ATC_DIR}) | find_module(slog libslog.so ${ASCEND_ATC_DIR}) | ||||
| find_module(mmpa libmmpa.so ${ASCEND_ATC_DIR}) | find_module(mmpa libmmpa.so ${ASCEND_ATC_DIR}) | ||||
| if(PLATFORM STREQUAL "train") | if(PLATFORM STREQUAL "train") | ||||
| @@ -88,7 +89,6 @@ if (ENABLE_OPEN_SRC) | |||||
| find_module(error_manager liberror_manager.so ${ASCEND_ATC_DIR}) | find_module(error_manager liberror_manager.so ${ASCEND_ATC_DIR}) | ||||
| find_module(error_manager_static liberror_manager.a ${ASCEND_ACL_DIR}) | find_module(error_manager_static liberror_manager.a ${ASCEND_ACL_DIR}) | ||||
| find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR}) | find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR}) | ||||
| find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR}) | |||||
| if(PRODUCT STREQUAL "flr3") | if(PRODUCT STREQUAL "flr3") | ||||
| find_module(msprof libmsprof.so ${ASCEND_DRIVER_SHARE_DIR}) | find_module(msprof libmsprof.so ${ASCEND_DRIVER_SHARE_DIR}) | ||||
| elseif(PRODUCT STREQUAL "flr1") | elseif(PRODUCT STREQUAL "flr1") | ||||
| @@ -111,7 +111,6 @@ if (ENABLE_OPEN_SRC) | |||||
| find_module(error_manager_static liberror_manager.a ${ASCEND_ACL_DIR}) | find_module(error_manager_static liberror_manager.a ${ASCEND_ACL_DIR}) | ||||
| find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR}) | find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR}) | ||||
| find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}/driver) | find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}/driver) | ||||
| find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR}) | |||||
| else() | else() | ||||
| message(FATAL_ERROR "PLATFORM param is invalid, should be train or inference, build terminated") | message(FATAL_ERROR "PLATFORM param is invalid, should be train or inference, build terminated") | ||||
| endif() | endif() | ||||
| @@ -1,6 +0,0 @@ | |||||
| inc_path := $(shell pwd)/metadef/inc/external/ | |||||
| out_path := $(shell pwd)/out/graph/lib64/stub/ | |||||
| stub_path := $(shell pwd)/metadef/graph/stub/ | |||||
| mkdir_stub := $(shell mkdir -p $(out_path)) | |||||
| graph_local_stub := $(shell $(HI_PYTHON) $(stub_path)/gen_stubapi.py $(inc_path) $(out_path)) | |||||
| @@ -1,578 +0,0 @@ | |||||
| import os | |||||
| import re | |||||
| import sys | |||||
| import logging | |||||
| logging.basicConfig(stream=sys.stdout, format='[%(asctime)s] [%(lineno)s] %(levelname)s: %(message)s', | |||||
| level=logging.INFO) | |||||
| """ | |||||
| this attr is used for symbol table visible | |||||
| """ | |||||
| GE_ATTR = 'GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY' | |||||
| """ | |||||
| generate stub func body by return type | |||||
| """ | |||||
| RETURN_STATEMENTS = { | |||||
| 'graphStatus': ' std::cout << "[ERROR]: stub library libgraph or libge_compiler cannot be used for execution, please check your "\n ' | |||||
| ' << "environment variables and compilation options to make sure you use the correct library."\n' | |||||
| ' << std::endl;\n' | |||||
| ' return ACL_ERROR_COMPILING_STUB_MODE;', | |||||
| 'Status': ' return SUCCESS;', | |||||
| 'Graph': ' return Graph();', | |||||
| 'Graph&': ' return *this;', | |||||
| 'Format': ' return Format();', | |||||
| 'Format&': ' return *this;', | |||||
| 'Shape': ' return Shape();', | |||||
| 'Shape&': ' return *this;', | |||||
| 'TensorDesc': ' return TensorDesc();', | |||||
| 'TensorDesc&': ' return *this;', | |||||
| 'Tensor': ' return Tensor();', | |||||
| 'Tensor&': ' return *this;', | |||||
| 'Operator': ' return Operator();', | |||||
| 'Operator&': ' return *this;', | |||||
| 'Ptr': ' return nullptr;', | |||||
| 'std::string': ' return "";', | |||||
| 'std::string&': ' return "";', | |||||
| 'string': ' return "";', | |||||
| 'int': ' return 0;', | |||||
| 'DataType': ' return DT_FLOAT;', | |||||
| 'InferenceContextPtr': ' return nullptr;', | |||||
| 'SubgraphBuilder': ' return nullptr;', | |||||
| 'OperatorImplPtr': ' return nullptr;', | |||||
| 'OutHandler': ' return nullptr;', | |||||
| 'std::vector<std::string>': ' return {};', | |||||
| 'std::vector<int64_t>': ' return {};', | |||||
| 'std::map': ' return {};', | |||||
| 'uint32_t': ' return 0;', | |||||
| 'int64_t': ' return 0;', | |||||
| 'uint64_t': ' return 0;', | |||||
| 'size_t': ' return 0;', | |||||
| 'float': ' return 0.0f;', | |||||
| 'bool': ' return false;', | |||||
| } | |||||
| """ | |||||
| max code len per line in hua_wei software programming specifications | |||||
| """ | |||||
| max_code_len_per_line = 100 | |||||
| """ | |||||
| white_list_for_debug, include_dir_key_words is to | |||||
| determines which header files to generate cc files from | |||||
| when DEBUG on | |||||
| """ | |||||
| white_list_for_debug = ["attr_value.h", "operator.h", "tensor.h", "graph.h", "operator_factory.h", "inference_context.h", | |||||
| "ge_ir_build.h", "ge_api.h", "ascend_string.h", "gnode.h"] | |||||
| include_dir_key_words = ["ge", "graph"] | |||||
| DEBUG = True | |||||
| def need_generate_func(func_line): | |||||
| """ | |||||
| :param func_line: | |||||
| :return: | |||||
| """ | |||||
| if func_line.strip().endswith("default") or func_line.strip().endswith("delete") \ | |||||
| or func_line.strip().startswith("typedef") or func_line.strip().startswith("using"): | |||||
| return False | |||||
| return True | |||||
| def file_endswith_white_list_suffix(file): | |||||
| """ | |||||
| :param file: | |||||
| :return: | |||||
| """ | |||||
| if DEBUG: | |||||
| for suffix in white_list_for_debug: | |||||
| if file.endswith(suffix): | |||||
| return True | |||||
| return False | |||||
| else: | |||||
| return True | |||||
| """ | |||||
| belows are patterns used for analyse .h file | |||||
| """ | |||||
| # pattern function | |||||
| pattern_func = re.compile(r"""(^[\s]*) #leading with space,we will find and delete after | |||||
| ([a-zA-Z~_] # void int likely | |||||
| .* | |||||
| [)] #we find ) | |||||
| (?!.*{) # we do not want the case int abc() const | |||||
| .*) | |||||
| (;.*) #we want to find ; and after for we will replace these later | |||||
| \n$ | |||||
| """, re.VERBOSE | re.MULTILINE | re.DOTALL) | |||||
| # pattern comment | |||||
| pattern_comment = re.compile(r'^\s*//') | |||||
| pattern_comment_2_start = re.compile(r'^\s*/[*]') | |||||
| pattern_comment_2_end = re.compile(r'[*]/\s*$') | |||||
| # pattern define | |||||
| pattern_define = re.compile(r'^\s*#define') | |||||
| pattern_define_return = re.compile(r'\\\s*$') | |||||
| # blank line | |||||
| pattern_blank_line = re.compile(r'^\s*$') | |||||
| # virtual,explicit,friend,static | |||||
| pattern_keyword = re.compile(r'(virtual\s+|explicit\s+|friend\s+|static\s+)') | |||||
| # lead space | |||||
| pattern_leading_space = re.compile(r'(^[\s]*)[a-zA-Z~_]') | |||||
| # functions will have patterns such as func ( or func( | |||||
| # but operator is an exception; the class name is preceded by an operator, and the above mode does not exist | |||||
| # format like :"operator = ()" | |||||
| pattern_func_name = re.compile(r'([a-zA-Z0-9~_\-]+\s*|operator?.*)[(]') | |||||
| # template | |||||
| pattern_template = re.compile(r'^\s*template') | |||||
| pattern_template_end = re.compile(r'>\s*$') | |||||
| # namespace | |||||
| pattern_namespace = re.compile(r'namespace.*{') | |||||
| # class : which can handle classA a and {not on the same line, but if found ';' after class,then don't deal with | |||||
| pattern_class = re.compile(r'^[\s]*(class|struct)\s+(%s\s+)?([a-zA-Z0-9_\-]+<?)(?!.*;)' % GE_ATTR) | |||||
| # {} | |||||
| pattern_start = re.compile('{') | |||||
| pattern_end = re.compile('}') | |||||
| line_index = 0 | |||||
| class H2CC(object): | |||||
| def __init__(self, input_file, output_file, shared_includes_content): | |||||
| """ | |||||
| :param input_file: | |||||
| :param output_file: | |||||
| :param shared_includes_content: | |||||
| """ | |||||
| self.input_file = input_file | |||||
| self.output_file = output_file | |||||
| self.shared_includes_content = shared_includes_content | |||||
| self.line_index = 0 | |||||
| self.input_fd = open(self.input_file, 'r') | |||||
| self.input_content = self.input_fd.readlines() | |||||
| self.output_fd = open(self.output_file, 'w') | |||||
| # The state may be normal_now(in the middle of {}),class_now,namespace_now | |||||
| self.stack = [] | |||||
| self.stack_class = [] | |||||
| self.stack_template = [] | |||||
| # record funcs generated by h2cc func | |||||
| self.func_list_exist = [] | |||||
| def __del__(self): | |||||
| self.input_fd.close() | |||||
| self.output_fd.close() | |||||
| del self.stack | |||||
| del self.stack_class | |||||
| del self.stack_template | |||||
| del self.func_list_exist | |||||
| def just_skip(self): | |||||
| # skip blank line or comment | |||||
| if pattern_blank_line.search(self.input_content[self.line_index]) or pattern_comment.search( | |||||
| self.input_content[self.line_index]): # /n or comment using // | |||||
| self.line_index += 1 | |||||
| if pattern_comment_2_start.search(self.input_content[self.line_index]): # comment using /* | |||||
| while not pattern_comment_2_end.search(self.input_content[self.line_index]): # */ | |||||
| self.line_index += 1 | |||||
| self.line_index += 1 | |||||
| # skip define | |||||
| if pattern_define.search(self.input_content[self.line_index]): | |||||
| while pattern_blank_line.search(self.input_content[self.line_index]) or pattern_define_return.search( | |||||
| self.input_content[self.line_index]): | |||||
| self.line_index += 1 | |||||
| self.line_index += 1 | |||||
| def write_inc_content(self): | |||||
| for shared_include_content in self.shared_includes_content: | |||||
| self.output_fd.write(shared_include_content) | |||||
| def h2cc(self): | |||||
| """ | |||||
| :return: | |||||
| """ | |||||
| logging.info("start generate cc_file[%s] from h_file[%s]", self.output_file, self.input_file) | |||||
| global pattern_comment | |||||
| global pattern_comment_2_start | |||||
| global pattern_comment_2_end | |||||
| global pattern_blank_line | |||||
| global pattern_func | |||||
| global pattern_keyword | |||||
| global pattern_leading_space | |||||
| global pattern_func_name | |||||
| global pattern_template | |||||
| global pattern_template_end | |||||
| global pattern_namespace | |||||
| global pattern_class | |||||
| global pattern_start | |||||
| global pattern_end | |||||
| global line_index | |||||
| # write inc content | |||||
| self.write_inc_content() | |||||
| # core processing cycle, process the input .h file by line | |||||
| while self.line_index < len(self.input_content): | |||||
| # handle comment and blank line | |||||
| self.just_skip() | |||||
| # match namespace | |||||
| self.handle_namespace() | |||||
| # match template | |||||
| template_string = self.handle_template() | |||||
| # match class | |||||
| line = self.input_content[self.line_index] | |||||
| match_class = pattern_class.search(line) | |||||
| match_start = pattern_start.search(line) | |||||
| handle_class_result = self.handle_class(template_string, line, match_start, match_class) | |||||
| if handle_class_result == "continue": | |||||
| continue | |||||
| # match "}" | |||||
| handle_stack_result = self.handle_stack(match_start) | |||||
| if handle_stack_result == "continue": | |||||
| continue | |||||
| # handle func | |||||
| handle_func1_result, line, start_i = self.handle_func1(line) | |||||
| if handle_func1_result == "continue": | |||||
| continue | |||||
| # here means func is found | |||||
| # delete key word | |||||
| line = pattern_keyword.sub('', line) | |||||
| logging.info("line[%s]", line) | |||||
| # Class member function | |||||
| # if friend we will not add class name | |||||
| friend_match = re.search('friend ', line) | |||||
| if len(self.stack_class) > 0 and not friend_match: | |||||
| line, func_name = self.handle_class_member_func(line, template_string) | |||||
| # Normal functions | |||||
| else: | |||||
| line, func_name = self.handle_normal_func(line, template_string) | |||||
| need_generate = need_generate_func(line) | |||||
| # func body | |||||
| line += self.implement_function(line) | |||||
| # comment | |||||
| line = self.gen_comment(start_i) + line | |||||
| # write to out file | |||||
| self.write_func_content(line, func_name, need_generate) | |||||
| # next loop | |||||
| self.line_index += 1 | |||||
| logging.info('Added %s functions', len(self.func_list_exist)) | |||||
| logging.info('Successfully converted,please see ' + self.output_file) | |||||
| def handle_func1(self, line): | |||||
| """ | |||||
| :param line: | |||||
| :return: | |||||
| """ | |||||
| find1 = re.search('[(]', line) | |||||
| if not find1: | |||||
| self.line_index += 1 | |||||
| return "continue", line, None | |||||
| find2 = re.search('[)]', line) | |||||
| start_i = self.line_index | |||||
| space_match = pattern_leading_space.search(line) | |||||
| # deal with | |||||
| # int abc(int a, | |||||
| # int b) | |||||
| if find1 and (not find2): | |||||
| self.line_index += 1 | |||||
| line2 = self.input_content[self.line_index] | |||||
| if space_match: | |||||
| line2 = re.sub('^' + space_match.group(1), '', line2) | |||||
| line += line2 | |||||
| while self.line_index < len(self.input_content) and (not re.search('[)]', line2)): | |||||
| self.line_index += 1 | |||||
| line2 = self.input_content[self.line_index] | |||||
| line2 = re.sub('^' + space_match.group(1), '', line2) | |||||
| line += line2 | |||||
| match_start = pattern_start.search(self.input_content[self.line_index]) | |||||
| match_end = pattern_end.search(self.input_content[self.line_index]) | |||||
| if match_start: # like ) { or ) {} int the last line | |||||
| if not match_end: | |||||
| self.stack.append('normal_now') | |||||
| ii = start_i | |||||
| while ii <= self.line_index: | |||||
| ii += 1 | |||||
| self.line_index += 1 | |||||
| return "continue", line, start_i | |||||
| logging.info("line[%s]", line) | |||||
| # ' int abc();'->'int abc()' | |||||
| (line, match) = pattern_func.subn(r'\2\n', line) | |||||
| logging.info("line[%s]", line) | |||||
| # deal with case: | |||||
| # 'int \n abc(int a, int b)' | |||||
| if re.search(r'^\s*(inline)?\s*[a-zA-Z0-9_]+\s*$', self.input_content[start_i - 1]): | |||||
| line = self.input_content[start_i - 1] + line | |||||
| line = line.lstrip() | |||||
| if not match: | |||||
| self.line_index += 1 | |||||
| return "continue", line, start_i | |||||
| return "pass", line, start_i | |||||
| def handle_stack(self, match_start): | |||||
| """ | |||||
| :param match_start: | |||||
| :return: | |||||
| """ | |||||
| line = self.input_content[self.line_index] | |||||
| match_end = pattern_end.search(line) | |||||
| if match_start: | |||||
| self.stack.append('normal_now') | |||||
| if match_end: | |||||
| top_status = self.stack.pop() | |||||
| if top_status == 'namespace_now': | |||||
| self.output_fd.write(line + '\n') | |||||
| elif top_status == 'class_now': | |||||
| self.stack_class.pop() | |||||
| self.stack_template.pop() | |||||
| if match_start or match_end: | |||||
| self.line_index += 1 | |||||
| return "continue" | |||||
| if len(self.stack) > 0 and self.stack[-1] == 'normal_now': | |||||
| self.line_index += 1 | |||||
| return "continue" | |||||
| return "pass" | |||||
| def handle_class(self, template_string, line, match_start, match_class): | |||||
| """ | |||||
| :param template_string: | |||||
| :param line: | |||||
| :param match_start: | |||||
| :param match_class: | |||||
| :return: | |||||
| """ | |||||
| if match_class: # we face a class | |||||
| self.stack_template.append(template_string) | |||||
| self.stack.append('class_now') | |||||
| class_name = match_class.group(3) | |||||
| # class template specializations: class A<u,Node<u> > | |||||
| if '<' in class_name: | |||||
| k = line.index('<') | |||||
| fit = 1 | |||||
| for ii in range(k + 1, len(line)): | |||||
| if line[ii] == '<': | |||||
| fit += 1 | |||||
| if line[ii] == '>': | |||||
| fit -= 1 | |||||
| if fit == 0: | |||||
| break | |||||
| class_name += line[k + 1:ii + 1] | |||||
| logging.info('class_name[%s]', class_name) | |||||
| self.stack_class.append(class_name) | |||||
| while not match_start: | |||||
| self.line_index += 1 | |||||
| line = self.input_content[self.line_index] | |||||
| match_start = pattern_start.search(line) | |||||
| self.line_index += 1 | |||||
| return "continue" | |||||
| return "pass" | |||||
| def handle_template(self): | |||||
| line = self.input_content[self.line_index] | |||||
| match_template = pattern_template.search(line) | |||||
| template_string = '' | |||||
| if match_template: | |||||
| match_template_end = pattern_template_end.search(line) | |||||
| template_string = line | |||||
| while not match_template_end: | |||||
| self.line_index += 1 | |||||
| line = self.input_content[self.line_index] | |||||
| template_string += line | |||||
| match_template_end = pattern_template_end.search(line) | |||||
| self.line_index += 1 | |||||
| return template_string | |||||
| def handle_namespace(self): | |||||
| line = self.input_content[self.line_index] | |||||
| match_namespace = pattern_namespace.search(line) | |||||
| if match_namespace: # we face namespace | |||||
| self.output_fd.write(line + '\n') | |||||
| self.stack.append('namespace_now') | |||||
| self.line_index += 1 | |||||
| def handle_normal_func(self, line, template_string): | |||||
| template_line = '' | |||||
| self.stack_template.append(template_string) | |||||
| if self.stack_template[-1] != '': | |||||
| template_line = re.sub(r'\s*template', 'template', self.stack_template[-1]) | |||||
| # change '< class T = a, class U = A(3)>' to '<class T, class U>' | |||||
| template_line = re.sub(r'\s*=.*>(\s*)$', r'>\1', template_line) | |||||
| template_line = re.sub(r'\s*=.*,', ',', template_line) | |||||
| template_line = re.sub(r'\s*=.*', '', template_line) | |||||
| line = re.sub(r'\s*=.*,', ',', line) | |||||
| line = re.sub(r'\s*=.*\)', ')', line) | |||||
| line = template_line + line | |||||
| self.stack_template.pop() | |||||
| func_name = re.search(r'^.*\)', line, re.MULTILINE | re.DOTALL).group() | |||||
| logging.info("line[%s]", line) | |||||
| logging.info("func_name[%s]", func_name) | |||||
| return line, func_name | |||||
| def handle_class_member_func(self, line, template_string): | |||||
| template_line = '' | |||||
| x = '' | |||||
| if template_string != '': | |||||
| template_string = re.sub(r'\s*template', 'template', template_string) | |||||
| template_string = re.sub(r'\s*=.*>(\s*)$', r'>\1', template_string) | |||||
| template_string = re.sub(r'\s*=.*,', ',', template_string) | |||||
| template_string = re.sub(r'\s*=.*', '', template_string) | |||||
| if self.stack_template[-1] != '': | |||||
| if not (re.search(r'<\s*>', stack_template[-1])): | |||||
| template_line = re.sub(r'^\s*template', 'template', stack_template[-1]) | |||||
| if not (re.search(r'<.*>', self.stack_class[-1])): | |||||
| # for x we get like template<class T, typename U> -> <T,U> | |||||
| x = re.sub(r'template\s*<', '<', template_line) # remove template -> <class T, typename U> | |||||
| x = re.sub(r'\n', '', x) | |||||
| x = re.sub(r'\s*=.*,', ',', x) | |||||
| x = re.sub(r'\s*=.*\>', '>', x) | |||||
| x = x.rstrip() # remove \n | |||||
| x = re.sub(r'(class|typename)\s+|(<class>|<typename>\s*class)', '', | |||||
| x) # remove class,typename -> <T, U> | |||||
| x = re.sub(r'<\s+', '<', x) | |||||
| x = re.sub(r'\s+>', '>', x) | |||||
| x = re.sub(r'\s+,', ',', x) | |||||
| x = re.sub(r',\s+', ', ', x) | |||||
| line = re.sub(r'\s*=\s+0', '', line) | |||||
| line = re.sub(r'\s*=\s+.*,', ',', line) | |||||
| line = re.sub(r'\s*=\s+.*\)', ')', line) | |||||
| logging.info("x[%s]\nline[%s]", x, line) | |||||
| # if the function is long, void ABC::foo() | |||||
| # breaks into two lines void ABC::\n foo() | |||||
| temp_line = pattern_func_name.sub(self.stack_class[-1] + x + '::' + r'\1(', line, count=1) | |||||
| if len(temp_line) > max_code_len_per_line: | |||||
| line = pattern_func_name.sub(self.stack_class[-1] + x + '::\n' + r'\1(', line, count=1) | |||||
| else: | |||||
| line = temp_line | |||||
| logging.info("line[%s]", line) | |||||
| # add template as the above if there is one | |||||
| template_line = re.sub(r'\s*=.*>(\s*)$', r'>\1', template_line) | |||||
| template_line = re.sub(r'\s*=.*,', ',', template_line) | |||||
| template_line = re.sub(r'\s*=.*', '', template_line) | |||||
| line = template_line + template_string + line | |||||
| func_name = re.search(r'^.*\)', line, re.MULTILINE | re.DOTALL).group() | |||||
| logging.info("line[%s]", line) | |||||
| logging.info("func_name[%s]", func_name) | |||||
| return line, func_name | |||||
| def write_func_content(self, content, func_name, need_generate): | |||||
| if not (func_name in self.func_list_exist) and need_generate: | |||||
| self.output_fd.write(content) | |||||
| self.func_list_exist.append(func_name) | |||||
| logging.info('add func:[%s]', func_name) | |||||
| def gen_comment(self, start_i): | |||||
| comment_line = '' | |||||
| # Function comments are on top of function declarations, copy them over | |||||
| k = start_i - 1 # one line before this func start | |||||
| if pattern_template.search(self.input_content[k]): | |||||
| k -= 1 | |||||
| if pattern_comment_2_end.search(self.input_content[k]): | |||||
| comment_line = self.input_content[k].lstrip() | |||||
| while not pattern_comment_2_start.search(self.input_content[k]): | |||||
| k -= 1 | |||||
| comment_line = self.input_content[k].lstrip() + comment_line | |||||
| else: | |||||
| for j in range(k, 0, -1): | |||||
| c_line = self.input_content[j] | |||||
| if pattern_comment.search(c_line): | |||||
| c_line = re.sub(r'\s*//', '//', c_line) | |||||
| comment_line = c_line + comment_line | |||||
| else: | |||||
| break | |||||
| return comment_line | |||||
| @staticmethod | |||||
| def implement_function(func): | |||||
| function_def = '' | |||||
| function_def += '{\n' | |||||
| all_items = func.split() | |||||
| start = 0 | |||||
| return_type = all_items[start] | |||||
| if return_type == "const": | |||||
| start += 1 | |||||
| return_type = all_items[start] | |||||
| if return_type.startswith(('std::map', 'std::set', 'std::vector')): | |||||
| return_type = "std::map" | |||||
| if return_type.endswith('*') or (len(all_items) > start + 1 and all_items[start + 1].startswith('*')): | |||||
| return_type = "Ptr" | |||||
| if len(all_items) > start + 1 and all_items[start + 1].startswith('&'): | |||||
| return_type += "&" | |||||
| if RETURN_STATEMENTS.__contains__(return_type): | |||||
| function_def += RETURN_STATEMENTS[return_type] | |||||
| else: | |||||
| logging.warning("Unhandled return type[%s]", return_type) | |||||
| function_def += '\n' | |||||
| function_def += '}\n' | |||||
| function_def += '\n' | |||||
| return function_def | |||||
| def collect_header_files(path): | |||||
| """ | |||||
| :param path: | |||||
| :return: | |||||
| """ | |||||
| header_files = [] | |||||
| shared_includes_content = [] | |||||
| for root, dirs, files in os.walk(path): | |||||
| files.sort() | |||||
| for file in files: | |||||
| if file.find("git") >= 0: | |||||
| continue | |||||
| if not file.endswith('.h'): | |||||
| continue | |||||
| file_path = os.path.join(root, file) | |||||
| file_path = file_path.replace('\\', '/') | |||||
| header_files.append(file_path) | |||||
| include_str = '#include "{}"\n'.format(file_path[path.rindex('/') + 1:]) | |||||
| shared_includes_content.append(include_str) | |||||
| # for acl error code | |||||
| shared_includes_content.append('#include <iostream>\n') | |||||
| shared_includes_content.append('const int ACL_ERROR_COMPILING_STUB_MODE = 100039;\n') | |||||
| return header_files, shared_includes_content | |||||
| def generate_stub_file(inc_dir, out_cc_dir): | |||||
| """ | |||||
| :param inc_dir: | |||||
| :param out_cc_dir: | |||||
| :return: | |||||
| """ | |||||
| target_header_files, shared_includes_content = collect_header_files(inc_dir) | |||||
| for header_file in target_header_files: | |||||
| if not file_endswith_white_list_suffix(header_file): | |||||
| continue | |||||
| cc_file = re.sub('.h*$', '.cc', header_file) | |||||
| h_2_cc = H2CC(header_file, out_cc_dir + cc_file[cc_file.rindex('/') + 1:], shared_includes_content) | |||||
| h_2_cc.h2cc() | |||||
| def gen_code(inc_dir, out_cc_dir): | |||||
| """ | |||||
| :param inc_dir: | |||||
| :param out_cc_dir: | |||||
| :return: | |||||
| """ | |||||
| if not inc_dir.endswith('/'): | |||||
| inc_dir += '/' | |||||
| if not out_cc_dir.endswith('/'): | |||||
| out_cc_dir += '/' | |||||
| for include_dir_key_word in include_dir_key_words: | |||||
| generate_stub_file(inc_dir + include_dir_key_word, out_cc_dir) | |||||
| if __name__ == '__main__': | |||||
| inc_dir = sys.argv[1] | |||||
| out_cc_dir = sys.argv[2] | |||||
| gen_code(inc_dir, out_cc_dir) | |||||
| @@ -719,10 +719,24 @@ target_link_libraries(ge_compiler | |||||
| ############ libascendcl.so ############ | ############ libascendcl.so ############ | ||||
| file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/dummy.c CONTENT "") | file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/dummy.c CONTENT "") | ||||
| add_library(dummy_obj OBJECT ${CMAKE_BINARY_DIR}/dummy.c) | |||||
| set(DUMMY_OBJ $<TARGET_OBJECTS:dummy_obj>) | |||||
| #add_library(dummy_obj OBJECT ${CMAKE_BINARY_DIR}/dummy.c) | |||||
| #set(DUMMY_OBJ $<TARGET_OBJECTS:dummy_obj>) | |||||
| add_library(opensrc_ascendcl SHARED ${DUMMY_OBJ}) | |||||
| file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ascendcl_object) | |||||
| if(EXISTS ${STATIC_ACL_LIB}/libascendcl.a) | |||||
| execute_process( | |||||
| COMMAND ar x ${STATIC_ACL_LIB}/libascendcl.a | |||||
| WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ascendcl_object | |||||
| ) | |||||
| file(GLOB OBJECT_LIST ${CMAKE_CURRENT_BINARY_DIR}/ascendcl_object/*.o) | |||||
| else() | |||||
| set(OBJECT_LIST ${CMAKE_BINARY_DIR}/dummy.c) | |||||
| endif() | |||||
| add_library(opensrc_ascendcl SHARED | |||||
| ${OBJECT_LIST} | |||||
| ) | |||||
| target_compile_options(opensrc_ascendcl PRIVATE | target_compile_options(opensrc_ascendcl PRIVATE | ||||
| -O2 | -O2 | ||||
| -fvisibility=hidden | -fvisibility=hidden | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -40,34 +40,32 @@ const std::string kFilePath = "./"; | |||||
| const std::string kAnalyzeFile = "ge_check_op.json"; | const std::string kAnalyzeFile = "ge_check_op.json"; | ||||
| const std::string kUnknownShape = "unknownshape"; | const std::string kUnknownShape = "unknownshape"; | ||||
| const std::string kUnsupport = "unsupport"; | |||||
| const std::string kUnsupport = "unsupport"; | |||||
| const std::string kSessionId = "session_id"; | const std::string kSessionId = "session_id"; | ||||
| const std::string kGraphId = "graph_id"; | |||||
| const std::string kOpInfo = "op_info"; | |||||
| const std::string kGraphId = "graph_id"; | |||||
| const std::string kOpInfo = "op_info"; | |||||
| const std::string kErrorType = "error_type"; | const std::string kErrorType = "error_type"; | ||||
| const std::string kOpName = "name"; | |||||
| const std::string kOpType = "type"; | |||||
| const std::string kReason = "reason"; | |||||
| const std::string kInput = "input"; | |||||
| const std::string kOutput = "output"; | |||||
| const std::string kShape = "shape"; | |||||
| const std::string kDataType = "data_type"; | |||||
| const std::string kLayout = "layout"; | |||||
| const std::string kResult = "result"; | |||||
| const std::string kOp = "op"; | |||||
| std::map<analyzer::AnalyzeType, std::string> errors_map { | |||||
| {PARSER, "paser_error"}, | |||||
| {INFER_SHAPE, "infer_shape_error"}, | |||||
| {CHECKSUPPORT, "check_support_error"}, | |||||
| {GRAPH_OPTIMIZE, "graph_optimize_error"}, | |||||
| {GRAPH_PARTION, "graph_partion_error"}, | |||||
| {GRAPH_BUILDER, "graph_builder_error"} | |||||
| }; | |||||
| } | |||||
| Analyzer* Analyzer::GetInstance() { | |||||
| const std::string kOpName = "name"; | |||||
| const std::string kOpType = "type"; | |||||
| const std::string kReason = "reason"; | |||||
| const std::string kInput = "input"; | |||||
| const std::string kOutput = "output"; | |||||
| const std::string kShape = "shape"; | |||||
| const std::string kDataType = "data_type"; | |||||
| const std::string kLayout = "layout"; | |||||
| const std::string kResult = "result"; | |||||
| const std::string kOp = "op"; | |||||
| std::map<analyzer::AnalyzeType, std::string> errors_map{{PARSER, "paser_error"}, | |||||
| {INFER_SHAPE, "infer_shape_error"}, | |||||
| {CHECKSUPPORT, "check_support_error"}, | |||||
| {GRAPH_OPTIMIZE, "graph_optimize_error"}, | |||||
| {GRAPH_PARTION, "graph_partion_error"}, | |||||
| {GRAPH_BUILDER, "graph_builder_error"}}; | |||||
| } // namespace | |||||
| Analyzer *Analyzer::GetInstance() { | |||||
| static Analyzer instance; | static Analyzer instance; | ||||
| return &instance; | return &instance; | ||||
| } | } | ||||
| @@ -77,8 +75,9 @@ Status Analyzer::BuildJsonObject(uint64_t session_id, uint64_t graph_id) { | |||||
| std::lock_guard<std::recursive_mutex> lg(mutex_); | std::lock_guard<std::recursive_mutex> lg(mutex_); | ||||
| auto iter = graph_infos_.find(session_id); | auto iter = graph_infos_.find(session_id); | ||||
| if (iter == graph_infos_.end()) { | if (iter == graph_infos_.end()) { | ||||
| std::shared_ptr<GraphInfo> graph_info(new(std::nothrow) GraphInfo()); | |||||
| GE_CHECK_NOTNULL(graph_info); | |||||
| auto p = new (std::nothrow) GraphInfo(); | |||||
| GE_CHECK_NOTNULL(p); | |||||
| std::shared_ptr<GraphInfo> graph_info(p); | |||||
| std::map<uint64_t, std::shared_ptr<GraphInfo>> graph_map; | std::map<uint64_t, std::shared_ptr<GraphInfo>> graph_map; | ||||
| graph_map[graph_id] = graph_info; | graph_map[graph_id] = graph_info; | ||||
| graph_info->session_id = session_id; | graph_info->session_id = session_id; | ||||
| @@ -87,8 +86,9 @@ Status Analyzer::BuildJsonObject(uint64_t session_id, uint64_t graph_id) { | |||||
| } else { | } else { | ||||
| auto iter1 = (iter->second).find(graph_id); | auto iter1 = (iter->second).find(graph_id); | ||||
| if (iter1 == (iter->second).end()) { | if (iter1 == (iter->second).end()) { | ||||
| std::shared_ptr<GraphInfo> graph_info(new(std::nothrow) GraphInfo()); | |||||
| GE_CHECK_NOTNULL(graph_info); | |||||
| auto p = new (std::nothrow) GraphInfo(); | |||||
| GE_CHECK_NOTNULL(p); | |||||
| std::shared_ptr<GraphInfo> graph_info(p); | |||||
| graph_info->session_id = session_id; | graph_info->session_id = session_id; | ||||
| graph_info->graph_id = graph_id; | graph_info->graph_id = graph_id; | ||||
| (iter->second).insert({graph_id, graph_info}); | (iter->second).insert({graph_id, graph_info}); | ||||
| @@ -100,14 +100,7 @@ Status Analyzer::BuildJsonObject(uint64_t session_id, uint64_t graph_id) { | |||||
| } | } | ||||
| ge::Status Analyzer::Initialize() { | ge::Status Analyzer::Initialize() { | ||||
| // Initialize file | |||||
| string real_path = RealPath(kFilePath.c_str()); | |||||
| if (real_path.empty()) { | |||||
| GELOGE(FAILED, "File path is invalid."); | |||||
| return FAILED; | |||||
| } | |||||
| json_file_name_ = real_path + "/" + kAnalyzeFile; | |||||
| ClearHistoryFile(); | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| @@ -145,7 +138,6 @@ void Analyzer::DestroyGraphJsonObject(uint64_t session_id, uint64_t graph_id) { | |||||
| if (iter1 == (iter->second).end()) { | if (iter1 == (iter->second).end()) { | ||||
| GELOGW("Can not find the graph json object by session_id[%lu] and graph_id[%lu]. Do nothing.", session_id, | GELOGW("Can not find the graph json object by session_id[%lu] and graph_id[%lu]. Do nothing.", session_id, | ||||
| graph_id); | graph_id); | ||||
| return; | |||||
| } | } | ||||
| (iter->second).erase(iter1); | (iter->second).erase(iter1); | ||||
| } | } | ||||
| @@ -182,8 +174,15 @@ ge::Status Analyzer::CreateAnalyzerFile() { | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| GELOGD("start to create analyzer file!"); | GELOGD("start to create analyzer file!"); | ||||
| // Check whether the manifest exists, if not, create it. | |||||
| string real_path = RealPath(kFilePath.c_str()); | |||||
| if (real_path.empty()) { | |||||
| GELOGE(FAILED, "File path is invalid."); | |||||
| return FAILED; | |||||
| } | |||||
| std::lock_guard<std::mutex> lg(file_mutex_); | std::lock_guard<std::mutex> lg(file_mutex_); | ||||
| json_file_name_ = real_path + "/" + kAnalyzeFile; | |||||
| GELOGD("Created analyzer file:[%s]", json_file_name_.c_str()); | |||||
| int fd = open(json_file_name_.c_str(), O_WRONLY | O_CREAT | O_TRUNC, kFileAuthority); | int fd = open(json_file_name_.c_str(), O_WRONLY | O_CREAT | O_TRUNC, kFileAuthority); | ||||
| if (fd < 0) { | if (fd < 0) { | ||||
| GELOGE(INTERNAL_ERROR, "Fail to open the file: %s.", json_file_name_.c_str()); | GELOGE(INTERNAL_ERROR, "Fail to open the file: %s.", json_file_name_.c_str()); | ||||
| @@ -199,27 +198,25 @@ ge::Status Analyzer::CreateAnalyzerFile() { | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| ge::Status Analyzer::SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_id) { | |||||
| ge::Status Analyzer::SaveAnalyzerDataToFile() { | |||||
| GELOGD("start to save analyze file!"); | GELOGD("start to save analyze file!"); | ||||
| auto graph_info = GetJsonObject(session_id, graph_id); | |||||
| GE_CHECK_NOTNULL(graph_info); | |||||
| if (graph_info->op_info.size() == 0) { | |||||
| GELOGD("session_id:%lu graph_id:%lu does not owner op info, break it!", session_id, graph_id); | |||||
| return SUCCESS; | |||||
| } | |||||
| std::lock_guard<std::mutex> lg(file_mutex_); | std::lock_guard<std::mutex> lg(file_mutex_); | ||||
| json_file_.open(json_file_name_, std::ios::app); | |||||
| json_file_.open(json_file_name_, std::ios::out); | |||||
| if (!json_file_.is_open()) { | if (!json_file_.is_open()) { | ||||
| GELOGE(FAILED, "analyzer file does not exist[%s]", json_file_name_.c_str()); | GELOGE(FAILED, "analyzer file does not exist[%s]", json_file_name_.c_str()); | ||||
| return PARAM_INVALID; | return PARAM_INVALID; | ||||
| } | } | ||||
| json jsn; | |||||
| GraphInfoToJson(jsn, *graph_info); | |||||
| json_file_ << jsn.dump(kJsonDumpLevel) << std::endl; | |||||
| json_file_.close(); | |||||
| std::lock_guard<std::recursive_mutex> lk(mutex_); | |||||
| for (auto &ele : graph_infos_) { | |||||
| for (auto &ele2 : ele.second) { | |||||
| json jsn; | |||||
| GraphInfoToJson(jsn, *(ele2.second)); | |||||
| json_file_ << jsn.dump(kJsonDumpLevel) << std::endl; | |||||
| } | |||||
| } | |||||
| json_file_.close(); | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| @@ -240,7 +237,13 @@ ge::Status Analyzer::DoAnalyze(DataInfo &data_info) { | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| // create json file | // create json file | ||||
| return CreateAnalyzerFile(); | |||||
| status = CreateAnalyzerFile(); | |||||
| if (status != SUCCESS) { | |||||
| GELOGE(status, "create analyzer file failed!"); | |||||
| return status; | |||||
| } | |||||
| // save data to file | |||||
| return SaveAnalyzerDataToFile(); | |||||
| } | } | ||||
| ge::Status Analyzer::SaveOpInfo(ge::OpDescPtr desc, DataInfo &data_info, | ge::Status Analyzer::SaveOpInfo(ge::OpDescPtr desc, DataInfo &data_info, | ||||
| @@ -253,18 +256,18 @@ ge::Status Analyzer::SaveOpInfo(ge::OpDescPtr desc, DataInfo &data_info, | |||||
| op_info.error_type = iter->second; | op_info.error_type = iter->second; | ||||
| op_info.op_name = desc->GetName(); | op_info.op_name = desc->GetName(); | ||||
| op_info.op_type = desc->GetType(); | op_info.op_type = desc->GetType(); | ||||
| op_info.reason = data_info.reason; | |||||
| op_info.reason = data_info.reason; | |||||
| for (const auto &ptr : desc->GetAllInputsDescPtr()) { | for (const auto &ptr : desc->GetAllInputsDescPtr()) { | ||||
| TensorInfo tensor_info; | TensorInfo tensor_info; | ||||
| tensor_info.shape = ptr->GetShape().GetDims(); | |||||
| tensor_info.shape = ptr->GetShape().GetDims(); | |||||
| tensor_info.d_type = ge::TypeUtils::DataTypeToSerialString(ptr->GetDataType()); | tensor_info.d_type = ge::TypeUtils::DataTypeToSerialString(ptr->GetDataType()); | ||||
| tensor_info.layout = ge::TypeUtils::FormatToSerialString(ptr->GetFormat()); | tensor_info.layout = ge::TypeUtils::FormatToSerialString(ptr->GetFormat()); | ||||
| op_info.input_info.emplace_back(tensor_info); | op_info.input_info.emplace_back(tensor_info); | ||||
| } | } | ||||
| for (const auto &ptr : desc->GetAllOutputsDescPtr()) { | for (const auto &ptr : desc->GetAllOutputsDescPtr()) { | ||||
| TensorInfo tensor_info; | TensorInfo tensor_info; | ||||
| tensor_info.shape = ptr->GetShape().GetDims(); | |||||
| tensor_info.shape = ptr->GetShape().GetDims(); | |||||
| tensor_info.d_type = ge::TypeUtils::DataTypeToSerialString(ptr->GetDataType()); | tensor_info.d_type = ge::TypeUtils::DataTypeToSerialString(ptr->GetDataType()); | ||||
| tensor_info.layout = ge::TypeUtils::FormatToSerialString(ptr->GetFormat()); | tensor_info.layout = ge::TypeUtils::FormatToSerialString(ptr->GetFormat()); | ||||
| op_info.output_info.emplace_back(tensor_info); | op_info.output_info.emplace_back(tensor_info); | ||||
| @@ -274,13 +277,13 @@ ge::Status Analyzer::SaveOpInfo(ge::OpDescPtr desc, DataInfo &data_info, | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| void Analyzer::TensorInfoToJson(json& j, const TensorInfo &tensor_info) { | |||||
| void Analyzer::TensorInfoToJson(json &j, const TensorInfo &tensor_info) { | |||||
| j[kShape] = tensor_info.shape; | j[kShape] = tensor_info.shape; | ||||
| j[kDataType] = tensor_info.d_type; | j[kDataType] = tensor_info.d_type; | ||||
| j[kLayout] = tensor_info.layout; | j[kLayout] = tensor_info.layout; | ||||
| } | } | ||||
| void Analyzer::OpInfoToJson(json& j, const OpInfo &op_info) { | |||||
| void Analyzer::OpInfoToJson(json &j, const OpInfo &op_info) { | |||||
| j[kErrorType] = op_info.error_type; | j[kErrorType] = op_info.error_type; | ||||
| j[kOpName] = op_info.op_name; | j[kOpName] = op_info.op_name; | ||||
| j[kOpType] = op_info.op_type; | j[kOpType] = op_info.op_type; | ||||
| @@ -297,7 +300,7 @@ void Analyzer::OpInfoToJson(json& j, const OpInfo &op_info) { | |||||
| } | } | ||||
| } | } | ||||
| void Analyzer::GraphInfoToJson(json& j, const GraphInfo &graph_info) { | |||||
| void Analyzer::GraphInfoToJson(json &j, const GraphInfo &graph_info) { | |||||
| GELOGD("start to buff graph info!"); | GELOGD("start to buff graph info!"); | ||||
| j[kSessionId] = graph_info.session_id; | j[kSessionId] = graph_info.session_id; | ||||
| j[kGraphId] = graph_info.graph_id; | j[kGraphId] = graph_info.graph_id; | ||||
| @@ -309,4 +312,4 @@ void Analyzer::GraphInfoToJson(json& j, const GraphInfo &graph_info) { | |||||
| } | } | ||||
| j[kOp] = json_op_infos; | j[kOp] = json_op_infos; | ||||
| } | } | ||||
| } // namespace ge | |||||
| } // namespace ge | |||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -33,12 +33,12 @@ | |||||
| namespace ge { | namespace ge { | ||||
| namespace analyzer { | namespace analyzer { | ||||
| enum AnalyzeType { | enum AnalyzeType { | ||||
| PARSER = 0, | |||||
| INFER_SHAPE = 1, | |||||
| CHECKSUPPORT = 2, | |||||
| PARSER = 0, | |||||
| INFER_SHAPE = 1, | |||||
| CHECKSUPPORT = 2, | |||||
| GRAPH_OPTIMIZE = 3, | GRAPH_OPTIMIZE = 3, | ||||
| GRAPH_PARTION = 4, | |||||
| GRAPH_BUILDER = 5, | |||||
| GRAPH_PARTION = 4, | |||||
| GRAPH_BUILDER = 5, | |||||
| }; | }; | ||||
| struct TensorInfo { | struct TensorInfo { | ||||
| @@ -66,8 +66,7 @@ struct DataInfo { | |||||
| DataInfo() = default; | DataInfo() = default; | ||||
| ~DataInfo() = default; | ~DataInfo() = default; | ||||
| DataInfo(uint64_t sess, uint64_t graph, AnalyzeType type, | |||||
| ge::NodePtr node, std::string error_info) { | |||||
| DataInfo(uint64_t sess, uint64_t graph, AnalyzeType type, ge::NodePtr node, std::string error_info) { | |||||
| session_id = sess; | session_id = sess; | ||||
| graph_id = graph; | graph_id = graph; | ||||
| analyze_type = type; | analyze_type = type; | ||||
| @@ -80,10 +79,10 @@ struct DataInfo { | |||||
| ge::NodePtr node_ptr{nullptr}; | ge::NodePtr node_ptr{nullptr}; | ||||
| std::string reason; | std::string reason; | ||||
| }; | }; | ||||
| } | |||||
| } // namespace analyzer | |||||
| class Analyzer { | class Analyzer { | ||||
| public: | |||||
| public: | |||||
| /** | /** | ||||
| * @ingroup ge | * @ingroup ge | ||||
| * @brief: get analyzer instance. | * @brief: get analyzer instance. | ||||
| @@ -157,39 +156,33 @@ public: | |||||
| */ | */ | ||||
| ge::Status DoAnalyze(analyzer::DataInfo &data_info); | ge::Status DoAnalyze(analyzer::DataInfo &data_info); | ||||
| /** | |||||
| * @ingroup ge | |||||
| * @brief: Buff analyzed data and output to json file | |||||
| * @param [in]: session id , graph id | |||||
| * @return: 0: SUCCESS other: FAILED | |||||
| */ | |||||
| ge::Status SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_id); | |||||
| Analyzer(const Analyzer &) = delete; | Analyzer(const Analyzer &) = delete; | ||||
| Analyzer& operator=(const Analyzer&) = delete; | |||||
| Analyzer &operator=(const Analyzer &) = delete; | |||||
| Analyzer(Analyzer &&) = delete; | Analyzer(Analyzer &&) = delete; | ||||
| Analyzer& operator=(Analyzer &&) = delete; | |||||
| private: | |||||
| void TensorInfoToJson(nlohmann::json& j, const analyzer::TensorInfo &tensor_info); | |||||
| void OpInfoToJson(nlohmann::json& j, const analyzer::OpInfo &op_info); | |||||
| void GraphInfoToJson(nlohmann::json& j, const analyzer::GraphInfo &graph_info); | |||||
| Analyzer &operator=(Analyzer &&) = delete; | |||||
| private: | |||||
| void TensorInfoToJson(nlohmann::json &j, const analyzer::TensorInfo &tensor_info); | |||||
| void OpInfoToJson(nlohmann::json &j, const analyzer::OpInfo &op_info); | |||||
| void GraphInfoToJson(nlohmann::json &j, const analyzer::GraphInfo &graph_info); | |||||
| ge::Status SaveAnalyzerDataToFile(); | |||||
| ge::Status SaveOpInfo(ge::OpDescPtr desc, analyzer::DataInfo &data_info, | ge::Status SaveOpInfo(ge::OpDescPtr desc, analyzer::DataInfo &data_info, | ||||
| std::shared_ptr<analyzer::GraphInfo> graph_info); | |||||
| std::shared_ptr<analyzer::GraphInfo> graph_info); | |||||
| void ClearHistoryFile(); | void ClearHistoryFile(); | ||||
| ge::Status CreateAnalyzerFile(); | ge::Status CreateAnalyzerFile(); | ||||
| explicit Analyzer() {}; | |||||
| explicit Analyzer(){}; | |||||
| ~Analyzer() = default; | ~Analyzer() = default; | ||||
| private: | |||||
| private: | |||||
| std::map<uint64_t, std::map<uint64_t, std::shared_ptr<analyzer::GraphInfo>>> graph_infos_; | std::map<uint64_t, std::map<uint64_t, std::shared_ptr<analyzer::GraphInfo>>> graph_infos_; | ||||
| std::recursive_mutex mutex_; // protect graph_infos_ | |||||
| std::mutex file_mutex_; // protect json_file_ | |||||
| std::recursive_mutex mutex_; // protect graph_infos_ | |||||
| std::mutex file_mutex_; // protect json_file_ | |||||
| std::ofstream json_file_; | std::ofstream json_file_; | ||||
| std::string json_file_name_; | std::string json_file_name_; | ||||
| std::atomic_bool is_json_file_create_{false}; | std::atomic_bool is_json_file_create_{false}; | ||||
| }; | }; | ||||
| } // namespace ge | |||||
| #endif // DOMI_ANALYZER_ANANLYZER_H_ | |||||
| } // namespace ge | |||||
| #endif // DOMI_ANALYZER_ANANLYZER_H_ | |||||
| @@ -384,7 +384,7 @@ Status Session::RunGraphAsync(uint32_t graph_id, const std::vector<InputTensorIn | |||||
| } | } | ||||
| GELOGT(TRACE_RUNNING, "Run Graph Asynchronously"); | GELOGT(TRACE_RUNNING, "Run Graph Asynchronously"); | ||||
| GELOGW( | GELOGW( | ||||
| "The callback function will not be checked. Please ensure that the implementation of the function is trusted."); | |||||
| "The callback function will not be checked. Please ensure that the implementation of the function is trusted."); | |||||
| Status ret = ge::GELib::GetInstance()->SessionManagerObj().RunGraphAsync(sessionId_, graph_id, inputs, callback); | Status ret = ge::GELib::GetInstance()->SessionManagerObj().RunGraphAsync(sessionId_, graph_id, inputs, callback); | ||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -39,21 +39,12 @@ const std::string kDeviceIdList = "devIdList"; | |||||
| const std::string kAicoreMetrics = "aicoreMetrics"; | const std::string kAicoreMetrics = "aicoreMetrics"; | ||||
| const std::map<ge::ProfilingAicoreMetrics, std::string> kProfAicoreMetricsToString = { | const std::map<ge::ProfilingAicoreMetrics, std::string> kProfAicoreMetricsToString = { | ||||
| <<<<<<< HEAD:ge/client/ge_prof.cc | |||||
| {ge::kAicoreArithmaticThroughput, "AICORE_ARITHMATIC_THROUGHPUT"}, | |||||
| {ge::kAicorePipeline, "AICORE_PIPELINE"}, | |||||
| {ge::kAicoreSynchronization, "AICORE_SYNCHRONIZATION"}, | |||||
| {ge::kAicoreMemory, "AICORE_MEMORY"}, | |||||
| {ge::kAicoreInternalMemory, "AICORE_INTERNAL_MEMORY"}, | |||||
| {ge::kAicoreStall, "AICORE_STALL"}}; | |||||
| ======= | |||||
| {ge::kAicoreArithmaticThroughput, "AICORE_ARITHMATIC_THROUGHPUT"}, | {ge::kAicoreArithmaticThroughput, "AICORE_ARITHMATIC_THROUGHPUT"}, | ||||
| {ge::kAicorePipeline, "AICORE_PIPELINE"}, | {ge::kAicorePipeline, "AICORE_PIPELINE"}, | ||||
| {ge::kAicoreSynchronization, "AICORE_SYNCHRONIZATION"}, | {ge::kAicoreSynchronization, "AICORE_SYNCHRONIZATION"}, | ||||
| {ge::kAicoreMemory, "AICORE_MEMORY"}, | {ge::kAicoreMemory, "AICORE_MEMORY"}, | ||||
| {ge::kAicoreInternalMemory, "AICORE_INTERNAL_MEMORY"}, | {ge::kAicoreInternalMemory, "AICORE_INTERNAL_MEMORY"}, | ||||
| {ge::kAicoreStall, "AICORE_STALL"}}; | {ge::kAicoreStall, "AICORE_STALL"}}; | ||||
| >>>>>>> cd365aa247c64e30487d1e71e4f724a889848f80:src/ge/client/ge_prof.cc | |||||
| } // namespace | } // namespace | ||||
| static bool g_graph_prof_init_ = false; | static bool g_graph_prof_init_ = false; | ||||
| @@ -174,7 +165,7 @@ bool TransProfConfigToParam(const aclgrphProfConfig *profiler_config, vector<str | |||||
| prof_config_params.push_back(devID); | prof_config_params.push_back(devID); | ||||
| prof_config_params.push_back(kAicoreMetrics); | prof_config_params.push_back(kAicoreMetrics); | ||||
| auto iter = | auto iter = | ||||
| kProfAicoreMetricsToString.find(static_cast<ProfilingAicoreMetrics>(profiler_config->config.aicoreMetrics)); | |||||
| kProfAicoreMetricsToString.find(static_cast<ProfilingAicoreMetrics>(profiler_config->config.aicoreMetrics)); | |||||
| if (iter == kProfAicoreMetricsToString.end()) { | if (iter == kProfAicoreMetricsToString.end()) { | ||||
| GELOGW("The prof aicore metrics is invalid."); | GELOGW("The prof aicore metrics is invalid."); | ||||
| return false; | return false; | ||||
| @@ -333,17 +324,10 @@ Status aclgrphProfStop(aclgrphProfConfig *profiler_config) { | |||||
| return GE_PROF_NOT_INIT; | return GE_PROF_NOT_INIT; | ||||
| } | } | ||||
| for (uint32_t i = 0; i < profiler_config->config.devNums; i++) { | |||||
| uint64_t data_type_config; | |||||
| Status status = ProfGetDataTypeConfig(profiler_config->config.devIdList[i], data_type_config); | |||||
| if (status != SUCCESS) { | |||||
| GELOGE(status, "Prof get data type config failed, prof result = %d", status); | |||||
| return status; | |||||
| } | |||||
| if (data_type_config != profiler_config->config.dataTypeConfig) { | |||||
| GELOGE(FAILED, "data type config verify failed"); | |||||
| return FAILED; | |||||
| } | |||||
| Status ret = ProfStopProfiling(&profiler_config->config); | |||||
| if (ret != SUCCESS) { | |||||
| GELOGE(ret, "Stop profiling failed, prof result = %d", ret); | |||||
| return ret; | |||||
| } | } | ||||
| std::vector<string> prof_params; | std::vector<string> prof_params; | ||||
| @@ -360,22 +344,12 @@ Status aclgrphProfStop(aclgrphProfConfig *profiler_config) { | |||||
| command.module_index = profiler_config->config.dataTypeConfig; | command.module_index = profiler_config->config.dataTypeConfig; | ||||
| GELOGI("Profiling will stop, device nums:%s , deviceID:[%s], data type config: 0x%llx", prof_params[0].c_str(), | GELOGI("Profiling will stop, device nums:%s , deviceID:[%s], data type config: 0x%llx", prof_params[0].c_str(), | ||||
| prof_params[kDeviceListIndex].c_str(), command.module_index); | prof_params[kDeviceListIndex].c_str(), command.module_index); | ||||
| <<<<<<< HEAD:ge/client/ge_prof.cc | |||||
| Status ret = graph_loader.CommandHandle(command); | |||||
| ======= | |||||
| ret = graph_loader.CommandHandle(command); | ret = graph_loader.CommandHandle(command); | ||||
| >>>>>>> cd365aa247c64e30487d1e71e4f724a889848f80:src/ge/client/ge_prof.cc | |||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(ret, "Handle profiling command failed"); | GELOGE(ret, "Handle profiling command failed"); | ||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| ret = ProfStopProfiling(&profiler_config->config); | |||||
| if (ret != SUCCESS) { | |||||
| GELOGE(ret, "Stop profiling failed, prof result = %d", ret); | |||||
| return ret; | |||||
| } | |||||
| GELOGI("Successfully execute GraphProfStopProfiling."); | GELOGI("Successfully execute GraphProfStopProfiling."); | ||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| @@ -1 +1,104 @@ | |||||
| ../../proto/ge_api.proto | |||||
| /** | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | |||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||||
| * you may not use this file except in compliance with the License. | |||||
| * You may obtain a copy of the License at | |||||
| * | |||||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||||
| * | |||||
| * Unless required by applicable law or agreed to in writing, software | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| * See the License for the specific language governing permissions and | |||||
| * limitations under the License. | |||||
| */ | |||||
| syntax = "proto3"; | |||||
| package ge.api_pb; | |||||
| import "ge_ir.proto"; | |||||
| // GE initialize | |||||
| message GEInitialize { | |||||
| map<string, string> options = 1; | |||||
| }; | |||||
| // initialize response | |||||
| message GEInitializeResponse { | |||||
| uint32 status = 1; | |||||
| uint32 clientId = 2; | |||||
| }; | |||||
| // GE finalize | |||||
| message GEFinalize { | |||||
| bool final = 1; | |||||
| uint32 clientId = 2; | |||||
| }; | |||||
| message GEFinalizeResponse { | |||||
| uint32 status = 1; | |||||
| }; | |||||
| // GE Session | |||||
| message CreateSession{ | |||||
| map<string, string> options = 1; | |||||
| }; | |||||
| message CreateSessionResponse { | |||||
| uint32 status = 1; | |||||
| uint64 sessionId = 2; | |||||
| }; | |||||
| //GE AddGraph | |||||
| //model serialize :: serializegraph | |||||
| message SessionAddGraph{ | |||||
| uint32 graphId = 1; | |||||
| uint64 sessionId = 2; | |||||
| ge.proto.GraphDef graph = 3; | |||||
| }; | |||||
| message SessionAddGraphResponse { | |||||
| uint32 status = 1; | |||||
| }; | |||||
| //GE SessionRemoveGraph | |||||
| message SessionRemoveGraph{ | |||||
| uint32 graphId = 1; | |||||
| uint64 sessionId = 2; | |||||
| }; | |||||
| message SessionRemoveGraphResponse { | |||||
| uint32 status = 1; | |||||
| }; | |||||
| message SessionRunGraph{ | |||||
| uint32 graphId = 1; | |||||
| uint64 sessionId = 2; | |||||
| repeated ge.proto.TensorDef tensor = 3; | |||||
| }; | |||||
| message SessionBuildGraph{ | |||||
| uint32 graphId = 1; | |||||
| uint64 sessionId = 2; | |||||
| repeated ge.proto.TensorDef tensor = 3; | |||||
| string savePath = 4; | |||||
| }; | |||||
| message SessionRunGraphResponse { | |||||
| uint32 status = 1; | |||||
| repeated ge.proto.TensorDef tensor = 2; | |||||
| }; | |||||
| message SessionBuildGraphResponse { | |||||
| uint32 status = 1; | |||||
| }; | |||||
| message DestroySession{ | |||||
| bool final = 1; | |||||
| uint64 sessionId = 2; | |||||
| }; | |||||
| message DestroySessionResponse { | |||||
| uint32 status = 1; | |||||
| }; | |||||
| @@ -1,3 +1,19 @@ | |||||
| /** | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | |||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||||
| * you may not use this file except in compliance with the License. | |||||
| * You may obtain a copy of the License at | |||||
| * | |||||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||||
| * | |||||
| * Unless required by applicable law or agreed to in writing, software | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| * See the License for the specific language governing permissions and | |||||
| * limitations under the License. | |||||
| */ | |||||
| syntax = "proto3"; | syntax = "proto3"; | ||||
| package ge.proto; | package ge.proto; | ||||
| @@ -1,3 +1,19 @@ | |||||
| /** | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | |||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||||
| * you may not use this file except in compliance with the License. | |||||
| * You may obtain a copy of the License at | |||||
| * | |||||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||||
| * | |||||
| * Unless required by applicable law or agreed to in writing, software | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| * See the License for the specific language governing permissions and | |||||
| * limitations under the License. | |||||
| */ | |||||
| syntax = "proto3"; | syntax = "proto3"; | ||||
| package domi; | package domi; | ||||
| @@ -45,9 +61,6 @@ message AippOpParams { | |||||
| // 标识对模型的第几个输入做AIPP处理,例如模型有两个输入,需要对第2个输入做AIPP,则配置related_input_rank为1。 | // 标识对模型的第几个输入做AIPP处理,例如模型有两个输入,需要对第2个输入做AIPP,则配置related_input_rank为1。 | ||||
| uint32 related_input_rank = 2; | uint32 related_input_rank = 2; | ||||
| // related_input_name is optional and the top name of data node which inserts aipp | |||||
| string related_input_name = 6; | |||||
| // input_edge_idx参数为可选,类型为整型,配置范围为>=0。 | // input_edge_idx参数为可选,类型为整型,配置范围为>=0。 | ||||
| // 配置该参数的作用,在于对Data算子不同的输出做不同的AIPP处理,如果该参数没有配置,默认对related_input_rank指定的模型输入的所有输出边做AIPP。 | // 配置该参数的作用,在于对Data算子不同的输出做不同的AIPP处理,如果该参数没有配置,默认对related_input_rank指定的模型输入的所有输出边做AIPP。 | ||||
| // 配置值 <= Data算子输出边的个数。 | // 配置值 <= Data算子输出边的个数。 | ||||
| @@ -1,14 +1,19 @@ | |||||
| /* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. | |||||
| /** | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * This program is free software; you can redistribute it and/or modify | |||||
| * it under the terms of the Apache License Version 2.0.You may not use this file except in compliance with the License. | |||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||||
| * you may not use this file except in compliance with the License. | |||||
| * You may obtain a copy of the License at | |||||
| * | * | ||||
| * This program is distributed in the hope that it will be useful, | |||||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| * Apache License for more details at | |||||
| * http://www.apache.org/licenses/LICENSE-2.0 | * http://www.apache.org/licenses/LICENSE-2.0 | ||||
| * | |||||
| * Unless required by applicable law or agreed to in writing, software | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| * See the License for the specific language governing permissions and | |||||
| * limitations under the License. | |||||
| */ | */ | ||||
| syntax = "proto3"; | syntax = "proto3"; | ||||
| package domi; | package domi; | ||||
| @@ -1,14 +1,19 @@ | |||||
| /* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. | |||||
| /** | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * This program is free software; you can redistribute it and/or modify | |||||
| * it under the terms of the Apache License Version 2.0.You may not use this file except in compliance with the License. | |||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||||
| * you may not use this file except in compliance with the License. | |||||
| * You may obtain a copy of the License at | |||||
| * | * | ||||
| * This program is distributed in the hope that it will be useful, | |||||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| * Apache License for more details at | |||||
| * http://www.apache.org/licenses/LICENSE-2.0 | * http://www.apache.org/licenses/LICENSE-2.0 | ||||
| * | |||||
| * Unless required by applicable law or agreed to in writing, software | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| * See the License for the specific language governing permissions and | |||||
| * limitations under the License. | |||||
| */ | */ | ||||
| syntax = "proto3"; | syntax = "proto3"; | ||||
| package domi; | package domi; | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -55,26 +55,9 @@ Status FileSaver::OpenFile(int32_t &fd, const std::string &file_path) { | |||||
| Status FileSaver::WriteData(const void *data, uint32_t size, int32_t fd) { | Status FileSaver::WriteData(const void *data, uint32_t size, int32_t fd) { | ||||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(size == 0 || data == nullptr, return PARAM_INVALID); | GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(size == 0 || data == nullptr, return PARAM_INVALID); | ||||
| mmSsize_t write_count; | |||||
| uint32_t size_2g = ((uint32_t) 0x1 << 31); | |||||
| uint32_t size_1g = ((uint32_t) 0x1 << 30); | |||||
| // Write data | |||||
| if (size > size_2g) { | |||||
| auto seek = reinterpret_cast<uint8_t *>(const_cast<void *>(data)); | |||||
| while (size > size_1g) { | |||||
| write_count = mmWrite(fd, reinterpret_cast<void *>(seek), size_1g); | |||||
| if (write_count == EN_INVALID_PARAM || write_count == EN_ERROR) { | |||||
| GELOGE(FAILED, "Write data failed. mmpa_errorno = %d, %s", write_count, strerror(errno)); | |||||
| return FAILED; | |||||
| } | |||||
| size -= size_1g; | |||||
| seek += size_1g; | |||||
| } | |||||
| write_count = mmWrite(fd, reinterpret_cast<void *>(seek), size); | |||||
| } else { | |||||
| write_count = mmWrite(fd, const_cast<void *>(data), size); | |||||
| } | |||||
| // Write data | |||||
| int32_t write_count = mmWrite(fd, const_cast<void *>(data), size); | |||||
| // -1: Failed to write to file; - 2: Illegal parameter | // -1: Failed to write to file; - 2: Illegal parameter | ||||
| if (write_count == EN_INVALID_PARAM || write_count == EN_ERROR) { | if (write_count == EN_INVALID_PARAM || write_count == EN_ERROR) { | ||||
| GELOGE(FAILED, "Write data failed. mmpa_errorno = %d, %s", write_count, strerror(errno)); | GELOGE(FAILED, "Write data failed. mmpa_errorno = %d, %s", write_count, strerror(errno)); | ||||
| @@ -116,10 +99,10 @@ Status FileSaver::SaveWithFileHeader(const std::string &file_path, const ModelFi | |||||
| ModelPartitionTable &model_partition_table, | ModelPartitionTable &model_partition_table, | ||||
| const std::vector<ModelPartition> &partition_datas) { | const std::vector<ModelPartition> &partition_datas) { | ||||
| GE_CHK_BOOL_RET_STATUS(!partition_datas.empty() && model_partition_table.num != 0 | |||||
| && model_partition_table.num == partition_datas.size(), FAILED, | |||||
| "Invalid param:partition data size is (%u), model_partition_table.num is (%zu).", | |||||
| model_partition_table.num, partition_datas.size()); | |||||
| GE_CHK_BOOL_RET_STATUS( | |||||
| !partition_datas.empty() && model_partition_table.num != 0 && model_partition_table.num == partition_datas.size(), | |||||
| FAILED, "Invalid param:partition data size is (%u), model_partition_table.num is (%zu).", model_partition_table.num, | |||||
| partition_datas.size()); | |||||
| // Open file | // Open file | ||||
| int32_t fd = 0; | int32_t fd = 0; | ||||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(OpenFile(fd, file_path) != SUCCESS, return FAILED); | GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(OpenFile(fd, file_path) != SUCCESS, return FAILED); | ||||
| @@ -127,18 +110,16 @@ Status FileSaver::SaveWithFileHeader(const std::string &file_path, const ModelFi | |||||
| do { | do { | ||||
| // Write file header | // Write file header | ||||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | ||||
| WriteData(static_cast<const void *>(&file_header), sizeof(ModelFileHeader), fd) != SUCCESS, ret = FAILED; | |||||
| break); | |||||
| WriteData(static_cast<const void *>(&file_header), sizeof(ModelFileHeader), fd) != SUCCESS, ret = FAILED; break); | |||||
| // Write model partition table | // Write model partition table | ||||
| uint32_t table_size = static_cast<uint32_t>(SIZE_OF_MODEL_PARTITION_TABLE(model_partition_table)); | uint32_t table_size = static_cast<uint32_t>(SIZE_OF_MODEL_PARTITION_TABLE(model_partition_table)); | ||||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | ||||
| WriteData(static_cast<const void *>(&model_partition_table), table_size, fd) != SUCCESS, ret = FAILED; break); | |||||
| WriteData(static_cast<const void *>(&model_partition_table), table_size, fd) != SUCCESS, ret = FAILED; break); | |||||
| // Write partition data | // Write partition data | ||||
| for (const auto &partitionData : partition_datas) { | for (const auto &partitionData : partition_datas) { | ||||
| GELOGI("GC:size[%zu]", partitionData.size); | |||||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | ||||
| WriteData(static_cast<const void *>(partitionData.data), partitionData.size, fd) != SUCCESS, ret = FAILED; | |||||
| break); | |||||
| WriteData(static_cast<const void *>(partitionData.data), partitionData.size, fd) != SUCCESS, ret = FAILED; | |||||
| break); | |||||
| } | } | ||||
| } while (0); | } while (0); | ||||
| // Close file | // Close file | ||||
| @@ -151,9 +132,9 @@ Status FileSaver::SaveToBuffWithFileHeader(const ModelFileHeader &file_header, | |||||
| const std::vector<ModelPartition> &partitionDatas, | const std::vector<ModelPartition> &partitionDatas, | ||||
| ge::ModelBufferData &model) { | ge::ModelBufferData &model) { | ||||
| GE_CHK_BOOL_RET_STATUS( | GE_CHK_BOOL_RET_STATUS( | ||||
| !partitionDatas.empty() && model_partition_table.num != 0 && model_partition_table.num == partitionDatas.size(), | |||||
| FAILED, "Invalid param:partition data size is (%u), model_partition_table.num is (%zu).", | |||||
| model_partition_table.num, partitionDatas.size()); | |||||
| !partitionDatas.empty() && model_partition_table.num != 0 && model_partition_table.num == partitionDatas.size(), | |||||
| FAILED, "Invalid param:partition data size is (%u), model_partition_table.num is (%zu).", model_partition_table.num, | |||||
| partitionDatas.size()); | |||||
| uint32_t model_header_size = sizeof(ModelFileHeader); | uint32_t model_header_size = sizeof(ModelFileHeader); | ||||
| uint32_t table_size = static_cast<uint32_t>(SIZE_OF_MODEL_PARTITION_TABLE(model_partition_table)); | uint32_t table_size = static_cast<uint32_t>(SIZE_OF_MODEL_PARTITION_TABLE(model_partition_table)); | ||||
| uint32_t total_size = model_header_size + table_size; | uint32_t total_size = model_header_size + table_size; | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -74,10 +74,8 @@ class FileSaver { | |||||
| ModelPartitionTable &model_partition_table, | ModelPartitionTable &model_partition_table, | ||||
| const std::vector<ModelPartition> &partition_datas); | const std::vector<ModelPartition> &partition_datas); | ||||
| static Status SaveToBuffWithFileHeader(const ModelFileHeader &file_header, | |||||
| ModelPartitionTable &model_partition_table, | |||||
| const std::vector<ModelPartition> &partitionDatas, | |||||
| ge::ModelBufferData& model); | |||||
| static Status SaveToBuffWithFileHeader(const ModelFileHeader &file_header, ModelPartitionTable &model_partition_table, | |||||
| const std::vector<ModelPartition> &partitionDatas, ge::ModelBufferData &model); | |||||
| static Status SaveToFile(const string &file_path, const void *data, int len); | static Status SaveToFile(const string &file_path, const void *data, int len); | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -25,24 +25,23 @@ | |||||
| namespace ge { | namespace ge { | ||||
| namespace { | namespace { | ||||
| const char* kBase64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |||||
| "abcdefghijklmnopqrstuvwxyz" | |||||
| "0123456789+/"; | |||||
| const char *kBase64Chars = | |||||
| "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |||||
| "abcdefghijklmnopqrstuvwxyz" | |||||
| "0123456789+/"; | |||||
| const char kEqualSymbol = '='; | const char kEqualSymbol = '='; | ||||
| const size_t kBase64CharsNum = 64; | const size_t kBase64CharsNum = 64; | ||||
| const size_t kThreeByteOneGroup = 3; | const size_t kThreeByteOneGroup = 3; | ||||
| const size_t kFourByteOneGroup = 4; | const size_t kFourByteOneGroup = 4; | ||||
| } | |||||
| } // namespace | |||||
| namespace base64 { | namespace base64 { | ||||
| static inline bool IsBase64Char(const char &c) { | |||||
| return (isalnum(c) || (c == '+') || (c == '/')); | |||||
| } | |||||
| static inline bool IsBase64Char(const char &c) { return (isalnum(c) || (c == '+') || (c == '/')); } | |||||
| static std::string EncodeToBase64(const std::string &raw_data) { | static std::string EncodeToBase64(const std::string &raw_data) { | ||||
| size_t encode_length = raw_data.size() / kThreeByteOneGroup * kFourByteOneGroup; | size_t encode_length = raw_data.size() / kThreeByteOneGroup * kFourByteOneGroup; | ||||
| encode_length += raw_data.size() % kThreeByteOneGroup == 0 ? 0 : kFourByteOneGroup; | encode_length += raw_data.size() % kThreeByteOneGroup == 0 ? 0 : kFourByteOneGroup; | ||||
| size_t raw_data_index = 0 ; | |||||
| size_t raw_data_index = 0; | |||||
| size_t encode_data_index = 0; | size_t encode_data_index = 0; | ||||
| std::string encode_data; | std::string encode_data; | ||||
| encode_data.resize(encode_length); | encode_data.resize(encode_length); | ||||
| @@ -80,8 +79,7 @@ static std::string EncodeToBase64(const std::string &raw_data) { | |||||
| #pragma GCC diagnostic ignored "-Wunused-function" | #pragma GCC diagnostic ignored "-Wunused-function" | ||||
| static Status DecodeFromBase64(const std::string &base64_data, std::string &decode_data) { | static Status DecodeFromBase64(const std::string &base64_data, std::string &decode_data) { | ||||
| if (base64_data.size() % kFourByteOneGroup != 0) { | if (base64_data.size() % kFourByteOneGroup != 0) { | ||||
| GELOGE(PARAM_INVALID, "base64 data size must can be divided by 4, but given data size is %zu", | |||||
| base64_data.size()); | |||||
| GELOGE(PARAM_INVALID, "base64 data size must can be divided by 4, but given data size is %zu", base64_data.size()); | |||||
| return PARAM_INVALID; | return PARAM_INVALID; | ||||
| } | } | ||||
| decode_data.clear(); | decode_data.clear(); | ||||
| @@ -94,8 +92,7 @@ static Status DecodeFromBase64(const std::string &base64_data, std::string &deco | |||||
| for (std::size_t input_data_index = 0; input_data_index < base64_data_len; input_data_index += 4) { | for (std::size_t input_data_index = 0; input_data_index < base64_data_len; input_data_index += 4) { | ||||
| for (size_t i = 0; i < kFourByteOneGroup; ++i) { | for (size_t i = 0; i < kFourByteOneGroup; ++i) { | ||||
| if (base64_data[input_data_index + i] == kEqualSymbol && | |||||
| input_data_index >= base64_data_len - 4 && i > 1) { | |||||
| if (base64_data[input_data_index + i] == kEqualSymbol && input_data_index >= base64_data_len - 4 && i > 1) { | |||||
| byte_4[i] = kBase64CharsNum; | byte_4[i] = kBase64CharsNum; | ||||
| } else if (IsBase64Char(base64_data[input_data_index + i])) { | } else if (IsBase64Char(base64_data[input_data_index + i])) { | ||||
| byte_4[i] = FindCharInBase64Chars(base64_data[input_data_index + i]); | byte_4[i] = FindCharInBase64Chars(base64_data[input_data_index + i]); | ||||
| @@ -105,18 +102,18 @@ static Status DecodeFromBase64(const std::string &base64_data, std::string &deco | |||||
| } | } | ||||
| } | } | ||||
| decode_data += static_cast<char>((byte_4[0] << 2u) + ((byte_4[1] & 0x30) >> 4u)); | decode_data += static_cast<char>((byte_4[0] << 2u) + ((byte_4[1] & 0x30) >> 4u)); | ||||
| if (byte_4[2] >= kBase64CharsNum){ | |||||
| if (byte_4[2] >= kBase64CharsNum) { | |||||
| break; | break; | ||||
| } else if (byte_4[3] >= kBase64CharsNum) { | } else if (byte_4[3] >= kBase64CharsNum) { | ||||
| decode_data += static_cast<char>(((byte_4[1] & 0x0f) << 4u) + ((byte_4[2] & 0x3c) >> 2u)); | |||||
| decode_data += static_cast<char>(((byte_4[1] & 0x0f) << 4u) + ((byte_4[2] & 0x3c) >> 2u)); | |||||
| break; | break; | ||||
| } | } | ||||
| decode_data += static_cast<char>(((byte_4[1] & 0x0f) << 4u) + ((byte_4[2] & 0x3c) >> 2u)); | |||||
| decode_data += static_cast<char>(((byte_4[2] & 0x03) << 6u) + byte_4[3]); | |||||
| decode_data += static_cast<char>(((byte_4[1] & 0x0f) << 4u) + ((byte_4[2] & 0x3c) >> 2u)); | |||||
| decode_data += static_cast<char>(((byte_4[2] & 0x03) << 6u) + byte_4[3]); | |||||
| } | } | ||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| #pragma GCC diagnostic pop | #pragma GCC diagnostic pop | ||||
| } | |||||
| } // namespace base64 | |||||
| } // namespace ge | } // namespace ge | ||||
| #endif // GE_COMMON_BASE64_H_ | #endif // GE_COMMON_BASE64_H_ | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -20,9 +20,7 @@ namespace ge { | |||||
| CustAICPUKernelStore::CustAICPUKernelStore() {} | CustAICPUKernelStore::CustAICPUKernelStore() {} | ||||
| void CustAICPUKernelStore::AddCustAICPUKernel(const CustAICPUKernelPtr &kernel) { | |||||
| AddKernel(kernel); | |||||
| } | |||||
| void CustAICPUKernelStore::AddCustAICPUKernel(const CustAICPUKernelPtr &kernel) { AddKernel(kernel); } | |||||
| void CustAICPUKernelStore::LoadCustAICPUKernelBinToOpDesc(const std::shared_ptr<ge::OpDesc> &op_desc) const { | void CustAICPUKernelStore::LoadCustAICPUKernelBinToOpDesc(const std::shared_ptr<ge::OpDesc> &op_desc) const { | ||||
| GELOGI("LoadCustAICPUKernelBinToOpDesc in"); | GELOGI("LoadCustAICPUKernelBinToOpDesc in"); | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -252,4 +252,4 @@ Status DumpOp::LaunchDumpOp() { | |||||
| } | } | ||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| } // namesapce ge | |||||
| } // namespace ge | |||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -35,14 +35,14 @@ const std::string kDumpStatusOpen = "on"; | |||||
| const uint32_t kAicoreOverflow = (0x1 << 0); | const uint32_t kAicoreOverflow = (0x1 << 0); | ||||
| const uint32_t kAtomicOverflow = (0x1 << 1); | const uint32_t kAtomicOverflow = (0x1 << 1); | ||||
| const uint32_t kAllOverflow = (kAicoreOverflow | kAtomicOverflow); | const uint32_t kAllOverflow = (kAicoreOverflow | kAtomicOverflow); | ||||
| } | |||||
| } // namespace | |||||
| namespace ge { | namespace ge { | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY DumpProperties::DumpProperties(const DumpProperties &other) { | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY DumpProperties::DumpProperties(const DumpProperties &other) { | ||||
| CopyFrom(other); | CopyFrom(other); | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY DumpProperties &DumpProperties::operator=( | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY DumpProperties &DumpProperties::operator=( | ||||
| const DumpProperties &other) { | |||||
| const DumpProperties &other) { | |||||
| CopyFrom(other); | CopyFrom(other); | ||||
| return *this; | return *this; | ||||
| } | } | ||||
| @@ -97,7 +97,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::InitByOpti | |||||
| // The following is the new dump scenario of the fusion operator | // The following is the new dump scenario of the fusion operator | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::AddPropertyValue( | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::AddPropertyValue( | ||||
| const std::string &model, const std::set<std::string> &layers) { | |||||
| const std::string &model, const std::set<std::string> &layers) { | |||||
| for (const std::string &layer : layers) { | for (const std::string &layer : layers) { | ||||
| GELOGI("This model %s config to dump layer %s", model.c_str(), layer.c_str()); | GELOGI("This model %s config to dump layer %s", model.c_str(), layer.c_str()); | ||||
| } | } | ||||
| @@ -136,7 +136,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::set<std::string> DumpPrope | |||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::set<std::string> DumpProperties::GetPropertyValue( | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::set<std::string> DumpProperties::GetPropertyValue( | ||||
| const std::string &model) const { | |||||
| const std::string &model) const { | |||||
| auto iter = model_dump_properties_map_.find(model); | auto iter = model_dump_properties_map_.find(model); | ||||
| if (iter != model_dump_properties_map_.end()) { | if (iter != model_dump_properties_map_.end()) { | ||||
| return iter->second; | return iter->second; | ||||
| @@ -145,7 +145,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::set<std::string> DumpPrope | |||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool DumpProperties::IsLayerNeedDump( | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool DumpProperties::IsLayerNeedDump( | ||||
| const std::string &model, const std::string &om_name, const std::string &op_name) const { | |||||
| const std::string &model, const std::string &om_name, const std::string &op_name) const { | |||||
| // if dump all | // if dump all | ||||
| if (model_dump_properties_map_.find(DUMP_ALL_MODEL) != model_dump_properties_map_.end()) { | if (model_dump_properties_map_.find(DUMP_ALL_MODEL) != model_dump_properties_map_.end()) { | ||||
| return true; | return true; | ||||
| @@ -201,7 +201,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY const std::string &DumpProperti | |||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::SetDumpOpSwitch( | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::SetDumpOpSwitch( | ||||
| const std::string dump_op_switch) { | |||||
| const std::string &dump_op_switch) { | |||||
| dump_op_switch_ = dump_op_switch; | dump_op_switch_ = dump_op_switch; | ||||
| } | } | ||||
| @@ -266,4 +266,4 @@ void DumpProperties::SetDumpDebugOptions() { | |||||
| GELOGI("ge.exec.enableDumpDebug is false or is not set."); | GELOGI("ge.exec.enableDumpDebug is false or is not set."); | ||||
| } | } | ||||
| } | } | ||||
| } // namespace | |||||
| } // namespace ge | |||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -65,7 +65,7 @@ class DumpProperties { | |||||
| const std::string &GetDumpStatus() const; | const std::string &GetDumpStatus() const; | ||||
| void SetDumpOpSwitch(const std::string dump_op_switch); | |||||
| void SetDumpOpSwitch(const std::string &dump_op_switch); | |||||
| const std::string &GetDumpOpSwitch() const; | const std::string &GetDumpOpSwitch() const; | ||||
| @@ -77,9 +77,9 @@ class DumpProperties { | |||||
| uint32_t GetOpDebugMode() const { return op_debug_mode_; } | uint32_t GetOpDebugMode() const { return op_debug_mode_; } | ||||
| const std::string &GetEnableDump() const {return enable_dump_;} | |||||
| const std::string &GetEnableDump() const { return enable_dump_; } | |||||
| const std::string &GetEnableDumpDebug() const {return enable_dump_debug_;} | |||||
| const std::string &GetEnableDumpDebug() const { return enable_dump_debug_; } | |||||
| private: | private: | ||||
| void CopyFrom(const DumpProperties &other); | void CopyFrom(const DumpProperties &other); | ||||
| @@ -99,6 +99,6 @@ class DumpProperties { | |||||
| bool is_op_debug_ = false; | bool is_op_debug_ = false; | ||||
| uint32_t op_debug_mode_ = 0; | uint32_t op_debug_mode_ = 0; | ||||
| }; | }; | ||||
| } | |||||
| } // namespace ge | |||||
| #endif //GE_COMMON_DUMP_DUMP_PROPERTIES_H_ | |||||
| #endif // GE_COMMON_DUMP_DUMP_PROPERTIES_H_ | |||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -89,8 +89,8 @@ Status TransDataSrc2Fp16(const CastArgs &args, uint8_t *dst, const size_t data_s | |||||
| } | } | ||||
| Status CastKernel(const CastArgs &args, uint8_t *dst, const size_t data_size, const DataTypeTransMode trans_mode) { | Status CastKernel(const CastArgs &args, uint8_t *dst, const size_t data_size, const DataTypeTransMode trans_mode) { | ||||
| static std::map<DataTypeTransMode, std::function<Status(const CastArgs &, uint8_t *, const size_t)>> | |||||
| transfer_handle = { | |||||
| static std::map<DataTypeTransMode, std::function<Status(const CastArgs &, uint8_t *, const size_t)>> transfer_handle = | |||||
| { | |||||
| {kTransferWithDatatypeFloatToFloat16, TransDataSrc2Fp16<float>}, | {kTransferWithDatatypeFloatToFloat16, TransDataSrc2Fp16<float>}, | ||||
| {kTransferWithDatatypeFloatToInt32, TransDataSrc2Dst<float, int32_t>}, | {kTransferWithDatatypeFloatToInt32, TransDataSrc2Dst<float, int32_t>}, | ||||
| {kTransferWithDatatypeFloat16ToFloat, TransDataSrc2Dst<fp16_t, float>}, | {kTransferWithDatatypeFloat16ToFloat, TransDataSrc2Dst<fp16_t, float>}, | ||||
| @@ -107,7 +107,7 @@ Status CastKernel(const CastArgs &args, uint8_t *dst, const size_t data_size, co | |||||
| {kTransferWithDatatypeInt32ToInt64, TransDataSrc2Dst<int32_t, int64_t>}, | {kTransferWithDatatypeInt32ToInt64, TransDataSrc2Dst<int32_t, int64_t>}, | ||||
| {kTransferWithDatatypeInt32ToDouble, TransDataSrc2Dst<int32_t, double>}, | {kTransferWithDatatypeInt32ToDouble, TransDataSrc2Dst<int32_t, double>}, | ||||
| {kTransferWithDatatypeDoubleToInt32, TransDataSrc2Dst<double, int32_t>}, | {kTransferWithDatatypeDoubleToInt32, TransDataSrc2Dst<double, int32_t>}, | ||||
| }; | |||||
| }; | |||||
| auto it = transfer_handle.find(trans_mode); | auto it = transfer_handle.find(trans_mode); | ||||
| if (it == transfer_handle.end()) { | if (it == transfer_handle.end()) { | ||||
| return UNSUPPORTED; | return UNSUPPORTED; | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -105,8 +105,8 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, int size | |||||
| auto dst_offset = dst_idx * size; | auto dst_offset = dst_idx * size; | ||||
| // The memcpy_s/memset_s argument `dstMax` must be less than 2G | // The memcpy_s/memset_s argument `dstMax` must be less than 2G | ||||
| auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | ||||
| ? total_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| ? total_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | ||||
| static_cast<size_t>(size)); | static_cast<size_t>(size)); | ||||
| if (ret != EOK) { | if (ret != EOK) { | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -13,6 +13,7 @@ | |||||
| * See the License for the specific language governing permissions and | * See the License for the specific language governing permissions and | ||||
| * limitations under the License. | * limitations under the License. | ||||
| */ | */ | ||||
| #include "common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h" | #include "common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h" | ||||
| #include <securec.h> | #include <securec.h> | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -13,6 +13,7 @@ | |||||
| * See the License for the specific language governing permissions and | * See the License for the specific language governing permissions and | ||||
| * limitations under the License. | * limitations under the License. | ||||
| */ | */ | ||||
| #ifndef GE_COMMON_FORMATS_FORMAT_TRANSFERS_FORMAT_TRANSFER_DHWCN_FRACTAL_Z_3D_H_ | #ifndef GE_COMMON_FORMATS_FORMAT_TRANSFERS_FORMAT_TRANSFER_DHWCN_FRACTAL_Z_3D_H_ | ||||
| #define GE_COMMON_FORMATS_FORMAT_TRANSFERS_FORMAT_TRANSFER_DHWCN_FRACTAL_Z_3D_H_ | #define GE_COMMON_FORMATS_FORMAT_TRANSFERS_FORMAT_TRANSFER_DHWCN_FRACTAL_Z_3D_H_ | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -13,6 +13,7 @@ | |||||
| * See the License for the specific language governing permissions and | * See the License for the specific language governing permissions and | ||||
| * limitations under the License. | * limitations under the License. | ||||
| */ | */ | ||||
| #include "common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h" | #include "common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h" | ||||
| #include <securec.h> | #include <securec.h> | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -13,6 +13,7 @@ | |||||
| * See the License for the specific language governing permissions and | * See the License for the specific language governing permissions and | ||||
| * limitations under the License. | * limitations under the License. | ||||
| */ | */ | ||||
| #ifndef GE_COMMON_FORMATS_FORMAT_TRANSFERS_FORMAT_TRANSFER_DHWNC_FRACTAL_Z_3D_TRANSPOSE_H_ | #ifndef GE_COMMON_FORMATS_FORMAT_TRANSFERS_FORMAT_TRANSFER_DHWNC_FRACTAL_Z_3D_TRANSPOSE_H_ | ||||
| #define GE_COMMON_FORMATS_FORMAT_TRANSFERS_FORMAT_TRANSFER_DHWNC_FRACTAL_Z_3D_TRANSPOSE_H_ | #define GE_COMMON_FORMATS_FORMAT_TRANSFERS_FORMAT_TRANSFER_DHWNC_FRACTAL_Z_3D_TRANSPOSE_H_ | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -154,8 +154,9 @@ Status TransFormatFromNdToFracNz(const TransArgs &args, TransResult &result, con | |||||
| for (int64_t w1_idx = 0; w1_idx < num_w1; w1_idx++) { | for (int64_t w1_idx = 0; w1_idx < num_w1; w1_idx++) { | ||||
| auto dst_offset = (h1h0_head + w1_idx * h1h0w0) * size; | auto dst_offset = (h1h0_head + w1_idx * h1h0w0) * size; | ||||
| auto src_offset = (src_h_head + w1_idx * w0) * size; | auto src_offset = (src_h_head + w1_idx * w0) * size; | ||||
| auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) ? | |||||
| dst_size - dst_offset : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | |||||
| ? dst_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | ||||
| static_cast<size_t>(size * w0)); | static_cast<size_t>(size * w0)); | ||||
| if (ret != EOK) { | if (ret != EOK) { | ||||
| @@ -168,8 +169,9 @@ Status TransFormatFromNdToFracNz(const TransArgs &args, TransResult &result, con | |||||
| auto src_w_idx = w1_head + w0_idx; | auto src_w_idx = w1_head + w0_idx; | ||||
| auto dst_offset = (h1h0_head + num_w1 * h1h0w0 + w0_idx) * size; | auto dst_offset = (h1h0_head + num_w1 * h1h0w0 + w0_idx) * size; | ||||
| auto src_offset = (src_h_head + src_w_idx) * size; | auto src_offset = (src_h_head + src_w_idx) * size; | ||||
| auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) ? | |||||
| dst_size - dst_offset : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | |||||
| ? dst_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | ||||
| static_cast<size_t>(size)); | static_cast<size_t>(size)); | ||||
| if (ret != EOK) { | if (ret != EOK) { | ||||
| @@ -225,8 +227,9 @@ Status TransFormatFromFracNzToNd(const TransArgs &args, TransResult &result, con | |||||
| for (int64_t w1_idx = 0; w1_idx < num_w1; w1_idx++) { | for (int64_t w1_idx = 0; w1_idx < num_w1; w1_idx++) { | ||||
| auto src_offset = (h1h0_head + w1_idx * h1h0w0) * size; | auto src_offset = (h1h0_head + w1_idx * h1h0w0) * size; | ||||
| auto dst_offset = (dst_h_head + w1_idx * w0) * size; | auto dst_offset = (dst_h_head + w1_idx * w0) * size; | ||||
| auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) ? | |||||
| dst_size - dst_offset : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | |||||
| ? dst_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | ||||
| static_cast<size_t>(size * w0)); | static_cast<size_t>(size * w0)); | ||||
| if (ret != EOK) { | if (ret != EOK) { | ||||
| @@ -239,8 +242,9 @@ Status TransFormatFromFracNzToNd(const TransArgs &args, TransResult &result, con | |||||
| auto dst_w_idx = w1_head + w0_idx; | auto dst_w_idx = w1_head + w0_idx; | ||||
| auto src_offset = (h1h0_head + num_w1 * h1h0w0 + w0_idx) * size; | auto src_offset = (h1h0_head + num_w1 * h1h0w0 + w0_idx) * size; | ||||
| auto dst_offset = (dst_h_head + dst_w_idx) * size; | auto dst_offset = (dst_h_head + dst_w_idx) * size; | ||||
| auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) ? | |||||
| dst_size - dst_offset : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | |||||
| ? dst_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | ||||
| static_cast<size_t>(size)); | static_cast<size_t>(size)); | ||||
| if (ret != EOK) { | if (ret != EOK) { | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -124,11 +124,11 @@ Status TransFormatFromNchwToFz(const TransArgs &args, TransResult &result) { | |||||
| std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size], std::default_delete<uint8_t[]>()); | std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size], std::default_delete<uint8_t[]>()); | ||||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | ||||
| dst == nullptr, | |||||
| GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", | |||||
| TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||||
| TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); | |||||
| return OUT_OF_MEMORY;); | |||||
| dst == nullptr, | |||||
| GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", | |||||
| TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||||
| TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); | |||||
| return OUT_OF_MEMORY;); | |||||
| for (int64_t vfi = 0; vfi < vf_cnt; vfi++) { | for (int64_t vfi = 0; vfi < vf_cnt; vfi++) { | ||||
| // vertical fractal matrix base index | // vertical fractal matrix base index | ||||
| @@ -152,8 +152,8 @@ Status TransFormatFromNchwToFz(const TransArgs &args, TransResult &result) { | |||||
| auto idx = gfi * fractal_ele_cnt + col * c0 + row; | auto idx = gfi * fractal_ele_cnt + col * c0 + row; | ||||
| auto offset = idx * size; | auto offset = idx * size; | ||||
| auto protected_size = dst_size - offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | auto protected_size = dst_size - offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | ||||
| ? dst_size - offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| ? dst_size - offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| errno_t ret = EOK; | errno_t ret = EOK; | ||||
| if (need_pad_zero) { | if (need_pad_zero) { | ||||
| ret = memset_s(dst.get() + offset, static_cast<size_t>(protected_size), 0, static_cast<size_t>(size)); | ret = memset_s(dst.get() + offset, static_cast<size_t>(protected_size), 0, static_cast<size_t>(size)); | ||||
| @@ -209,11 +209,11 @@ Status TransFormatHwcnToFz(const TransArgs &args, TransResult &result) { | |||||
| std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size], std::default_delete<uint8_t[]>()); | std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size], std::default_delete<uint8_t[]>()); | ||||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | ||||
| dst == nullptr, | |||||
| GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", | |||||
| TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||||
| TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); | |||||
| return OUT_OF_MEMORY;); | |||||
| dst == nullptr, | |||||
| GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", | |||||
| TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||||
| TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); | |||||
| return OUT_OF_MEMORY;); | |||||
| for (int64_t c1i = 0; c1i < c1; c1i++) { | for (int64_t c1i = 0; c1i < c1; c1i++) { | ||||
| for (int64_t hi = 0; hi < h; hi++) { | for (int64_t hi = 0; hi < h; hi++) { | ||||
| @@ -223,8 +223,8 @@ Status TransFormatHwcnToFz(const TransArgs &args, TransResult &result) { | |||||
| int64_t dst_idx = c1i * hwn1n0c0 + hi * wn1n0c0 + wi * n1n0c0 + n1n0i * c0 + c0i; | int64_t dst_idx = c1i * hwn1n0c0 + hi * wn1n0c0 + wi * n1n0c0 + n1n0i * c0 + c0i; | ||||
| int64_t dst_offset = dst_idx * data_size; | int64_t dst_offset = dst_idx * data_size; | ||||
| auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | ||||
| ? dst_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| ? dst_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| auto pad_zero = ((c1i * c0 + c0i) >= c) || (n1n0i >= n); | auto pad_zero = ((c1i * c0 + c0i) >= c) || (n1n0i >= n); | ||||
| errno_t ret = EOK; | errno_t ret = EOK; | ||||
| if (pad_zero) { | if (pad_zero) { | ||||
| @@ -284,11 +284,11 @@ Status TransFormatNhwcToFz(const TransArgs &args, TransResult &result) { | |||||
| std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size], std::default_delete<uint8_t[]>()); | std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size], std::default_delete<uint8_t[]>()); | ||||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | ||||
| dst == nullptr, | |||||
| GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", | |||||
| TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||||
| TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); | |||||
| return OUT_OF_MEMORY;); | |||||
| dst == nullptr, | |||||
| GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", | |||||
| TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||||
| TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); | |||||
| return OUT_OF_MEMORY;); | |||||
| for (int64_t c1i = 0; c1i < c1; c1i++) { | for (int64_t c1i = 0; c1i < c1; c1i++) { | ||||
| for (int64_t hi = 0; hi < h; hi++) { | for (int64_t hi = 0; hi < h; hi++) { | ||||
| @@ -298,8 +298,8 @@ Status TransFormatNhwcToFz(const TransArgs &args, TransResult &result) { | |||||
| int64_t dst_idx = c1i * hwn1n0c0 + hi * wn1n0c0 + wi * n1n0c0 + n1n0i * c0 + c0i; | int64_t dst_idx = c1i * hwn1n0c0 + hi * wn1n0c0 + wi * n1n0c0 + n1n0i * c0 + c0i; | ||||
| int64_t dst_offset = dst_idx * data_size; | int64_t dst_offset = dst_idx * data_size; | ||||
| auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | ||||
| ? dst_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| ? dst_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| auto pad_zero = ((c1i * c0 + c0i) >= c) || (n1n0i >= n); | auto pad_zero = ((c1i * c0 + c0i) >= c) || (n1n0i >= n); | ||||
| errno_t ret = EOK; | errno_t ret = EOK; | ||||
| if (pad_zero) { | if (pad_zero) { | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2019 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -158,8 +158,8 @@ Status TransFormatFromNdToFracZz(const TransArgs &args, TransResult &result, con | |||||
| auto src_offset = (src_h_head + w1_idx * w0) * size; | auto src_offset = (src_h_head + w1_idx * w0) * size; | ||||
| auto dst_offset = (h0_head + w1_idx * h0w0) * size; | auto dst_offset = (h0_head + w1_idx * h0w0) * size; | ||||
| auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | ||||
| ? dst_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| ? dst_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | ||||
| static_cast<size_t>(size * w0)); | static_cast<size_t>(size * w0)); | ||||
| if (ret != EOK) { | if (ret != EOK) { | ||||
| @@ -174,8 +174,8 @@ Status TransFormatFromNdToFracZz(const TransArgs &args, TransResult &result, con | |||||
| auto src_offset = (src_h_head + src_w_idx) * size; | auto src_offset = (src_h_head + src_w_idx) * size; | ||||
| auto dst_offset = (w0_head + w0_idx) * size; | auto dst_offset = (w0_head + w0_idx) * size; | ||||
| auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | ||||
| ? dst_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| ? dst_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | ||||
| static_cast<size_t>(size)); | static_cast<size_t>(size)); | ||||
| if (ret != EOK) { | if (ret != EOK) { | ||||
| @@ -236,8 +236,8 @@ Status TransFormatFromFracZzToNd(const TransArgs &args, TransResult &result, con | |||||
| auto src_offset = (h0_head + w1_idx * h0w0) * size; | auto src_offset = (h0_head + w1_idx * h0w0) * size; | ||||
| auto dst_offset = (dst_h_head + w1_idx * w0) * size; | auto dst_offset = (dst_h_head + w1_idx * w0) * size; | ||||
| auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | ||||
| ? dst_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| ? dst_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | ||||
| static_cast<size_t>(size * w0)); | static_cast<size_t>(size * w0)); | ||||
| if (ret != EOK) { | if (ret != EOK) { | ||||
| @@ -252,8 +252,8 @@ Status TransFormatFromFracZzToNd(const TransArgs &args, TransResult &result, con | |||||
| auto dst_w_idx = w1_head + w0_idx; | auto dst_w_idx = w1_head + w0_idx; | ||||
| auto dst_offset = (dst_h_head + dst_w_idx) * size; | auto dst_offset = (dst_h_head + dst_w_idx) * size; | ||||
| auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | ||||
| ? dst_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| ? dst_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | ||||
| static_cast<size_t>(size)); | static_cast<size_t>(size)); | ||||
| if (ret != EOK) { | if (ret != EOK) { | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2019 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -104,8 +104,9 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||||
| int64_t src_idx = c1_idx * hwncc0 + h_idx * wncc0 + w_idx * ncc0 + nc_idx * c0 + c0_idx; | int64_t src_idx = c1_idx * hwncc0 + h_idx * wncc0 + w_idx * ncc0 + nc_idx * c0 + c0_idx; | ||||
| auto src_offset = src_idx * size; | auto src_offset = src_idx * size; | ||||
| auto dst_offset = dst_idx * size; | auto dst_offset = dst_idx * size; | ||||
| auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) ? | |||||
| total_size - dst_offset : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | |||||
| ? total_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | ||||
| static_cast<size_t>(size)); | static_cast<size_t>(size)); | ||||
| if (ret != EOK) { | if (ret != EOK) { | ||||
| @@ -139,7 +140,7 @@ Status FormatTransferFracZHwcn::TransFormat(const TransArgs &args, TransResult & | |||||
| } | } | ||||
| GELOGE(INTERNAL_ERROR, "Get %ld total size from dst shape %s, src shape %s", total_size, | GELOGE(INTERNAL_ERROR, "Get %ld total size from dst shape %s, src shape %s", total_size, | ||||
| ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||||
| ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||||
| return PARAM_INVALID; | return PARAM_INVALID; | ||||
| } | } | ||||
| GELOGD("Begin to trans format from FracZ to HWCN, src shape %s, data type %s, dst shape %s, memory size %ld", | GELOGD("Begin to trans format from FracZ to HWCN, src shape %s, data type %s, dst shape %s, memory size %ld", | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -104,8 +104,9 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||||
| int64_t src_idx = c1_idx * hwncc0 + h_idx * wncc0 + w_idx * ncc0 + nc_idx * c0 + c0_idx; | int64_t src_idx = c1_idx * hwncc0 + h_idx * wncc0 + w_idx * ncc0 + nc_idx * c0 + c0_idx; | ||||
| auto src_offset = src_idx * size; | auto src_offset = src_idx * size; | ||||
| auto dst_offset = dst_idx * size; | auto dst_offset = dst_idx * size; | ||||
| auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) ? | |||||
| total_size - dst_offset : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | |||||
| ? total_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | ||||
| static_cast<size_t>(size)); | static_cast<size_t>(size)); | ||||
| if (ret != EOK) { | if (ret != EOK) { | ||||
| @@ -139,7 +140,7 @@ Status FormatTransferFracZNchw::TransFormat(const TransArgs &args, TransResult & | |||||
| } | } | ||||
| GELOGE(INTERNAL_ERROR, "Get %ld total size from dst shape %s, src shape %s", total_size, | GELOGE(INTERNAL_ERROR, "Get %ld total size from dst shape %s, src shape %s", total_size, | ||||
| ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||||
| ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||||
| return PARAM_INVALID; | return PARAM_INVALID; | ||||
| } | } | ||||
| GELOGD("Begin to trans format from FracZ to NCHW, src shape %s, data type %s, dst shape %s, memory size %ld", | GELOGD("Begin to trans format from FracZ to NCHW, src shape %s, data type %s, dst shape %s, memory size %ld", | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -104,8 +104,9 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, int size | |||||
| int64_t src_idx = c1_idx * hwncc0 + h_idx * wncc0 + w_idx * ncc0 + nc_idx * c0 + c0_idx; | int64_t src_idx = c1_idx * hwncc0 + h_idx * wncc0 + w_idx * ncc0 + nc_idx * c0 + c0_idx; | ||||
| auto src_offset = src_idx * size; | auto src_offset = src_idx * size; | ||||
| auto dst_offset = dst_idx * size; | auto dst_offset = dst_idx * size; | ||||
| auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) ? | |||||
| total_size - dst_offset : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | |||||
| ? total_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | ||||
| static_cast<size_t>(size)); | static_cast<size_t>(size)); | ||||
| if (ret != EOK) { | if (ret != EOK) { | ||||
| @@ -138,7 +139,7 @@ Status FormatTransferFracZNhwc::TransFormat(const TransArgs &args, TransResult & | |||||
| } | } | ||||
| GELOGE(INTERNAL_ERROR, "Get %ld total size from dst shape %s, src shape %s", total_size, | GELOGE(INTERNAL_ERROR, "Get %ld total size from dst shape %s, src shape %s", total_size, | ||||
| ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||||
| ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||||
| return PARAM_INVALID; | return PARAM_INVALID; | ||||
| } | } | ||||
| GELOGD("Begin to trans format from FracZ to NHWC, src shape %s, data type %s, dst shape %s, memory size %ld", | GELOGD("Begin to trans format from FracZ to NHWC, src shape %s, data type %s, dst shape %s, memory size %ld", | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -122,8 +122,8 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||||
| int64_t dst_idx = c0_idx + co_head_addr; | int64_t dst_idx = c0_idx + co_head_addr; | ||||
| auto dst_offset = dst_idx * size; | auto dst_offset = dst_idx * size; | ||||
| auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | ||||
| ? total_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| ? total_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| int64_t c_idx = c0_idx + c1_idx * c0; | int64_t c_idx = c0_idx + c1_idx * c0; | ||||
| int64_t src_idx = h_idx * wcn + w_idx * cn + c_idx * n + n_idx; | int64_t src_idx = h_idx * wcn + w_idx * cn + c_idx * n + n_idx; | ||||
| auto src_offset = src_idx * size; | auto src_offset = src_idx * size; | ||||
| @@ -141,7 +141,7 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||||
| } | } | ||||
| } else { | } else { | ||||
| auto ret = | auto ret = | ||||
| memset_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), 0, static_cast<size_t>(size)); | |||||
| memset_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), 0, static_cast<size_t>(size)); | |||||
| if (ret != EOK) { | if (ret != EOK) { | ||||
| GELOGE(INTERNAL_ERROR, | GELOGE(INTERNAL_ERROR, | ||||
| "Failed to set to 0 to C1HWNCoC0[%ld, %ld, %ld, %ld, %ld, %ld] offset %ld, " | "Failed to set to 0 to C1HWNCoC0[%ld, %ld, %ld, %ld, %ld, %ld] offset %ld, " | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -102,8 +102,8 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||||
| auto src_offset = src_idx * size; | auto src_offset = src_idx * size; | ||||
| auto dst_offset = dst_idx * size; | auto dst_offset = dst_idx * size; | ||||
| auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | ||||
| ? total_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| ? total_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | ||||
| static_cast<size_t>(size)); | static_cast<size_t>(size)); | ||||
| if (ret != EOK) { | if (ret != EOK) { | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -102,8 +102,8 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||||
| auto src_offset = src_idx * size; | auto src_offset = src_idx * size; | ||||
| auto dst_offset = dst_idx * size; | auto dst_offset = dst_idx * size; | ||||
| auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | ||||
| ? total_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| ? total_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | ||||
| static_cast<size_t>(size)); | static_cast<size_t>(size)); | ||||
| if (ret != EOK) { | if (ret != EOK) { | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -115,8 +115,8 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||||
| int64_t dst_index = c0_idx + w_head_addr; | int64_t dst_index = c0_idx + w_head_addr; | ||||
| int64_t dst_offset = dst_index * size; | int64_t dst_offset = dst_index * size; | ||||
| auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | ||||
| ? total_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| ? total_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| int64_t cIdx = c0_idx + c1_idx * c0; | int64_t cIdx = c0_idx + c1_idx * c0; | ||||
| int64_t srcIdx = n_idx * chw + cIdx * hw + h_idx * w + w_idx; | int64_t srcIdx = n_idx * chw + cIdx * hw + h_idx * w + w_idx; | ||||
| auto src_offset = srcIdx * size; | auto src_offset = srcIdx * size; | ||||
| @@ -133,7 +133,7 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||||
| } | } | ||||
| } else { | } else { | ||||
| auto ret = | auto ret = | ||||
| memset_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), 0, static_cast<size_t>(size)); | |||||
| memset_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), 0, static_cast<size_t>(size)); | |||||
| if (ret != EOK) { | if (ret != EOK) { | ||||
| GELOGE(INTERNAL_ERROR, | GELOGE(INTERNAL_ERROR, | ||||
| "Failed to set to 0 to " | "Failed to set to 0 to " | ||||
| @@ -173,10 +173,10 @@ Status FormatTransferNchwNc1hwc0::TransFormat(const TransArgs &args, TransResult | |||||
| return PARAM_INVALID; | return PARAM_INVALID; | ||||
| } | } | ||||
| GELOGD( | GELOGD( | ||||
| "Begin to trans format from NCHW to NC1HWC0, src shape %s, data type " | |||||
| "%s, dst shape %s memory size %ld", | |||||
| ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||||
| ShapeToString(args.dst_shape).c_str(), total_size); | |||||
| "Begin to trans format from NCHW to NC1HWC0, src shape %s, data type " | |||||
| "%s, dst shape %s memory size %ld", | |||||
| ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||||
| ShapeToString(args.dst_shape).c_str(), total_size); | |||||
| if (GetDstDataAfterTrans(args, result, size, total_size) != SUCCESS) { | if (GetDstDataAfterTrans(args, result, size, total_size) != SUCCESS) { | ||||
| GELOGE(INTERNAL_ERROR, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", | GELOGE(INTERNAL_ERROR, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", | ||||
| ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -119,8 +119,8 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||||
| int64_t dst_idx = c0_idx + w_head_addr; | int64_t dst_idx = c0_idx + w_head_addr; | ||||
| int64_t dst_offset = dst_idx * size; | int64_t dst_offset = dst_idx * size; | ||||
| auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | ||||
| ? total_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| ? total_size - dst_offset | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| int64_t c_idx = c0_idx + c1_idx * c0; | int64_t c_idx = c0_idx + c1_idx * c0; | ||||
| int64_t src_idx = n_idx * hwc + h_idx * wc + w_idx * c + c_idx; | int64_t src_idx = n_idx * hwc + h_idx * wc + w_idx * c + c_idx; | ||||
| auto src_offset = src_idx * size; | auto src_offset = src_idx * size; | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -28,22 +28,22 @@ namespace ge { | |||||
| namespace formats { | namespace formats { | ||||
| namespace { | namespace { | ||||
| std::map<Format, std::map<Format, std::vector<int64_t>>> perm_args{ | std::map<Format, std::map<Format, std::vector<int64_t>>> perm_args{ | ||||
| {FORMAT_NCHW, | |||||
| {{FORMAT_NHWC, std::vector<int64_t>({0, 2, 3, 1})}, | |||||
| {FORMAT_HWCN, std::vector<int64_t>({2, 3, 1, 0})}, | |||||
| {FORMAT_CHWN, std::vector<int64_t>({1, 2, 3, 0})}}}, | |||||
| {FORMAT_NHWC, | |||||
| {{FORMAT_NCHW, std::vector<int64_t>({0, 3, 1, 2})}, | |||||
| {FORMAT_CHWN, std::vector<int64_t>({3, 1, 2, 0})}, | |||||
| {FORMAT_HWCN, std::vector<int64_t>({1, 2, 3, 0})}}}, | |||||
| {FORMAT_HWCN, | |||||
| {{FORMAT_NCHW, std::vector<int64_t>({3, 2, 0, 1})}, | |||||
| {FORMAT_NHWC, std::vector<int64_t>({3, 0, 1, 2})}, | |||||
| {FORMAT_CHWN, std::vector<int64_t>({2, 0, 1, 3})}}}, | |||||
| {FORMAT_CHWN, | |||||
| {{FORMAT_NCHW, std::vector<int64_t>({3, 0, 1, 2})}, | |||||
| {FORMAT_NHWC, std::vector<int64_t>({3, 1, 2, 0})}, | |||||
| {FORMAT_HWCN, std::vector<int64_t>({1, 2, 0, 3})}}}, | |||||
| {FORMAT_NCHW, | |||||
| {{FORMAT_NHWC, std::vector<int64_t>({0, 2, 3, 1})}, | |||||
| {FORMAT_HWCN, std::vector<int64_t>({2, 3, 1, 0})}, | |||||
| {FORMAT_CHWN, std::vector<int64_t>({1, 2, 3, 0})}}}, | |||||
| {FORMAT_NHWC, | |||||
| {{FORMAT_NCHW, std::vector<int64_t>({0, 3, 1, 2})}, | |||||
| {FORMAT_CHWN, std::vector<int64_t>({3, 1, 2, 0})}, | |||||
| {FORMAT_HWCN, std::vector<int64_t>({1, 2, 3, 0})}}}, | |||||
| {FORMAT_HWCN, | |||||
| {{FORMAT_NCHW, std::vector<int64_t>({3, 2, 0, 1})}, | |||||
| {FORMAT_NHWC, std::vector<int64_t>({3, 0, 1, 2})}, | |||||
| {FORMAT_CHWN, std::vector<int64_t>({2, 0, 1, 3})}}}, | |||||
| {FORMAT_CHWN, | |||||
| {{FORMAT_NCHW, std::vector<int64_t>({3, 0, 1, 2})}, | |||||
| {FORMAT_NHWC, std::vector<int64_t>({3, 1, 2, 0})}, | |||||
| {FORMAT_HWCN, std::vector<int64_t>({1, 2, 0, 3})}}}, | |||||
| }; | }; | ||||
| bool IsShapeArgValid(const std::vector<int64_t> &src_shape, const std::vector<int64_t> &perm_arg) { | bool IsShapeArgValid(const std::vector<int64_t> &src_shape, const std::vector<int64_t> &perm_arg) { | ||||
| @@ -163,8 +163,8 @@ Status Transpose(const uint8_t *src, const std::vector<int64_t> &src_shape, Data | |||||
| auto src_offset = GenOffset(src_heads, dst_indexes) * data_size; | auto src_offset = GenOffset(src_heads, dst_indexes) * data_size; | ||||
| auto dst_offset_bytes = dst_index * data_size; | auto dst_offset_bytes = dst_index * data_size; | ||||
| auto protected_size = dst_size - dst_offset_bytes < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | auto protected_size = dst_size - dst_offset_bytes < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | ||||
| ? dst_size - dst_offset_bytes | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| ? dst_size - dst_offset_bytes | |||||
| : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||||
| auto ret = memcpy_s(dst.get() + dst_offset_bytes, static_cast<size_t>(protected_size), src + src_offset, | auto ret = memcpy_s(dst.get() + dst_offset_bytes, static_cast<size_t>(protected_size), src + src_offset, | ||||
| static_cast<size_t>(data_size)); | static_cast<size_t>(data_size)); | ||||
| if (ret != EOK) { | if (ret != EOK) { | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -33,7 +33,6 @@ Status TransposeWithShapeCheck(const uint8_t *src, const std::vector<int64_t> &s | |||||
| Status GetPermByForamt(Format src_format, Format dst_format, std::vector<int64_t> &perm); | Status GetPermByForamt(Format src_format, Format dst_format, std::vector<int64_t> &perm); | ||||
| class FormatTransferTranspose : public FormatTransfer { | class FormatTransferTranspose : public FormatTransfer { | ||||
| public: | public: | ||||
| Status TransFormat(const TransArgs &args, TransResult &result) override; | Status TransFormat(const TransArgs &args, TransResult &result) override; | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2019 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -51,8 +51,7 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Status TransFormat(const TransArg | |||||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Status TransShape(Format src_format, | GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Status TransShape(Format src_format, | ||||
| const std::vector<int64_t> &src_shape, | const std::vector<int64_t> &src_shape, | ||||
| DataType data_type, | |||||
| Format dst_format, | |||||
| DataType data_type, Format dst_format, | |||||
| std::vector<int64_t> &dst_shape) { | std::vector<int64_t> &dst_shape) { | ||||
| formats::TransArgs args; | formats::TransArgs args; | ||||
| args.src_format = src_format; | args.src_format = src_format; | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -36,8 +36,8 @@ namespace formats { | |||||
| */ | */ | ||||
| Status TransFormat(const TransArgs &args, TransResult &result); | Status TransFormat(const TransArgs &args, TransResult &result); | ||||
| Status TransShape(Format src_format, const std::vector<int64_t> &src_shape, DataType data_type, | |||||
| Format dst_format, std::vector<int64_t> &dst_shape); | |||||
| Status TransShape(Format src_format, const std::vector<int64_t> &src_shape, DataType data_type, Format dst_format, | |||||
| std::vector<int64_t> &dst_shape); | |||||
| Status TransDataType(const CastArgs &args, TransResult &result); | Status TransDataType(const CastArgs &args, TransResult &result); | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2019 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -23,38 +23,13 @@ static const int kCubeSize = 16; | |||||
| static const int kNiSize = 16; | static const int kNiSize = 16; | ||||
| static const int64_t kShapeItemNumMAX = 1024UL * 1024UL * 1024UL * 1024UL; | static const int64_t kShapeItemNumMAX = 1024UL * 1024UL * 1024UL * 1024UL; | ||||
| enum NchwDimIndex { | |||||
| kNchwN, | |||||
| kNchwC, | |||||
| kNchwH, | |||||
| kNchwW, | |||||
| kNchwDimsNum | |||||
| }; | |||||
| enum NchwDimIndex { kNchwN, kNchwC, kNchwH, kNchwW, kNchwDimsNum }; | |||||
| enum NhwcDimIndex { | |||||
| kNhwcN, | |||||
| kNhwcH, | |||||
| kNhwcW, | |||||
| kNhwcC, | |||||
| kNhwcDimsNum | |||||
| }; | |||||
| enum NhwcDimIndex { kNhwcN, kNhwcH, kNhwcW, kNhwcC, kNhwcDimsNum }; | |||||
| enum HwcnDimIndex { | |||||
| kHwcnH, | |||||
| kHwcnW, | |||||
| kHwcnC, | |||||
| kHwcnN, | |||||
| kHwcnDimsNum | |||||
| }; | |||||
| enum HwcnDimIndex { kHwcnH, kHwcnW, kHwcnC, kHwcnN, kHwcnDimsNum }; | |||||
| enum Nc1hwc0DimIndex { | |||||
| kNc1hwc0N, | |||||
| kNc1hwc0C1, | |||||
| kNc1hwc0H, | |||||
| kNc1hwc0W, | |||||
| kNc1hwc0C0, | |||||
| kNc1hwc0DimsNum | |||||
| }; | |||||
| enum Nc1hwc0DimIndex { kNc1hwc0N, kNc1hwc0C1, kNc1hwc0H, kNc1hwc0W, kNc1hwc0C0, kNc1hwc0DimsNum }; | |||||
| enum C1hwncoc0DimIndex { | enum C1hwncoc0DimIndex { | ||||
| kC1hwncoc0C1, | kC1hwncoc0C1, | ||||
| @@ -66,31 +41,11 @@ enum C1hwncoc0DimIndex { | |||||
| kC1hwncoc0DimsNum | kC1hwncoc0DimsNum | ||||
| }; | }; | ||||
| enum FracZDimIndex { | |||||
| kFracZHWC1, | |||||
| kFracZN0, | |||||
| kFracZNi, | |||||
| kFracZC0, | |||||
| kFracZDimsNum | |||||
| }; | |||||
| enum FracZDimIndex { kFracZHWC1, kFracZN0, kFracZNi, kFracZC0, kFracZDimsNum }; | |||||
| enum DhwcnDimIndex { | |||||
| kDhwcnD, | |||||
| kDhwcnH, | |||||
| kDhwcnW, | |||||
| kDhwcnC, | |||||
| kDhwcnN, | |||||
| kDhwcnDimsNum | |||||
| }; | |||||
| enum DhwcnDimIndex { kDhwcnD, kDhwcnH, kDhwcnW, kDhwcnC, kDhwcnN, kDhwcnDimsNum }; | |||||
| enum DhwncDimIndex { | |||||
| kDhwncD, | |||||
| kDhwncH, | |||||
| kDhwncW, | |||||
| kDhwncN, | |||||
| kDhwncC, | |||||
| kDhwncDimsNum | |||||
| }; | |||||
| enum DhwncDimIndex { kDhwncD, kDhwncH, kDhwncW, kDhwncN, kDhwncC, kDhwncDimsNum }; | |||||
| } // namespace formats | } // namespace formats | ||||
| } // namespace ge | } // namespace ge | ||||
| #endif // GE_COMMON_FORMATS_UTILS_FORMATS_DEFINITIONS_H_ | #endif // GE_COMMON_FORMATS_UTILS_FORMATS_DEFINITIONS_H_ | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2019 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -22,46 +22,46 @@ | |||||
| namespace { | namespace { | ||||
| const std::vector<ge::DataType> kEmptyDatatypeVector; | const std::vector<ge::DataType> kEmptyDatatypeVector; | ||||
| std::map<ge::DataType, std::vector<ge::DataType>> g_translatable_data_type = { | std::map<ge::DataType, std::vector<ge::DataType>> g_translatable_data_type = { | ||||
| // key:src datatype, value:dst datatype | |||||
| {ge::DT_FLOAT, {ge::DT_FLOAT16, ge::DT_FLOAT}}, | |||||
| {ge::DT_BOOL, {ge::DT_INT32}}, | |||||
| {ge::DT_FLOAT16, {ge::DT_FLOAT, ge::DT_FLOAT16}}, | |||||
| {ge::DT_INT64, {ge::DT_INT32}}}; | |||||
| // key:src datatype, value:dst datatype | |||||
| {ge::DT_FLOAT, {ge::DT_FLOAT16, ge::DT_FLOAT}}, | |||||
| {ge::DT_BOOL, {ge::DT_INT32}}, | |||||
| {ge::DT_FLOAT16, {ge::DT_FLOAT, ge::DT_FLOAT16}}, | |||||
| {ge::DT_INT64, {ge::DT_INT32}}}; | |||||
| std::map<ge::DataType, std::vector<ge::DataType>> g_reverse_translatable_data_type = { | std::map<ge::DataType, std::vector<ge::DataType>> g_reverse_translatable_data_type = { | ||||
| // key:dst datatype,value:src datatype | |||||
| {ge::DT_FLOAT16, {ge::DT_FLOAT, ge::DT_FLOAT16}}, | |||||
| {ge::DT_INT32, {ge::DT_BOOL, ge::DT_INT64}}, | |||||
| {ge::DT_FLOAT, {ge::DT_FLOAT16, ge::DT_FLOAT}}}; | |||||
| // key:dst datatype,value:src datatype | |||||
| {ge::DT_FLOAT16, {ge::DT_FLOAT, ge::DT_FLOAT16}}, | |||||
| {ge::DT_INT32, {ge::DT_BOOL, ge::DT_INT64}}, | |||||
| {ge::DT_FLOAT, {ge::DT_FLOAT16, ge::DT_FLOAT}}}; | |||||
| std::map<ge::DataType, ge::proto::DataType> g_dump_data_type_map = { | std::map<ge::DataType, ge::proto::DataType> g_dump_data_type_map = { | ||||
| // key:ge datatype,value:proto datatype | |||||
| {ge::DT_UNDEFINED, ge::proto::DT_UNDEFINED}, | |||||
| {ge::DT_FLOAT, ge::proto::DT_FLOAT}, | |||||
| {ge::DT_FLOAT16, ge::proto::DT_FLOAT16}, | |||||
| {ge::DT_INT8, ge::proto::DT_INT8}, | |||||
| {ge::DT_UINT8, ge::proto::DT_UINT8}, | |||||
| {ge::DT_INT16, ge::proto::DT_INT16}, | |||||
| {ge::DT_UINT16, ge::proto::DT_UINT16}, | |||||
| {ge::DT_INT32, ge::proto::DT_INT32}, | |||||
| {ge::DT_INT64, ge::proto::DT_INT64}, | |||||
| {ge::DT_UINT32, ge::proto::DT_UINT32}, | |||||
| {ge::DT_UINT64, ge::proto::DT_UINT64}, | |||||
| {ge::DT_BOOL, ge::proto::DT_BOOL}, | |||||
| {ge::DT_DOUBLE, ge::proto::DT_DOUBLE}, | |||||
| {ge::DT_DUAL, ge::proto::DT_DUAL}, | |||||
| {ge::DT_DUAL_SUB_INT8, ge::proto::DT_DUAL_SUB_INT8}, | |||||
| {ge::DT_DUAL_SUB_UINT8, ge::proto::DT_DUAL_SUB_UINT8}, | |||||
| {ge::DT_COMPLEX64, ge::proto::DT_COMPLEX64}, | |||||
| {ge::DT_COMPLEX128, ge::proto::DT_COMPLEX128}, | |||||
| {ge::DT_QINT8, ge::proto::DT_QINT8}, | |||||
| {ge::DT_QINT16, ge::proto::DT_QINT16}, | |||||
| {ge::DT_QINT32, ge::proto::DT_QINT32}, | |||||
| {ge::DT_QUINT8, ge::proto::DT_QUINT8}, | |||||
| {ge::DT_QUINT16, ge::proto::DT_QUINT16}, | |||||
| {ge::DT_RESOURCE, ge::proto::DT_RESOURCE}, | |||||
| {ge::DT_STRING_REF, ge::proto::DT_STRING_REF}, | |||||
| {ge::DT_STRING, ge::proto::DT_STRING}, | |||||
| // key:ge datatype,value:proto datatype | |||||
| {ge::DT_UNDEFINED, ge::proto::DT_UNDEFINED}, | |||||
| {ge::DT_FLOAT, ge::proto::DT_FLOAT}, | |||||
| {ge::DT_FLOAT16, ge::proto::DT_FLOAT16}, | |||||
| {ge::DT_INT8, ge::proto::DT_INT8}, | |||||
| {ge::DT_UINT8, ge::proto::DT_UINT8}, | |||||
| {ge::DT_INT16, ge::proto::DT_INT16}, | |||||
| {ge::DT_UINT16, ge::proto::DT_UINT16}, | |||||
| {ge::DT_INT32, ge::proto::DT_INT32}, | |||||
| {ge::DT_INT64, ge::proto::DT_INT64}, | |||||
| {ge::DT_UINT32, ge::proto::DT_UINT32}, | |||||
| {ge::DT_UINT64, ge::proto::DT_UINT64}, | |||||
| {ge::DT_BOOL, ge::proto::DT_BOOL}, | |||||
| {ge::DT_DOUBLE, ge::proto::DT_DOUBLE}, | |||||
| {ge::DT_DUAL, ge::proto::DT_DUAL}, | |||||
| {ge::DT_DUAL_SUB_INT8, ge::proto::DT_DUAL_SUB_INT8}, | |||||
| {ge::DT_DUAL_SUB_UINT8, ge::proto::DT_DUAL_SUB_UINT8}, | |||||
| {ge::DT_COMPLEX64, ge::proto::DT_COMPLEX64}, | |||||
| {ge::DT_COMPLEX128, ge::proto::DT_COMPLEX128}, | |||||
| {ge::DT_QINT8, ge::proto::DT_QINT8}, | |||||
| {ge::DT_QINT16, ge::proto::DT_QINT16}, | |||||
| {ge::DT_QINT32, ge::proto::DT_QINT32}, | |||||
| {ge::DT_QUINT8, ge::proto::DT_QUINT8}, | |||||
| {ge::DT_QUINT16, ge::proto::DT_QUINT16}, | |||||
| {ge::DT_RESOURCE, ge::proto::DT_RESOURCE}, | |||||
| {ge::DT_STRING_REF, ge::proto::DT_STRING_REF}, | |||||
| {ge::DT_STRING, ge::proto::DT_STRING}, | |||||
| }; | }; | ||||
| } // namespace | } // namespace | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -37,10 +37,10 @@ static const int32_t kGeSizeUint16 = sizeof(uint16_t); | |||||
| static const int32_t kGeSizeUint32 = sizeof(uint32_t); | static const int32_t kGeSizeUint32 = sizeof(uint32_t); | ||||
| static std::map<ge::DataType, int32_t> CONST_OPDATA_TYPE_SIZE_MAP = { | static std::map<ge::DataType, int32_t> CONST_OPDATA_TYPE_SIZE_MAP = { | ||||
| {ge::DT_FLOAT, kGeSizeFloat}, {ge::DT_FLOAT16, kGeSizeHalfFloat}, {ge::DT_INT8, kGeSizeInt8}, | |||||
| {ge::DT_INT16, kGeSizeInt16}, {ge::DT_INT32, kGeSizeInt32}, {ge::DT_INT64, kGeSizeInt64}, | |||||
| {ge::DT_UINT8, kGeSizeUint8}, {ge::DT_UINT16, kGeSizeUint16}, {ge::DT_UINT32, kGeSizeUint32}, | |||||
| {ge::DT_UINT64, kGeSizeUint64}, {ge::DT_DOUBLE, kGeSizeDouble}, {ge::DT_BOOL, kGeSizeBool}}; | |||||
| {ge::DT_FLOAT, kGeSizeFloat}, {ge::DT_FLOAT16, kGeSizeHalfFloat}, {ge::DT_INT8, kGeSizeInt8}, | |||||
| {ge::DT_INT16, kGeSizeInt16}, {ge::DT_INT32, kGeSizeInt32}, {ge::DT_INT64, kGeSizeInt64}, | |||||
| {ge::DT_UINT8, kGeSizeUint8}, {ge::DT_UINT16, kGeSizeUint16}, {ge::DT_UINT32, kGeSizeUint32}, | |||||
| {ge::DT_UINT64, kGeSizeUint64}, {ge::DT_DOUBLE, kGeSizeDouble}, {ge::DT_BOOL, kGeSizeBool}}; | |||||
| class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY DataTypeUtil { | class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY DataTypeUtil { | ||||
| public: | public: | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -45,8 +45,8 @@ std::string OpTilingManager::GetPath() { | |||||
| if (opp_path_env != nullptr) { | if (opp_path_env != nullptr) { | ||||
| char resolved_path[PATH_MAX]; | char resolved_path[PATH_MAX]; | ||||
| if (realpath(opp_path_env, resolved_path) == NULL) { | if (realpath(opp_path_env, resolved_path) == NULL) { | ||||
| ErrorManager::GetInstance().ATCReportErrMessage( | |||||
| "E19024", {"env", "value", "situation"}, {"ASCEND_OPP_PATH", opp_path_env, "loading the tiling lib"}); | |||||
| ErrorManager::GetInstance().ATCReportErrMessage("E19024", {"env", "value", "situation"}, | |||||
| {"ASCEND_OPP_PATH", opp_path_env, "loading the tiling lib"}); | |||||
| GELOGE(PARAM_INVALID, "Failed load tiling lib as env 'ASCEND_OPP_PATH'[%s] is invalid path.", opp_path_env); | GELOGE(PARAM_INVALID, "Failed load tiling lib as env 'ASCEND_OPP_PATH'[%s] is invalid path.", opp_path_env); | ||||
| return std::string(); | return std::string(); | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -36,4 +36,3 @@ class OpTilingManager { | |||||
| } // namespace ge | } // namespace ge | ||||
| #endif // GE_COMMON_GE_OP_TILING_MANAGER_H_ | #endif // GE_COMMON_GE_OP_TILING_MANAGER_H_ | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -93,13 +93,15 @@ Status PluginManager::LoadSo(const string &path, const vector<string> &func_chec | |||||
| std::vector<std::string> path_vec; | std::vector<std::string> path_vec; | ||||
| SplitPath(path, path_vec); | SplitPath(path, path_vec); | ||||
| for (const auto &single_path : path_vec) { | for (const auto &single_path : path_vec) { | ||||
| GE_IF_BOOL_EXEC(single_path.length() >= PATH_MAX, GELOGE(GE_PLGMGR_PATH_INVALID, | |||||
| "The shared library file path is too long!"); | |||||
| GE_IF_BOOL_EXEC(single_path.length() >= PATH_MAX, | |||||
| GELOGE(GE_PLGMGR_PATH_INVALID, "The shared library file path is too long!"); | |||||
| continue); | continue); | ||||
| // load break when number of loaded so reach maximum | // load break when number of loaded so reach maximum | ||||
| if (num_of_loaded_so >= kMaxNumOfSo) { | if (num_of_loaded_so >= kMaxNumOfSo) { | ||||
| GELOGW("The number of dynamic libraries loaded exceeds the kMaxNumOfSo," | |||||
| " and only the first %d shared libraries will be loaded.", kMaxNumOfSo); | |||||
| GELOGW( | |||||
| "The number of dynamic libraries loaded exceeds the kMaxNumOfSo," | |||||
| " and only the first %d shared libraries will be loaded.", | |||||
| kMaxNumOfSo); | |||||
| break; | break; | ||||
| } | } | ||||
| @@ -180,9 +182,9 @@ Status PluginManager::ValidateSo(const string &file_path, int64_t size_of_loaded | |||||
| // load continue if the total size of so reaches maximum when it is loaded | // load continue if the total size of so reaches maximum when it is loaded | ||||
| if (size_of_loaded_so + file_size > kMaxSizeOfLoadedSo) { | if (size_of_loaded_so + file_size > kMaxSizeOfLoadedSo) { | ||||
| GELOGW( | GELOGW( | ||||
| "%s is skipped because the size of loaded share library reaches maximum if it is loaded! " | |||||
| "(size: %ldB, size of loaded share library: %ldB, maximum: %dB)", | |||||
| file_path.c_str(), file_size, size_of_loaded_so, kMaxSizeOfLoadedSo); | |||||
| "%s is skipped because the size of loaded share library reaches maximum if it is loaded! " | |||||
| "(size: %ldB, size of loaded share library: %ldB, maximum: %dB)", | |||||
| file_path.c_str(), file_size, size_of_loaded_so, kMaxSizeOfLoadedSo); | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| @@ -229,8 +231,10 @@ Status PluginManager::Load(const string &path, const vector<string> &func_check_ | |||||
| // load break when number of loaded so reach maximum | // load break when number of loaded so reach maximum | ||||
| if (num_of_loaded_so >= kMaxNumOfSo) { | if (num_of_loaded_so >= kMaxNumOfSo) { | ||||
| GELOGW("The number of dynamic libraries loaded exceeds the kMaxNumOfSo," | |||||
| " and only the first %d shared libraries will be loaded.", kMaxNumOfSo); | |||||
| GELOGW( | |||||
| "The number of dynamic libraries loaded exceeds the kMaxNumOfSo," | |||||
| " and only the first %d shared libraries will be loaded.", | |||||
| kMaxNumOfSo); | |||||
| break; | break; | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -94,6 +94,13 @@ void TBEPluginManager::ProcessSoFullName(vector<string> &file_list, string &caff | |||||
| full_name.compare(full_name.size() - caffe_parser_so_suff.size(), caffe_parser_so_suff.size(), | full_name.compare(full_name.size() - caffe_parser_so_suff.size(), caffe_parser_so_suff.size(), | ||||
| caffe_parser_so_suff) == 0) { | caffe_parser_so_suff) == 0) { | ||||
| caffe_parser_path = full_name; | caffe_parser_path = full_name; | ||||
| } else if ((full_name.size() >= aicpu_so_suff.size() && | |||||
| full_name.compare(full_name.size() - aicpu_so_suff.size(), aicpu_so_suff.size(), aicpu_so_suff) == 0) || | |||||
| (full_name.size() >= aicpu_host_so_suff.size() && | |||||
| full_name.compare(full_name.size() - aicpu_host_so_suff.size(), aicpu_host_so_suff.size(), | |||||
| aicpu_host_so_suff) == 0)) { | |||||
| // aicpu so, Put the file path into the omgcontext and save into the model in the builder stage. | |||||
| domi::GetContext().aicpu_op_run_paths.push_back(full_name); | |||||
| } else { | } else { | ||||
| // Save parser so path into file_list vector | // Save parser so path into file_list vector | ||||
| file_list.push_back(full_name); | file_list.push_back(full_name); | ||||
| @@ -186,8 +193,8 @@ void TBEPluginManager::LoadCustomOpLib() { | |||||
| } | } | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY | |||||
| void TBEPluginManager::LoadPluginSo(const std::map<string, string> &options) { | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void TBEPluginManager::LoadPluginSo( | |||||
| const std::map<string, string> &options) { | |||||
| vector<string> file_list; | vector<string> file_list; | ||||
| string caffe_parser_path; | string caffe_parser_path; | ||||
| std::string plugin_path; | std::string plugin_path; | ||||
| @@ -223,10 +230,39 @@ void TBEPluginManager::LoadPluginSo(const std::map<string, string> &options) { | |||||
| } | } | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY | |||||
| void TBEPluginManager::InitPreparation(const std::map<string, string> &options) { | |||||
| Status TBEPluginManager::CheckCustomAiCpuOpLib() { | |||||
| std::vector<std::string> vec_op_type; | |||||
| domi::OpRegistry::Instance()->GetOpTypeByImplyType(vec_op_type, domi::ImplyType::CUSTOM); | |||||
| for (size_t i = 0; i < vec_op_type.size(); i++) { | |||||
| bool aicpu_so_exist = false; | |||||
| std::string ai_cpu_so_name = "lib" + vec_op_type[i] + "_aicpu.so"; | |||||
| for (size_t j = 0; j < domi::GetContext().aicpu_op_run_paths.size(); j++) { | |||||
| string bin_file_path = domi::GetContext().aicpu_op_run_paths[j]; | |||||
| if (bin_file_path.size() >= ai_cpu_so_name.size() && | |||||
| bin_file_path.compare(bin_file_path.size() - ai_cpu_so_name.size(), ai_cpu_so_name.size(), ai_cpu_so_name) == | |||||
| 0) { | |||||
| aicpu_so_exist = true; | |||||
| break; | |||||
| } | |||||
| } | |||||
| if (!aicpu_so_exist) { | |||||
| GELOGE(FAILED, "Can't find aicpu run so(%s), please check the plugin path!", ai_cpu_so_name.c_str()); | |||||
| return FAILED; | |||||
| } | |||||
| } | |||||
| return SUCCESS; | |||||
| } | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void TBEPluginManager::InitPreparation( | |||||
| const std::map<string, string> &options) { | |||||
| options_.insert(options.begin(), options.end()); | options_.insert(options.begin(), options.end()); | ||||
| // Load TBE plugin | // Load TBE plugin | ||||
| TBEPluginManager::Instance().LoadCustomOpLib(); | TBEPluginManager::Instance().LoadCustomOpLib(); | ||||
| Status ret = CheckCustomAiCpuOpLib(); | |||||
| if (ret != SUCCESS) { | |||||
| GELOGE(ret, "Check custom aicpu run so failed!"); | |||||
| return; | |||||
| } | |||||
| } | } | ||||
| } // namespace ge | } // namespace ge | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -32,23 +32,23 @@ | |||||
| namespace ge { | namespace ge { | ||||
| using SoHandlesVec = std::vector<void *>; | using SoHandlesVec = std::vector<void *>; | ||||
| using std::vector; | |||||
| using std::string; | |||||
| using std::map; | |||||
| using std::function; | using std::function; | ||||
| using std::map; | |||||
| using std::string; | |||||
| using std::vector; | |||||
| class TBEPluginManager { | class TBEPluginManager { | ||||
| public: | public: | ||||
| Status Finalize(); | Status Finalize(); | ||||
| // Get TBEPluginManager singleton instance | // Get TBEPluginManager singleton instance | ||||
| static TBEPluginManager& Instance(); | |||||
| static TBEPluginManager &Instance(); | |||||
| static string GetPath(); | static string GetPath(); | ||||
| static void InitPreparation(const std::map<string, string> &options); | static void InitPreparation(const std::map<string, string> &options); | ||||
| void LoadPluginSo(const std::map< string, string> &options); | |||||
| void LoadPluginSo(const std::map<string, string> &options); | |||||
| private: | private: | ||||
| TBEPluginManager() = default; | TBEPluginManager() = default; | ||||
| @@ -62,6 +62,7 @@ class TBEPluginManager { | |||||
| static void GetPluginSoFileList(const string &path, vector<string> &file_list, string &caffe_parser_path); | static void GetPluginSoFileList(const string &path, vector<string> &file_list, string &caffe_parser_path); | ||||
| static void GetCustomOpPath(std::string &customop_path); | static void GetCustomOpPath(std::string &customop_path); | ||||
| void LoadCustomOpLib(); | void LoadCustomOpLib(); | ||||
| static Status CheckCustomAiCpuOpLib(); | |||||
| SoHandlesVec handles_vec_; | SoHandlesVec handles_vec_; | ||||
| static std::map<string, string> options_; | static std::map<string, string> options_; | ||||
| @@ -71,10 +71,7 @@ GE_COMMON_LOCAL_C_INCLUDES := \ | |||||
| $(TOPDIR)third_party/openssl/include/x86/include \ | $(TOPDIR)third_party/openssl/include/x86/include \ | ||||
| $(TOPDIR)framework/domi \ | $(TOPDIR)framework/domi \ | ||||
| $(TOPDIR)framework/domi/common \ | $(TOPDIR)framework/domi/common \ | ||||
| $(TOPDIR)framework/domi/common/op \ | |||||
| $(TOPDIR)graphengine/ge \ | |||||
| $(TOPDIR)graphengine/ge/common \ | |||||
| $(TOPDIR)graphengine/ge/common/op \ | |||||
| $(TOPDIR)framework/domi/common/op | |||||
| #compile host libge_common | #compile host libge_common | ||||
| include $(CLEAR_VARS) | include $(CLEAR_VARS) | ||||
| @@ -1007,9 +1007,10 @@ Status ModelCacheHelper::RecoverVarAddrAndTensorDesc(const Json &json) const { | |||||
| return PARAM_INVALID; | return PARAM_INVALID; | ||||
| } | } | ||||
| // Offset is needed by SaveVarVddr instead of logic address | // Offset is needed by SaveVarVddr instead of logic address | ||||
| ret = VarManager::Instance(session_id_)->SaveVarAddr(iter.first, tensor_addr_mgr.tensor_desc, | |||||
| reinterpret_cast<uint8_t *>(reinterpret_cast<uintptr_t>(offset)), | |||||
| tensor_addr_mgr.memory_type); | |||||
| ret = | |||||
| VarManager::Instance(session_id_) | |||||
| ->SaveVarAddr(iter.first, tensor_addr_mgr.tensor_desc, | |||||
| reinterpret_cast<uint8_t *>(reinterpret_cast<uintptr_t>(offset)), tensor_addr_mgr.memory_type); | |||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGW("Fail to recover VarAddr or TensorDesc of var[%s].", iter.first.c_str()); | GELOGW("Fail to recover VarAddr or TensorDesc of var[%s].", iter.first.c_str()); | ||||
| return ret; | return ret; | ||||
| @@ -1496,6 +1497,7 @@ Status ModelCacheHelper::ParseMemResourceFromJson(const Json &json, map<rtMemTyp | |||||
| } | } | ||||
| mem_resource.clear(); | mem_resource.clear(); | ||||
| for (const Json &mem_resource_json : json) { | for (const Json &mem_resource_json : json) { | ||||
| MemResource var_addr_mgr; | |||||
| try { | try { | ||||
| rtMemType_t mem_type = mem_resource_json[kMemType].get<rtMemType_t>(); | rtMemType_t mem_type = mem_resource_json[kMemType].get<rtMemType_t>(); | ||||
| uint64_t var_mem_size = mem_resource_json[kVarMemSize].get<int64_t>(); | uint64_t var_mem_size = mem_resource_json[kVarMemSize].get<int64_t>(); | ||||
| @@ -42,7 +42,7 @@ class ModelCacheHelper { | |||||
| ModelCacheHelper(uint64_t session_id, uint32_t graph_id, ComputeGraphPtr &compute_graph); | ModelCacheHelper(uint64_t session_id, uint32_t graph_id, ComputeGraphPtr &compute_graph); | ||||
| ~ModelCacheHelper(); | ~ModelCacheHelper(); | ||||
| Status SaveCacheInfoToCache () const; | |||||
| Status SaveCacheInfoToCache() const; | |||||
| Status SaveVarManagerToCache(bool before_build) const; | Status SaveVarManagerToCache(bool before_build) const; | ||||
| Status SaveOmModelToCache(const GeModelPtr &ge_model) const; | Status SaveOmModelToCache(const GeModelPtr &ge_model) const; | ||||
| bool IsModelCacheHit() const; | bool IsModelCacheHit() const; | ||||
| @@ -97,7 +97,7 @@ class ModelCacheHelper { | |||||
| std::vector<std::pair<std::string, VarAddrMgr>> &var_addr_mgr_vector, | std::vector<std::pair<std::string, VarAddrMgr>> &var_addr_mgr_vector, | ||||
| std::unordered_set<uint64_t> &var_offset_set); | std::unordered_set<uint64_t> &var_offset_set); | ||||
| static Status ParseCurVarTensorDescMapFromJson( | static Status ParseCurVarTensorDescMapFromJson( | ||||
| const Json &json, std::unordered_map<std::string, ge::GeTensorDesc> &cur_var_tensor_desc_map); | |||||
| const Json &json, std::unordered_map<std::string, ge::GeTensorDesc> &cur_var_tensor_desc_map); | |||||
| static Status ParseTransRoadsFromJson(const Json &json, | static Status ParseTransRoadsFromJson(const Json &json, | ||||
| std::unordered_map<std::string, std::vector<TransNodeInfo>> &trans_roads); | std::unordered_map<std::string, std::vector<TransNodeInfo>> &trans_roads); | ||||
| static Status ParseChangedGraphIdFromJson(const Json &json, | static Status ParseChangedGraphIdFromJson(const Json &json, | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -27,14 +27,13 @@ | |||||
| #include "graph/utils/attr_utils.h" | #include "graph/utils/attr_utils.h" | ||||
| #include "graph/utils/graph_utils.h" | #include "graph/utils/graph_utils.h" | ||||
| using std::string; | |||||
| using domi::ModelTaskDef; | using domi::ModelTaskDef; | ||||
| using std::string; | |||||
| namespace { | namespace { | ||||
| const int64_t kOriginalOmPartitionNum = 1; | const int64_t kOriginalOmPartitionNum = 1; | ||||
| } | } | ||||
| namespace ge { | namespace ge { | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelHelper::~ModelHelper() { (void)ReleaseLocalModelData(); } | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelHelper::~ModelHelper() { (void)ReleaseLocalModelData(); } | ||||
| @@ -56,7 +55,7 @@ Status ModelHelper::SaveModelPartition(std::shared_ptr<OmFileSaveHelper> &om_fil | |||||
| item = "aicpu kernels"; | item = "aicpu kernels"; | ||||
| } | } | ||||
| ErrorManager::GetInstance().ATCReportErrMessage("E19023", {"size", "item", "maxsize"}, | ErrorManager::GetInstance().ATCReportErrMessage("E19023", {"size", "item", "maxsize"}, | ||||
| {std::to_string(size), item, std::to_string(UINT32_MAX)}); | |||||
| {std::to_string(size), item, std::to_string(UINT32_MAX)}); | |||||
| } | } | ||||
| return PARAM_INVALID; | return PARAM_INVALID; | ||||
| } | } | ||||
| @@ -78,7 +77,7 @@ Status ModelHelper::SaveModelPartition(std::shared_ptr<OmFileSaveHelper> &om_fil | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmModel(const GeModelPtr &ge_model, | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmModel(const GeModelPtr &ge_model, | ||||
| const SaveParam &save_param, | const SaveParam &save_param, | ||||
| const std::string &output_file, | const std::string &output_file, | ||||
| ModelBufferData& model) { | |||||
| ModelBufferData &model) { | |||||
| if (output_file.empty()) { | if (output_file.empty()) { | ||||
| GELOGE(FAILED, "GraphBuilder SaveModel received invalid file name prefix"); | GELOGE(FAILED, "GraphBuilder SaveModel received invalid file name prefix"); | ||||
| return FAILED; | return FAILED; | ||||
| @@ -110,19 +109,17 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmMod | |||||
| GELOGI("WEIGHTS_DATA size is %zu, %p", ge_model_weight.GetSize(), ge_model_weight.GetData()); | GELOGI("WEIGHTS_DATA size is %zu, %p", ge_model_weight.GetSize(), ge_model_weight.GetData()); | ||||
| // weight is not necessary | // weight is not necessary | ||||
| if (ge_model_weight.GetSize() > 0) { | if (ge_model_weight.GetSize() > 0) { | ||||
| GE_CHK_STATUS_RET(SaveModelPartition(om_file_save_helper, | |||||
| ModelPartitionType::WEIGHTS_DATA, | |||||
| ge_model_weight.GetData(), | |||||
| ge_model_weight.GetSize()), "Add weight partition failed"); | |||||
| GE_CHK_STATUS_RET(SaveModelPartition(om_file_save_helper, ModelPartitionType::WEIGHTS_DATA, | |||||
| ge_model_weight.GetData(), ge_model_weight.GetSize()), | |||||
| "Add weight partition failed"); | |||||
| } | } | ||||
| TBEKernelStore tbe_kernel_store = ge_model->GetTBEKernelStore(); | TBEKernelStore tbe_kernel_store = ge_model->GetTBEKernelStore(); | ||||
| GELOGI("TBE_KERNELS size is %zu", tbe_kernel_store.DataSize()); | GELOGI("TBE_KERNELS size is %zu", tbe_kernel_store.DataSize()); | ||||
| if (tbe_kernel_store.DataSize() > 0) { | if (tbe_kernel_store.DataSize() > 0) { | ||||
| GE_CHK_STATUS_RET(SaveModelPartition(om_file_save_helper, | |||||
| ModelPartitionType::TBE_KERNELS, | |||||
| tbe_kernel_store.Data(), | |||||
| tbe_kernel_store.DataSize()), "Add tbe kernel partition failed"); | |||||
| GE_CHK_STATUS_RET(SaveModelPartition(om_file_save_helper, ModelPartitionType::TBE_KERNELS, tbe_kernel_store.Data(), | |||||
| tbe_kernel_store.DataSize()), | |||||
| "Add tbe kernel partition failed"); | |||||
| } | } | ||||
| // no need to check value, DATA->NetOutput | // no need to check value, DATA->NetOutput | ||||
| @@ -131,10 +128,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmMod | |||||
| CustAICPUKernelStore cust_aicpu_kernel_store = ge_model->GetCustAICPUKernelStore(); | CustAICPUKernelStore cust_aicpu_kernel_store = ge_model->GetCustAICPUKernelStore(); | ||||
| GELOGI("cust aicpu kernels size is %zu", cust_aicpu_kernel_store.DataSize()); | GELOGI("cust aicpu kernels size is %zu", cust_aicpu_kernel_store.DataSize()); | ||||
| if (cust_aicpu_kernel_store.DataSize() > 0) { | if (cust_aicpu_kernel_store.DataSize() > 0) { | ||||
| GE_CHK_STATUS_RET(SaveModelPartition(om_file_save_helper, | |||||
| ModelPartitionType::CUST_AICPU_KERNELS, | |||||
| cust_aicpu_kernel_store.Data(), | |||||
| cust_aicpu_kernel_store.DataSize()), | |||||
| GE_CHK_STATUS_RET(SaveModelPartition(om_file_save_helper, ModelPartitionType::CUST_AICPU_KERNELS, | |||||
| cust_aicpu_kernel_store.Data(), cust_aicpu_kernel_store.DataSize()), | |||||
| "Add cust aicpu kernel partition failed"); | "Add cust aicpu kernel partition failed"); | ||||
| } | } | ||||
| @@ -459,8 +454,8 @@ Status ModelHelper::ReleaseLocalModelData() noexcept { | |||||
| return result; | return result; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::GetBaseNameFromFileName( | |||||
| const string &file_name, string &base_name) { | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::GetBaseNameFromFileName(const string &file_name, | |||||
| string &base_name) { | |||||
| GELOGD("Get base_name from file, file_name:%s", file_name.c_str()); | GELOGD("Get base_name from file, file_name:%s", file_name.c_str()); | ||||
| GE_CHK_BOOL_EXEC_WARN(!file_name.empty(), return FAILED, "File path may not valid, check params --output"); | GE_CHK_BOOL_EXEC_WARN(!file_name.empty(), return FAILED, "File path may not valid, check params --output"); | ||||
| size_t start_position = 0; | size_t start_position = 0; | ||||
| @@ -475,8 +470,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::GetBaseName | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::GetModelNameFromMergedGraphName( | |||||
| const string &graph_name, string &model_name) { | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status | |||||
| ModelHelper::GetModelNameFromMergedGraphName(const string &graph_name, string &model_name) { | |||||
| GELOGD("Get model_name from graph_name, graph_name:%s", graph_name.c_str()); | GELOGD("Get model_name from graph_name, graph_name:%s", graph_name.c_str()); | ||||
| // this can only be used after merged graph(graph name will be append with "_x", x is index); | // this can only be used after merged graph(graph name will be append with "_x", x is index); | ||||
| GE_CHK_BOOL_EXEC_WARN(!graph_name.empty(), return FAILED, "File path may not valid, check params --output"); | GE_CHK_BOOL_EXEC_WARN(!graph_name.empty(), return FAILED, "File path may not valid, check params --output"); | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -89,8 +89,8 @@ Status OmFileLoadHelper::CheckModelValid(const ge::ModelData &model) const { | |||||
| // Model length too small | // Model length too small | ||||
| if (model.model_len < (sizeof(ModelFileHeader) + sizeof(ModelPartitionTable))) { | if (model.model_len < (sizeof(ModelFileHeader) + sizeof(ModelPartitionTable))) { | ||||
| GELOGE(PARAM_INVALID, | GELOGE(PARAM_INVALID, | ||||
| "Invalid model. length[%u] < sizeof(ModelFileHeader)[%zu] + sizeof(ModelPartitionTable)[%zu].", | |||||
| model.model_len, sizeof(ModelFileHeader), sizeof(ModelPartitionTable)); | |||||
| "Invalid model. length[%u] < sizeof(ModelFileHeader)[%zu] + sizeof(ModelPartitionTable)[%zu].", | |||||
| model.model_len, sizeof(ModelFileHeader), sizeof(ModelPartitionTable)); | |||||
| return PARAM_INVALID; | return PARAM_INVALID; | ||||
| } | } | ||||
| @@ -101,7 +101,7 @@ Status OmFileLoadHelper::CheckModelValid(const ge::ModelData &model) const { | |||||
| (MODEL_FILE_MAGIC_NUM != model_header->magic)) { | (MODEL_FILE_MAGIC_NUM != model_header->magic)) { | ||||
| GELOGE(PARAM_INVALID, | GELOGE(PARAM_INVALID, | ||||
| "Invalid model. file_header->length[%u] + sizeof(ModelFileHeader)[%zu] != model->model_len[%u] || " | "Invalid model. file_header->length[%u] + sizeof(ModelFileHeader)[%zu] != model->model_len[%u] || " | ||||
| "MODEL_FILE_MAGIC_NUM[%u] != file_header->magic[%u]", | |||||
| "MODEL_FILE_MAGIC_NUM[%u] != file_header->magic[%u]", | |||||
| model_header->length, sizeof(ModelFileHeader), model.model_len, MODEL_FILE_MAGIC_NUM, model_header->magic); | model_header->length, sizeof(ModelFileHeader), model.model_len, MODEL_FILE_MAGIC_NUM, model_header->magic); | ||||
| return PARAM_INVALID; | return PARAM_INVALID; | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -51,8 +51,8 @@ bool KernelStore::Build() { | |||||
| kernel_head.name_len = static_cast<uint32_t>(kernel->GetName().length()); | kernel_head.name_len = static_cast<uint32_t>(kernel->GetName().length()); | ||||
| kernel_head.bin_len = static_cast<uint32_t>(kernel->GetBinDataSize()); | kernel_head.bin_len = static_cast<uint32_t>(kernel->GetBinDataSize()); | ||||
| GELOGI("get kernel bin name %s, addr %p, size %u", | |||||
| kernel->GetName().c_str(), kernel->GetBinData(), kernel->GetBinDataSize()); | |||||
| GELOGI("get kernel bin name %s, addr %p, size %u", kernel->GetName().c_str(), kernel->GetBinData(), | |||||
| kernel->GetBinDataSize()); | |||||
| mem_ret = memcpy_s(next_buffer, remain_len, &kernel_head, sizeof(kernel_head)); | mem_ret = memcpy_s(next_buffer, remain_len, &kernel_head, sizeof(kernel_head)); | ||||
| GE_CHK_BOOL_EXEC_NOLOG(mem_ret == EOK, return false); | GE_CHK_BOOL_EXEC_NOLOG(mem_ret == EOK, return false); | ||||
| next_buffer += sizeof(kernel_head); | next_buffer += sizeof(kernel_head); | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -612,295 +612,268 @@ inline Status CheckInt32DivOverflow(int32_t a, int32_t b) { | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| #define FMK_INT_ADDCHECK(a, b) \ | |||||
| if (ge::CheckIntAddOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int %d and %d addition can result in overflow!", static_cast<int>(a), \ | |||||
| static_cast<int>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_INT_ADDCHECK(a, b) \ | |||||
| if (ge::CheckIntAddOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int %d and %d addition can result in overflow!", static_cast<int>(a), static_cast<int>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_INT8_ADDCHECK(a, b) \ | |||||
| if (ge::CheckInt8AddOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int8 %d and %d addition can result in overflow!", static_cast<int8_t>(a), \ | |||||
| static_cast<int8_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_INT8_ADDCHECK(a, b) \ | |||||
| if (ge::CheckInt8AddOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int8 %d and %d addition can result in overflow!", static_cast<int8_t>(a), static_cast<int8_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_INT16_ADDCHECK(a, b) \ | |||||
| if (ge::CheckInt16AddOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int16 %d and %d addition can result in overflow!", static_cast<int16_t>(a), \ | |||||
| static_cast<int16_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_INT16_ADDCHECK(a, b) \ | |||||
| if (ge::CheckInt16AddOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int16 %d and %d addition can result in overflow!", static_cast<int16_t>(a), static_cast<int16_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_INT32_ADDCHECK(a, b) \ | |||||
| if (ge::CheckInt32AddOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int32 %d and %d addition can result in overflow!", static_cast<int32_t>(a), \ | |||||
| static_cast<int32_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_INT32_ADDCHECK(a, b) \ | |||||
| if (ge::CheckInt32AddOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int32 %d and %d addition can result in overflow!", static_cast<int32_t>(a), static_cast<int32_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_INT64_ADDCHECK(a, b) \ | |||||
| if (ge::CheckInt64AddOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int64 %ld and %ld addition can result in overflow!", static_cast<int64_t>(a), \ | |||||
| static_cast<int64_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_INT64_ADDCHECK(a, b) \ | |||||
| if (ge::CheckInt64AddOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int64 %ld and %ld addition can result in overflow!", static_cast<int64_t>(a), static_cast<int64_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_UINT8_ADDCHECK(a, b) \ | |||||
| if (ge::CheckUint8AddOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Uint8 %u and %u addition can result in overflow!", static_cast<uint8_t>(a), \ | |||||
| static_cast<uint8_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_UINT8_ADDCHECK(a, b) \ | |||||
| if (ge::CheckUint8AddOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Uint8 %u and %u addition can result in overflow!", static_cast<uint8_t>(a), static_cast<uint8_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_UINT16_ADDCHECK(a, b) \ | |||||
| if (ge::CheckUint16AddOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("UINT16 %u and %u addition can result in overflow!", static_cast<uint16_t>(a), \ | |||||
| static_cast<uint16_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_UINT16_ADDCHECK(a, b) \ | |||||
| if (ge::CheckUint16AddOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("UINT16 %u and %u addition can result in overflow!", static_cast<uint16_t>(a), static_cast<uint16_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_UINT32_ADDCHECK(a, b) \ | |||||
| if (ge::CheckUint32AddOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Uint32 %u and %u addition can result in overflow!", static_cast<uint32_t>(a), \ | |||||
| static_cast<uint32_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_UINT32_ADDCHECK(a, b) \ | |||||
| if (ge::CheckUint32AddOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Uint32 %u and %u addition can result in overflow!", static_cast<uint32_t>(a), static_cast<uint32_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_UINT64_ADDCHECK(a, b) \ | |||||
| if (ge::CheckUint64AddOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Uint64 %lu and %lu addition can result in overflow!", static_cast<uint64_t>(a), \ | |||||
| static_cast<uint64_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_UINT64_ADDCHECK(a, b) \ | |||||
| if (ge::CheckUint64AddOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Uint64 %lu and %lu addition can result in overflow!", static_cast<uint64_t>(a), static_cast<uint64_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_FP16_ADDCHECK(a, b) \ | |||||
| if (ge::CheckFp16AddOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Fp16 %f and %f addition can result in overflow!", static_cast<float>(a), \ | |||||
| static_cast<float>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_FP16_ADDCHECK(a, b) \ | |||||
| if (ge::CheckFp16AddOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Fp16 %f and %f addition can result in overflow!", static_cast<float>(a), static_cast<float>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_FLOAT_ADDCHECK(a, b) \ | |||||
| if (ge::CheckFloatAddOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Float %f and %f addition can result in overflow!", static_cast<float>(a), \ | |||||
| static_cast<float>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_FLOAT_ADDCHECK(a, b) \ | |||||
| if (ge::CheckFloatAddOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Float %f and %f addition can result in overflow!", static_cast<float>(a), static_cast<float>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_DOUBLE_ADDCHECK(a, b) \ | |||||
| if (ge::CheckDoubleAddOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Double %lf and %lf addition can result in overflow!", static_cast<double>(a), \ | |||||
| static_cast<double>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_DOUBLE_ADDCHECK(a, b) \ | |||||
| if (ge::CheckDoubleAddOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Double %lf and %lf addition can result in overflow!", static_cast<double>(a), static_cast<double>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_INT_SUBCHECK(a, b) \ | |||||
| if (ge::CheckIntSubOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int %d and %d subtraction can result in overflow!", static_cast<int>(a), \ | |||||
| static_cast<int>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_INT_SUBCHECK(a, b) \ | |||||
| if (ge::CheckIntSubOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int %d and %d subtraction can result in overflow!", static_cast<int>(a), static_cast<int>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_INT8_SUBCHECK(a, b) \ | |||||
| if (ge::CheckInt8SubOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int8 %d and %d subtraction can result in overflow!", static_cast<int8_t>(a), \ | |||||
| static_cast<int8_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_INT8_SUBCHECK(a, b) \ | |||||
| if (ge::CheckInt8SubOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int8 %d and %d subtraction can result in overflow!", static_cast<int8_t>(a), static_cast<int8_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_INT16_SUBCHECK(a, b) \ | |||||
| if (ge::CheckInt16SubOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int16 %d and %d subtraction can result in overflow!", static_cast<int16_t>(a), \ | |||||
| static_cast<int16_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_INT16_SUBCHECK(a, b) \ | |||||
| if (ge::CheckInt16SubOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int16 %d and %d subtraction can result in overflow!", static_cast<int16_t>(a), static_cast<int16_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_INT32_SUBCHECK(a, b) \ | |||||
| if (ge::CheckInt32SubOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int32 %d and %d subtraction can result in overflow!", static_cast<int32_t>(a), \ | |||||
| static_cast<int32_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_INT32_SUBCHECK(a, b) \ | |||||
| if (ge::CheckInt32SubOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int32 %d and %d subtraction can result in overflow!", static_cast<int32_t>(a), static_cast<int32_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_INT64_SUBCHECK(a, b) \ | |||||
| if (ge::CheckInt64SubOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int64 %ld and %ld subtraction can result in overflow!", static_cast<int64_t>(a), \ | |||||
| static_cast<int64_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_INT64_SUBCHECK(a, b) \ | |||||
| if (ge::CheckInt64SubOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int64 %ld and %ld subtraction can result in overflow!", static_cast<int64_t>(a), static_cast<int64_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_UINT8_SUBCHECK(a, b) \ | |||||
| if (ge::CheckUint8SubOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Uint8 %u and %u subtraction can result in overflow!", static_cast<uint8_t>(a), \ | |||||
| static_cast<uint8_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_UINT8_SUBCHECK(a, b) \ | |||||
| if (ge::CheckUint8SubOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Uint8 %u and %u subtraction can result in overflow!", static_cast<uint8_t>(a), static_cast<uint8_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_UINT16_SUBCHECK(a, b) \ | |||||
| if (ge::CheckUint16SubOverflow((a), (b)) != SUCCESS) { \ | |||||
| #define FMK_UINT16_SUBCHECK(a, b) \ | |||||
| if (ge::CheckUint16SubOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Uint16 %u and %u subtraction can result in overflow!", static_cast<uint16_t>(a), \ | GELOGW("Uint16 %u and %u subtraction can result in overflow!", static_cast<uint16_t>(a), \ | ||||
| static_cast<uint16_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| static_cast<uint16_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_UINT32_SUBCHECK(a, b) \ | |||||
| if (ge::CheckUint32SubOverflow((a), (b)) != SUCCESS) { \ | |||||
| #define FMK_UINT32_SUBCHECK(a, b) \ | |||||
| if (ge::CheckUint32SubOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Uint32 %u and %u subtraction can result in overflow!", static_cast<uint32_t>(a), \ | GELOGW("Uint32 %u and %u subtraction can result in overflow!", static_cast<uint32_t>(a), \ | ||||
| static_cast<uint32_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| static_cast<uint32_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_UINT64_SUBCHECK(a, b) \ | |||||
| if (ge::CheckUint64SubOverflow((a), (b)) != SUCCESS) { \ | |||||
| #define FMK_UINT64_SUBCHECK(a, b) \ | |||||
| if (ge::CheckUint64SubOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Uint64 %lu and %lu subtraction can result in overflow!", static_cast<uint64_t>(a), \ | GELOGW("Uint64 %lu and %lu subtraction can result in overflow!", static_cast<uint64_t>(a), \ | ||||
| static_cast<uint64_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| static_cast<uint64_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_FP16_SUBCHECK(a, b) \ | |||||
| if (ge::CheckFp16SubOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Fp16 %f and %f subtraction can result in overflow!", static_cast<float>(a), \ | |||||
| static_cast<float>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_FP16_SUBCHECK(a, b) \ | |||||
| if (ge::CheckFp16SubOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Fp16 %f and %f subtraction can result in overflow!", static_cast<float>(a), static_cast<float>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_FLOAT_SUBCHECK(a, b) \ | |||||
| if (ge::CheckFloatSubOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Float %f and %f subtraction can result in overflow!", static_cast<float>(a), \ | |||||
| static_cast<float>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_FLOAT_SUBCHECK(a, b) \ | |||||
| if (ge::CheckFloatSubOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Float %f and %f subtraction can result in overflow!", static_cast<float>(a), static_cast<float>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_DOUBLE_SUBCHECK(a, b) \ | |||||
| if (ge::CheckDoubleSubOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Double %lf and %lf subtraction can result in overflow!", static_cast<double>(a), \ | |||||
| static_cast<double>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_DOUBLE_SUBCHECK(a, b) \ | |||||
| if (ge::CheckDoubleSubOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Double %lf and %lf subtraction can result in overflow!", static_cast<double>(a), static_cast<double>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_INT_MULCHECK(a, b) \ | |||||
| if (ge::CheckIntMulOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int %d and %d multiplication can result in overflow!", static_cast<int>(a), \ | |||||
| static_cast<int>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_INT_MULCHECK(a, b) \ | |||||
| if (ge::CheckIntMulOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int %d and %d multiplication can result in overflow!", static_cast<int>(a), static_cast<int>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_INT8_MULCHECK(a, b) \ | |||||
| if (ge::CheckInt8MulOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int8 %d and %d multiplication can result in overflow!", static_cast<int8_t>(a), \ | |||||
| static_cast<int8_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_INT8_MULCHECK(a, b) \ | |||||
| if (ge::CheckInt8MulOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int8 %d and %d multiplication can result in overflow!", static_cast<int8_t>(a), static_cast<int8_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_INT16_MULCHECK(a, b) \ | |||||
| if (ge::CheckInt16MulOverflow((a), (b)) != SUCCESS) { \ | |||||
| #define FMK_INT16_MULCHECK(a, b) \ | |||||
| if (ge::CheckInt16MulOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int16 %d and %d multiplication can result in overflow!", static_cast<int16_t>(a), \ | GELOGW("Int16 %d and %d multiplication can result in overflow!", static_cast<int16_t>(a), \ | ||||
| static_cast<int16_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| static_cast<int16_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_INT32_MULCHECK(a, b) \ | |||||
| if (ge::CheckInt32MulOverflow((a), (b)) != SUCCESS) { \ | |||||
| #define FMK_INT32_MULCHECK(a, b) \ | |||||
| if (ge::CheckInt32MulOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int32 %d and %d multiplication can result in overflow!", static_cast<int32_t>(a), \ | GELOGW("Int32 %d and %d multiplication can result in overflow!", static_cast<int32_t>(a), \ | ||||
| static_cast<int32_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| static_cast<int32_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_INT64_MULCHECK(a, b) \ | |||||
| if (ge::Int64MulCheckOverflow((a), (b)) != SUCCESS) { \ | |||||
| #define FMK_INT64_MULCHECK(a, b) \ | |||||
| if (ge::Int64MulCheckOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int64 %ld and %ld multiplication can result in overflow!", static_cast<int64_t>(a), \ | GELOGW("Int64 %ld and %ld multiplication can result in overflow!", static_cast<int64_t>(a), \ | ||||
| static_cast<int64_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| static_cast<int64_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_UINT8_MULCHECK(a, b) \ | |||||
| if (ge::CheckUint8MulOverflow((a), (b)) != SUCCESS) { \ | |||||
| #define FMK_UINT8_MULCHECK(a, b) \ | |||||
| if (ge::CheckUint8MulOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Uint8 %u and %u multiplication can result in overflow!", static_cast<uint8_t>(a), \ | GELOGW("Uint8 %u and %u multiplication can result in overflow!", static_cast<uint8_t>(a), \ | ||||
| static_cast<uint8_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| static_cast<uint8_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_UINT16_MULCHECK(a, b) \ | |||||
| if (ge::CheckUint16MulOverflow((a), (b)) != SUCCESS) { \ | |||||
| #define FMK_UINT16_MULCHECK(a, b) \ | |||||
| if (ge::CheckUint16MulOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Uint16 %u and %u multiplication can result in overflow!", static_cast<uint16_t>(a), \ | GELOGW("Uint16 %u and %u multiplication can result in overflow!", static_cast<uint16_t>(a), \ | ||||
| static_cast<uint16_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| static_cast<uint16_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_UINT32_MULCHECK(a, b) \ | |||||
| if (ge::CheckUint32MulOverflow((a), (b)) != SUCCESS) { \ | |||||
| #define FMK_UINT32_MULCHECK(a, b) \ | |||||
| if (ge::CheckUint32MulOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Uint32 %u and %u multiplication can result in overflow!", static_cast<uint32_t>(a), \ | GELOGW("Uint32 %u and %u multiplication can result in overflow!", static_cast<uint32_t>(a), \ | ||||
| static_cast<uint32_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| static_cast<uint32_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_UINT64_MULCHECK(a, b) \ | |||||
| if (ge::CheckUint64MulOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Uint64 %lu and %lu multiplication can result in overflow!", static_cast<uint64_t>(a), \ | |||||
| static_cast<uint64_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_UINT64_MULCHECK(a, b) \ | |||||
| if (ge::CheckUint64MulOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Uint64 %lu and %lu multiplication can result in overflow!", static_cast<uint64_t>(a), \ | |||||
| static_cast<uint64_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_FP16_MULCHECK(a, b) \ | |||||
| if (ge::CheckFp16MulOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Fp16 %f and %f multiplication can result in overflow!", static_cast<float>(a), \ | |||||
| static_cast<float>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_FP16_MULCHECK(a, b) \ | |||||
| if (ge::CheckFp16MulOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Fp16 %f and %f multiplication can result in overflow!", static_cast<float>(a), static_cast<float>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_FLOAT_MULCHECK(a, b) \ | |||||
| if (ge::CheckFloatMulOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Float %f and %f multiplication can result in overflow!", static_cast<float>(a), \ | |||||
| static_cast<float>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_FLOAT_MULCHECK(a, b) \ | |||||
| if (ge::CheckFloatMulOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Float %f and %f multiplication can result in overflow!", static_cast<float>(a), static_cast<float>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_DOUBLE_MULCHECK(a, b) \ | |||||
| if (ge::CheckDoubleMulOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Double %lf and %lf multiplication can result in overflow!", static_cast<double>(a), \ | |||||
| static_cast<double>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_DOUBLE_MULCHECK(a, b) \ | |||||
| if (ge::CheckDoubleMulOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Double %lf and %lf multiplication can result in overflow!", static_cast<double>(a), \ | |||||
| static_cast<double>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_INT_DIVCHECK(a, b) \ | |||||
| if (CheckIntDivOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int %d and %d division can result in overflow!", static_cast<int>(a), \ | |||||
| static_cast<int>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_INT_DIVCHECK(a, b) \ | |||||
| if (CheckIntDivOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int %d and %d division can result in overflow!", static_cast<int>(a), static_cast<int>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_INT32_DIVCHECK(a, b) \ | |||||
| if (CheckInt32DivOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int32 %d and %d division can result in overflow!", static_cast<int32_t>(a), \ | |||||
| static_cast<int32_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_INT32_DIVCHECK(a, b) \ | |||||
| if (CheckInt32DivOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int32 %d and %d division can result in overflow!", static_cast<int32_t>(a), static_cast<int32_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_INT64_UINT32_MULCHECK(a, b) \ | |||||
| if (ge::CheckInt64Uint32MulOverflow((a), (b)) != SUCCESS) { \ | |||||
| #define FMK_INT64_UINT32_MULCHECK(a, b) \ | |||||
| if (ge::CheckInt64Uint32MulOverflow((a), (b)) != SUCCESS) { \ | |||||
| GELOGW("Int64 %ld and UINT32 %u multiplication can result in overflow!", static_cast<uint32_t>(a), \ | GELOGW("Int64 %ld and UINT32 %u multiplication can result in overflow!", static_cast<uint32_t>(a), \ | ||||
| static_cast<uint32_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| static_cast<uint32_t>(b)); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_FP16_ZEROCHECK(a) \ | |||||
| if (fabs(a) < DBL_EPSILON || a < 0) { \ | |||||
| GELOGW("Fp16 %f can not less than or equal to zero! ", a); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_FP16_ZEROCHECK(a) \ | |||||
| if (fabs(a) < DBL_EPSILON || a < 0) { \ | |||||
| GELOGW("Fp16 %f can not less than or equal to zero! ", a); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_FLOAT_ZEROCHECK(a) \ | |||||
| if (fabs(a) < FLT_EPSILON || a < 0) { \ | |||||
| GELOGW("Float %f can not less than or equal to zero! ", a); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_FLOAT_ZEROCHECK(a) \ | |||||
| if (fabs(a) < FLT_EPSILON || a < 0) { \ | |||||
| GELOGW("Float %f can not less than or equal to zero! ", a); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| #define FMK_DOUBLE_ZEROCHECK(a) \ | |||||
| if (fabs(a) < DBL_EPSILON || a < 0) { \ | |||||
| GELOGW("Double %lf can not less than or equal to zero! ", a); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| #define FMK_DOUBLE_ZEROCHECK(a) \ | |||||
| if (fabs(a) < DBL_EPSILON || a < 0) { \ | |||||
| GELOGW("Double %lf can not less than or equal to zero! ", a); \ | |||||
| return INTERNAL_ERROR; \ | |||||
| } | } | ||||
| } // namespace ge | } // namespace ge | ||||
| #endif // GE_COMMON_MATH_MATH_UTIL_H_ | #endif // GE_COMMON_MATH_MATH_UTIL_H_ | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -28,13 +28,13 @@ | |||||
| namespace ge { | namespace ge { | ||||
| /** | /** | ||||
| * @ingroup domi_calibration | |||||
| * @brief Initializes an input array to a specified value | |||||
| * @param [in] n array initialization length | |||||
| * @param [in] alpha initialization value | |||||
| * @param [out] output array to be initialized | |||||
| * @return Status | |||||
| */ | |||||
| * @ingroup domi_calibration | |||||
| * @brief Initializes an input array to a specified value | |||||
| * @param [in] n array initialization length | |||||
| * @param [in] alpha initialization value | |||||
| * @param [out] output array to be initialized | |||||
| * @return Status | |||||
| */ | |||||
| template <typename Dtype> | template <typename Dtype> | ||||
| Status NnSet(const int32_t n, const Dtype alpha, Dtype *output) { | Status NnSet(const int32_t n, const Dtype alpha, Dtype *output) { | ||||
| GE_CHECK_NOTNULL(output); | GE_CHECK_NOTNULL(output); | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -69,8 +69,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelSaver::SaveJsonToFi | |||||
| // Write data to file | // Write data to file | ||||
| mmSsize_t mmpa_ret = mmWrite(fd, const_cast<void *>((const void *)model_char), len); | mmSsize_t mmpa_ret = mmWrite(fd, const_cast<void *>((const void *)model_char), len); | ||||
| if (mmpa_ret == EN_ERROR || mmpa_ret == EN_INVALID_PARAM) { | if (mmpa_ret == EN_ERROR || mmpa_ret == EN_INVALID_PARAM) { | ||||
| ErrorManager::GetInstance().ATCReportErrMessage( | |||||
| "E19004", {"file", "errmsg"}, {file_path, strerror(errno)}); | |||||
| ErrorManager::GetInstance().ATCReportErrMessage("E19004", {"file", "errmsg"}, {file_path, strerror(errno)}); | |||||
| // Need to both print the error info of mmWrite and mmClose, so return ret after mmClose | // Need to both print the error info of mmWrite and mmClose, so return ret after mmClose | ||||
| GELOGE(FAILED, "Write to file failed. errno = %d, %s", mmpa_ret, strerror(errno)); | GELOGE(FAILED, "Write to file failed. errno = %d, %s", mmpa_ret, strerror(errno)); | ||||
| ret = FAILED; | ret = FAILED; | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -17,7 +17,6 @@ | |||||
| #include "framework/common/op/attr_value_util.h" | #include "framework/common/op/attr_value_util.h" | ||||
| #include "framework/common/debug/log.h" | #include "framework/common/debug/log.h" | ||||
| #include "framework/common/util.h" | #include "framework/common/util.h" | ||||
| #include "register/register_types.h" | |||||
| namespace ge { | namespace ge { | ||||
| #define DEFINE_SET_ATTR_VALUE_ONE(ARG_TYPE, FIELD) \ | #define DEFINE_SET_ATTR_VALUE_ONE(ARG_TYPE, FIELD) \ | ||||
| @@ -84,30 +83,27 @@ DEFINE_SET_ATTR_VALUE_LIST(const std::string &, s); | |||||
| ADD_TO_ATTR_MAP(map_key, value, attr) \ | ADD_TO_ATTR_MAP(map_key, value, attr) \ | ||||
| } \ | } \ | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void AddOpAttr(KEY_TYPE map_key, VALUE_TYPE value, \ | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void AddOpAttr(KEY_TYPE map_key, VALUE_TYPE value, \ | ||||
| AttrDefMap *attr_map) { \ | |||||
| ADD_TO_ATTR_MAP(map_key, value, attr_map) \ | |||||
| } \ | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void AddModelAttr(KEY_TYPE map_key, VALUE_TYPE value, \ | |||||
| ModelDef *model_def) { \ | |||||
| AttrDefMap *attr_map){ \ | |||||
| ADD_TO_ATTR_MAP(map_key, value, attr_map)} FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void \ | |||||
| AddModelAttr(KEY_TYPE map_key, VALUE_TYPE value, ModelDef *model_def) { \ | |||||
| GE_CHECK_NOTNULL_JUST_RETURN(model_def); \ | GE_CHECK_NOTNULL_JUST_RETURN(model_def); \ | ||||
| auto attr = model_def->mutable_attr(); \ | auto attr = model_def->mutable_attr(); \ | ||||
| ADD_TO_ATTR_MAP(map_key, value, attr) \ | ADD_TO_ATTR_MAP(map_key, value, attr) \ | ||||
| } | } | ||||
| #define DEFINE_ADD_ATTR_VALUE_LIST(KEY_TYPE, VALUE_TYPE) \ | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void AddOpAttrList(KEY_TYPE map_key, VALUE_TYPE value, \ | |||||
| OpDef *op_def) { \ | |||||
| GE_CHECK_NOTNULL_JUST_RETURN(op_def); \ | |||||
| auto attr = op_def->mutable_attr(); \ | |||||
| ADD_TO_ATTR_MAP_LIST(map_key, value, attr) \ | |||||
| } \ | |||||
| FMK_FUNC_DEV_VISIBILITY void AddOpAttrList(KEY_TYPE map_key, VALUE_TYPE value, AttrDefMap *attr_map) { \ | |||||
| ADD_TO_ATTR_MAP_LIST(map_key, value, attr_map) \ | |||||
| } \ | |||||
| FMK_FUNC_DEV_VISIBILITY void AddModelAttrList(KEY_TYPE map_key, VALUE_TYPE value, ModelDef *model_def) { \ | |||||
| GE_CHECK_NOTNULL_JUST_RETURN(model_def); \ | |||||
| auto attr = model_def->mutable_attr(); \ | |||||
| ADD_TO_ATTR_MAP_LIST(map_key, value, attr) \ | |||||
| #define DEFINE_ADD_ATTR_VALUE_LIST(KEY_TYPE, VALUE_TYPE) \ | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void AddOpAttrList(KEY_TYPE map_key, VALUE_TYPE value, \ | |||||
| OpDef *op_def) { \ | |||||
| GE_CHECK_NOTNULL_JUST_RETURN(op_def); \ | |||||
| auto attr = op_def->mutable_attr(); \ | |||||
| ADD_TO_ATTR_MAP_LIST(map_key, value, attr) \ | |||||
| } \ | |||||
| FMK_FUNC_DEV_VISIBILITY void AddOpAttrList(KEY_TYPE map_key, VALUE_TYPE value, AttrDefMap *attr_map){ \ | |||||
| ADD_TO_ATTR_MAP_LIST(map_key, value, attr_map)} FMK_FUNC_DEV_VISIBILITY void \ | |||||
| AddModelAttrList(KEY_TYPE map_key, VALUE_TYPE value, ModelDef *model_def) { \ | |||||
| GE_CHECK_NOTNULL_JUST_RETURN(model_def); \ | |||||
| auto attr = model_def->mutable_attr(); \ | |||||
| ADD_TO_ATTR_MAP_LIST(map_key, value, attr) \ | |||||
| } | } | ||||
| DEFINE_ADD_ATTR_VALUE(const std::string &, const std::string &); | DEFINE_ADD_ATTR_VALUE(const std::string &, const std::string &); | ||||
| @@ -157,16 +153,16 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void AddOpAttr(const std::strin | |||||
| return false; \ | return false; \ | ||||
| } | } | ||||
| #define DEFINE_GET_ATTR_CONST_POINT_REF(ARG_TYPE_KEY, ARG_TYPE_VALUE, FIELD) \ | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool GetAttrDefValue( \ | |||||
| ARG_TYPE_KEY map_key, const ARG_TYPE_VALUE *&value, const AttrDefMap &attr) { \ | |||||
| auto it = attr.find(map_key); \ | |||||
| if (it == attr.end()) { \ | |||||
| return false; \ | |||||
| } \ | |||||
| \ | |||||
| value = &(it->second.FIELD()); \ | |||||
| return true; \ | |||||
| #define DEFINE_GET_ATTR_CONST_POINT_REF(ARG_TYPE_KEY, ARG_TYPE_VALUE, FIELD) \ | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool GetAttrDefValue( \ | |||||
| ARG_TYPE_KEY map_key, const ARG_TYPE_VALUE *&value, const AttrDefMap &attr) { \ | |||||
| auto it = attr.find(map_key); \ | |||||
| if (it == attr.end()) { \ | |||||
| return false; \ | |||||
| } \ | |||||
| \ | |||||
| value = &(it->second.FIELD()); \ | |||||
| return true; \ | |||||
| } | } | ||||
| #define DEFINE_GET_BYTES_ATTR_VALUE(ARG_TYPE_KEY, ARG_TYPE_VALUE) \ | #define DEFINE_GET_BYTES_ATTR_VALUE(ARG_TYPE_KEY, ARG_TYPE_VALUE) \ | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -27,7 +27,6 @@ | |||||
| #include "framework/common/ge_inner_error_codes.h" | #include "framework/common/ge_inner_error_codes.h" | ||||
| #include "framework/common/op/attr_value_util.h" | #include "framework/common/op/attr_value_util.h" | ||||
| #include "framework/common/util.h" | #include "framework/common/util.h" | ||||
| #include "framework/common/types.h" | |||||
| #include "graph/anchor.h" | #include "graph/anchor.h" | ||||
| #include "graph/debug/ge_attr_define.h" | #include "graph/debug/ge_attr_define.h" | ||||
| #include "graph/utils/op_desc_utils.h" | #include "graph/utils/op_desc_utils.h" | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -98,7 +98,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::In | |||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::InitFromAclCfg( | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::InitFromAclCfg( | ||||
| const std::string &config) { | |||||
| const std::string &config) { | |||||
| #ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
| try { | try { | ||||
| is_load_profiling_ = false; | is_load_profiling_ = false; | ||||
| @@ -154,7 +154,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::In | |||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::ParseFeaturesFromAclCfg( | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::ParseFeaturesFromAclCfg( | ||||
| const Json &features) { | |||||
| const Json &features) { | |||||
| #ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
| try { | try { | ||||
| for (size_t i = 0; i < features.size(); ++i) { | for (size_t i = 0; i < features.size(); ++i) { | ||||
| @@ -353,18 +353,20 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::StopProf | |||||
| } | } | ||||
| uint64_t module = GetProfilingModule(); | uint64_t module = GetProfilingModule(); | ||||
| int32_t device_num = static_cast<int32_t>(device_id_.size()); | int32_t device_num = static_cast<int32_t>(device_id_.size()); | ||||
| auto device_id_ptr = std::unique_ptr<uint32_t[]>(new (std::nothrow) uint32_t[device_num]); | |||||
| uint32_t *device_id_ptr = new (std::nothrow) uint32_t[device_num]; | |||||
| if (device_id_ptr == nullptr) { | if (device_id_ptr == nullptr) { | ||||
| GELOGE(FAILED, "Stop profiling: device id ptr is null."); | |||||
| GELOGE(FAILED, "Stop profiling device id ptr is null."); | |||||
| return; | return; | ||||
| } | } | ||||
| for (int32_t i = 0; i < device_num; i++) { | for (int32_t i = 0; i < device_num; i++) { | ||||
| device_id_ptr[i] = static_cast<uint32_t>(device_id_[i]); | device_id_ptr[i] = static_cast<uint32_t>(device_id_[i]); | ||||
| } | } | ||||
| rtError_t rt_ret = rtProfilerStop(module, device_num, device_id_ptr.get()); | |||||
| rtError_t rt_ret = rtProfilerStop(module, device_num, device_id_ptr); | |||||
| if (rt_ret != RT_ERROR_NONE) { | if (rt_ret != RT_ERROR_NONE) { | ||||
| GELOGW("Call rtProfilerStop failed, ret:%d", rt_ret); | GELOGW("Call rtProfilerStop failed, ret:%d", rt_ret); | ||||
| } | } | ||||
| delete[] device_id_ptr; | |||||
| device_id_ptr = nullptr; | |||||
| for (size_t i = 0; i < prof_handle_vec_.size(); ++i) { | for (size_t i = 0; i < prof_handle_vec_.size(); ++i) { | ||||
| int result = ProfMgrStop(prof_handle_vec_[i]); | int result = ProfMgrStop(prof_handle_vec_[i]); | ||||
| @@ -380,7 +382,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::StopProf | |||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::ProfilingTaskDescInfo( | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::ProfilingTaskDescInfo( | ||||
| const std::vector<TaskDescInfo> &task_desc_info, const int32_t &device_id) { | |||||
| const std::vector<TaskDescInfo> &task_desc_info, const int32_t &device_id) { | |||||
| #ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
| Msprof::Engine::Reporter *reporter = PluginImpl::GetPluginReporter(); | Msprof::Engine::Reporter *reporter = PluginImpl::GetPluginReporter(); | ||||
| if (reporter == nullptr) { | if (reporter == nullptr) { | ||||
| @@ -395,11 +397,12 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::Profilin | |||||
| uint32_t block_dim = task.block_dim; | uint32_t block_dim = task.block_dim; | ||||
| uint32_t task_id = task.task_id; | uint32_t task_id = task.task_id; | ||||
| uint32_t stream_id = task.stream_id; | uint32_t stream_id = task.stream_id; | ||||
| data = model_name.append(" ") | |||||
| .append(op_name).append(" ") | |||||
| .append(std::to_string(block_dim).append(" ") | |||||
| .append(std::to_string(task_id)).append(" ") | |||||
| .append(std::to_string(stream_id)).append("\n")); | |||||
| data = model_name.append(" ").append(op_name).append(" ").append(std::to_string(block_dim) | |||||
| .append(" ") | |||||
| .append(std::to_string(task_id)) | |||||
| .append(" ") | |||||
| .append(std::to_string(stream_id)) | |||||
| .append("\n")); | |||||
| Msprof::Engine::ReporterData reporter_data{}; | Msprof::Engine::ReporterData reporter_data{}; | ||||
| reporter_data.deviceId = device_id; | reporter_data.deviceId = device_id; | ||||
| @@ -423,7 +426,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::Profilin | |||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::ProfilingGraphDescInfo( | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::ProfilingGraphDescInfo( | ||||
| const std::vector<ComputeGraphDescInfo> &compute_graph_desc_info, const int32_t &device_id) { | |||||
| const std::vector<ComputeGraphDescInfo> &compute_graph_desc_info, const int32_t &device_id) { | |||||
| #ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
| Msprof::Engine::Reporter *reporter = PluginImpl::GetPluginReporter(); | Msprof::Engine::Reporter *reporter = PluginImpl::GetPluginReporter(); | ||||
| GE_IF_BOOL_EXEC(reporter == nullptr, GELOGI("Profiling report is nullptr!"); return;); | GE_IF_BOOL_EXEC(reporter == nullptr, GELOGI("Profiling report is nullptr!"); return;); | ||||
| @@ -431,19 +434,19 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::Profilin | |||||
| std::string data; | std::string data; | ||||
| for (const auto &graph : compute_graph_desc_info) { | for (const auto &graph : compute_graph_desc_info) { | ||||
| data.append("model_name:") | data.append("model_name:") | ||||
| .append(graph.model_name) | |||||
| .append(" op_name:") | |||||
| .append(graph.op_name) | |||||
| .append(" op_type:") | |||||
| .append(graph.op_type); | |||||
| .append(graph.model_name) | |||||
| .append(" op_name:") | |||||
| .append(graph.op_name) | |||||
| .append(" op_type:") | |||||
| .append(graph.op_type); | |||||
| for (size_t i = 0; i < graph.input_format.size(); ++i) { | for (size_t i = 0; i < graph.input_format.size(); ++i) { | ||||
| data.append(" input_id:") | data.append(" input_id:") | ||||
| .append(std::to_string(i)) | |||||
| .append(" input_format:") | |||||
| .append(std::to_string(graph.input_format.at(i))) | |||||
| .append(" input_data_type:") | |||||
| .append(std::to_string(graph.input_data_type.at(i))) | |||||
| .append(" input_shape:\""); | |||||
| .append(std::to_string(i)) | |||||
| .append(" input_format:") | |||||
| .append(std::to_string(graph.input_format.at(i))) | |||||
| .append(" input_data_type:") | |||||
| .append(std::to_string(graph.input_data_type.at(i))) | |||||
| .append(" input_shape:\""); | |||||
| size_t input_shape_len = graph.input_shape.at(i).size(); | size_t input_shape_len = graph.input_shape.at(i).size(); | ||||
| if (input_shape_len == 0) { | if (input_shape_len == 0) { | ||||
| data.append(""); | data.append(""); | ||||
| @@ -461,12 +464,12 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::Profilin | |||||
| for (size_t i = 0; i < graph.output_format.size(); ++i) { | for (size_t i = 0; i < graph.output_format.size(); ++i) { | ||||
| data.append(" output_id:") | data.append(" output_id:") | ||||
| .append(std::to_string(i)) | |||||
| .append(" output_format:") | |||||
| .append(std::to_string(graph.output_format.at(i))) | |||||
| .append(" output_data_type:") | |||||
| .append(std::to_string(graph.output_data_type.at(i))) | |||||
| .append(" output_shape:\""); | |||||
| .append(std::to_string(i)) | |||||
| .append(" output_format:") | |||||
| .append(std::to_string(graph.output_format.at(i))) | |||||
| .append(" output_data_type:") | |||||
| .append(std::to_string(graph.output_data_type.at(i))) | |||||
| .append(" output_shape:\""); | |||||
| size_t output_shape_len = graph.output_shape.at(i).size(); | size_t output_shape_len = graph.output_shape.at(i).size(); | ||||
| if (output_shape_len == 0) { | if (output_shape_len == 0) { | ||||
| data.append(""); | data.append(""); | ||||
| @@ -492,8 +495,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::Profilin | |||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::Report( | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::Report( | ||||
| const int32_t &device_id, const string &data, Msprof::Engine::Reporter &reporter, | |||||
| Msprof::Engine::ReporterData &reporter_data) { | |||||
| const int32_t &device_id, const string &data, Msprof::Engine::Reporter &reporter, | |||||
| Msprof::Engine::ReporterData &reporter_data) { | |||||
| #ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
| size_t index = data.size() / kReportMaxLen; | size_t index = data.size() / kReportMaxLen; | ||||
| if (index >= 1) { | if (index >= 1) { | ||||
| @@ -535,7 +538,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::PluginUn | |||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::ReportProfilingData( | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::ReportProfilingData( | ||||
| const std::vector<TaskDescInfo> &task_desc_info, const std::vector<ComputeGraphDescInfo> &compute_graph_desc_info) { | |||||
| const std::vector<TaskDescInfo> &task_desc_info, const std::vector<ComputeGraphDescInfo> &compute_graph_desc_info) { | |||||
| #ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
| int32_t logic_device_id = 0; | int32_t logic_device_id = 0; | ||||
| rtError_t rt_ret = rtGetDevice(&logic_device_id); | rtError_t rt_ret = rtGetDevice(&logic_device_id); | ||||
| @@ -560,22 +563,15 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::ReportPr | |||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::SetProfilingConfig( | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::SetProfilingConfig( | ||||
| const std::string &profiling_cfg) { | |||||
| const std::string &profiling_cfg) { | |||||
| recv_profiling_config_ = profiling_cfg; | recv_profiling_config_ = profiling_cfg; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY uint64_t ProfilingManager::GetProfilingModule() { | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY uint64_t ProfilingManager::GetProfilingModule() { | ||||
| uint64_t module = PROF_MODEL_EXECUTE_MASK | | |||||
| PROF_RUNTIME_API_MASK | | |||||
| PROF_RUNTIME_TRACE_MASK | | |||||
| PROF_SCHEDULE_TIMELINE_MASK | | |||||
| PROF_SCHEDULE_TRACE_MASK | | |||||
| PROF_TASK_TIME_MASK | | |||||
| PROF_SUBTASK_TIME_MASK | | |||||
| PROF_AICPU_TRACE_MASK | | |||||
| PROF_AICORE_METRICS_MASK | | |||||
| PROF_AIVECTORCORE_METRICS_MASK | | |||||
| PROF_MODEL_LOAD_MASK; | |||||
| uint64_t module = PROF_MODEL_EXECUTE_MASK | PROF_RUNTIME_API_MASK | PROF_RUNTIME_TRACE_MASK | | |||||
| PROF_SCHEDULE_TIMELINE_MASK | PROF_SCHEDULE_TRACE_MASK | PROF_TASK_TIME_MASK | | |||||
| PROF_SUBTASK_TIME_MASK | PROF_AICPU_TRACE_MASK | PROF_AICORE_METRICS_MASK | | |||||
| PROF_AIVECTORCORE_METRICS_MASK | PROF_MODEL_LOAD_MASK; | |||||
| return module; | return module; | ||||
| } | } | ||||
| @@ -691,8 +687,8 @@ Status ProfilingManager::ProfParseDeviceId(const std::map<std::string, std::stri | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| Status ProfilingManager::ProfParseParam(const std::map<std::string, std::string> &config_para, | |||||
| int32_t &device_num, vector<int32_t> &device_list) { | |||||
| Status ProfilingManager::ProfParseParam(const std::map<std::string, std::string> &config_para, int32_t &device_num, | |||||
| vector<int32_t> &device_list) { | |||||
| #ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
| // device num | // device num | ||||
| auto iter = config_para.find(kConfigNumsdev); | auto iter = config_para.find(kConfigNumsdev); | ||||
| @@ -726,8 +722,8 @@ Status ProfilingManager::ProfParseParam(const std::map<std::string, std::string> | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfStartProfiling( | |||||
| uint64_t module, const std::map<std::string, std::string> &config_para) { | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status | |||||
| ProfilingManager::ProfStartProfiling(uint64_t module, const std::map<std::string, std::string> &config_para) { | |||||
| #ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
| std::lock_guard<std::mutex> lock(mutex_); | std::lock_guard<std::mutex> lock(mutex_); | ||||
| int32_t device_num = 0; | int32_t device_num = 0; | ||||
| @@ -736,21 +732,23 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfSt | |||||
| GELOGE(FAILED, "Prof start parse param failed."); | GELOGE(FAILED, "Prof start parse param failed."); | ||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| auto device_id_ptr = std::unique_ptr<uint32_t[]>(new (std::nothrow) uint32_t[device_num]); | |||||
| if (device_id_ptr == nullptr) { | |||||
| GELOGE(FAILED, "Prof start: device id ptr is null."); | |||||
| auto *device_id = new (std::nothrow) uint32_t[device_num]; | |||||
| if (device_id == nullptr) { | |||||
| GELOGE(FAILED, "Prof start parse param failed."); | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| for (int32_t i = 0; i < device_num; i++) { | for (int32_t i = 0; i < device_num; i++) { | ||||
| device_id_ptr[i] = static_cast<uint32_t>(device_list[i]); | |||||
| device_id[i] = static_cast<uint32_t>(device_list[i]); | |||||
| } | } | ||||
| GELOGI("Runtime config param: 0x%llx, device num: %d.", module, device_num); | GELOGI("Runtime config param: 0x%llx, device num: %d.", module, device_num); | ||||
| rtError_t rt_ret = rtProfilerStart(module, device_num, device_id_ptr.get()); | |||||
| rtError_t rt_ret = rtProfilerStart(module, device_num, device_id); | |||||
| if (rt_ret != RT_ERROR_NONE) { | if (rt_ret != RT_ERROR_NONE) { | ||||
| delete[] device_id; | |||||
| GELOGE(FAILED, "Runtime profiler config proc failed."); | GELOGE(FAILED, "Runtime profiler config proc failed."); | ||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| delete[] device_id; | |||||
| device_id = nullptr; | |||||
| if ((module & PROF_MODEL_EXECUTE_MASK) == PROF_MODEL_EXECUTE_MASK) { | if ((module & PROF_MODEL_EXECUTE_MASK) == PROF_MODEL_EXECUTE_MASK) { | ||||
| for (int32_t i = 0; i < device_num; i++) { | for (int32_t i = 0; i < device_num; i++) { | ||||
| if (std::find(device_id_.begin(), device_id_.end(), device_list[i]) == device_id_.end()) { | if (std::find(device_id_.begin(), device_id_.end(), device_list[i]) == device_id_.end()) { | ||||
| @@ -768,8 +766,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfSt | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfStopProfiling(uint64_t module, | |||||
| const std::map<std::string, std::string> &config_para) { | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status | |||||
| ProfilingManager::ProfStopProfiling(uint64_t module, const std::map<std::string, std::string> &config_para) { | |||||
| #ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
| std::lock_guard<std::mutex> lock(mutex_); | std::lock_guard<std::mutex> lock(mutex_); | ||||
| int32_t device_num = 0; | int32_t device_num = 0; | ||||
| @@ -778,20 +776,23 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfSt | |||||
| GELOGE(FAILED, "Prof stop parse param failed."); | GELOGE(FAILED, "Prof stop parse param failed."); | ||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| auto device_id_ptr = std::unique_ptr<uint32_t[]>(new (std::nothrow) uint32_t[device_num]); | |||||
| if (device_id_ptr == nullptr) { | |||||
| GELOGE(FAILED, "Prof stop: device id ptr is null."); | |||||
| auto *device_id = new (std::nothrow) uint32_t[device_num]; | |||||
| if (device_id == nullptr) { | |||||
| GELOGE(FAILED, "Prof stop parse param failed."); | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| for (int32_t i = 0; i < device_num; i++) { | for (int32_t i = 0; i < device_num; i++) { | ||||
| device_id_ptr[i] = static_cast<uint32_t>(device_list[i]); | |||||
| device_id[i] = static_cast<uint32_t>(device_list[i]); | |||||
| } | } | ||||
| GELOGI("Prof stop: runtime config param: 0x%llx, device num: %d", module, device_num); | GELOGI("Prof stop: runtime config param: 0x%llx, device num: %d", module, device_num); | ||||
| rtError_t rt_ret = rtProfilerStop(module, device_num, device_id_ptr.get()); | |||||
| rtError_t rt_ret = rtProfilerStop(module, device_num, device_id); | |||||
| if (rt_ret != RT_ERROR_NONE) { | if (rt_ret != RT_ERROR_NONE) { | ||||
| delete[] device_id; | |||||
| GELOGE(FAILED, "Prof stop: runtime profiler config proc failed."); | GELOGE(FAILED, "Prof stop: runtime profiler config proc failed."); | ||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| delete[] device_id; | |||||
| device_id = nullptr; | |||||
| uint64_t execute_model_mask = module & PROF_MODEL_EXECUTE_MASK; | uint64_t execute_model_mask = module & PROF_MODEL_EXECUTE_MASK; | ||||
| if (execute_model_mask == PROF_MODEL_EXECUTE_MASK) { | if (execute_model_mask == PROF_MODEL_EXECUTE_MASK) { | ||||
| for (int32_t i = 0; i < device_num; i++) { | for (int32_t i = 0; i < device_num; i++) { | ||||
| @@ -811,8 +812,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfSt | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::UpdateDeviceIdModuleMap(string prof_type, | |||||
| uint64_t module, const vector<int32_t> &device_list) { | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::UpdateDeviceIdModuleMap( | |||||
| string prof_type, uint64_t module, const vector<int32_t> &device_list) { | |||||
| #ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
| if (prof_type == kProfStart) { | if (prof_type == kProfStart) { | ||||
| for (uint32_t i = 0; i < device_list.size(); i++) { | for (uint32_t i = 0; i < device_list.size(); i++) { | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -36,7 +36,7 @@ using std::vector; | |||||
| using Json = nlohmann::json; | using Json = nlohmann::json; | ||||
| namespace { | namespace { | ||||
| const std::string GE_PROFILING_MODULE = "Framework"; | |||||
| const std::string GE_PROFILING_MODULE = "Framework"; | |||||
| } // namespace | } // namespace | ||||
| namespace ge { | namespace ge { | ||||
| // register Plugin | // register Plugin | ||||
| @@ -83,7 +83,7 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager { | |||||
| bool ProfilingTrainingTraceOn() const { return is_training_trace_; } | bool ProfilingTrainingTraceOn() const { return is_training_trace_; } | ||||
| bool ProfilingModelLoadOn() const { return is_load_profiling_; } | bool ProfilingModelLoadOn() const { return is_load_profiling_; } | ||||
| bool ProfilingModelExecuteOn() const; | bool ProfilingModelExecuteOn() const; | ||||
| bool ProfilingOn() const { return is_load_profiling_ && is_execute_profiling_; } // only used by command pattern | |||||
| bool ProfilingOn() const { return is_load_profiling_ && is_execute_profiling_; } // only used by command pattern | |||||
| int32_t GetOpTraceIterNum() const { return op_trace_iter_num_; } | int32_t GetOpTraceIterNum() const { return op_trace_iter_num_; } | ||||
| void ReportProfilingData(const std::vector<TaskDescInfo> &task_desc_info, | void ReportProfilingData(const std::vector<TaskDescInfo> &task_desc_info, | ||||
| const std::vector<ComputeGraphDescInfo> &compute_graph_desc_info); | const std::vector<ComputeGraphDescInfo> &compute_graph_desc_info); | ||||
| @@ -93,14 +93,14 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager { | |||||
| void ProfilingGraphDescInfo(const std::vector<ComputeGraphDescInfo> &compute_graph_desc_info, | void ProfilingGraphDescInfo(const std::vector<ComputeGraphDescInfo> &compute_graph_desc_info, | ||||
| const int32_t &device_id); | const int32_t &device_id); | ||||
| void SetProfilingConfig(const string &profiling_cfg); | void SetProfilingConfig(const string &profiling_cfg); | ||||
| vector<int32_t> GetProfilingDeviceId() const { return device_id_; } | |||||
| vector<int32_t> GetProfilingDeviceId() const { return device_id_; } | |||||
| void PluginUnInit(const std::string &module) const; | void PluginUnInit(const std::string &module) const; | ||||
| private: | private: | ||||
| ge::Status ParseFeaturesFromAclCfg(const Json &feature); | ge::Status ParseFeaturesFromAclCfg(const Json &feature); | ||||
| ge::Status ProfParseParam(const std::map<std::string, std::string> &config_para, int32_t &device_num, | ge::Status ProfParseParam(const std::map<std::string, std::string> &config_para, int32_t &device_num, | ||||
| vector<int32_t> &device_list); | vector<int32_t> &device_list); | ||||
| ge::Status ProfParseDeviceId(const std::map<std::string, std::string> &config_para, | |||||
| vector<int32_t> &device_list); | |||||
| ge::Status ProfParseDeviceId(const std::map<std::string, std::string> &config_para, vector<int32_t> &device_list); | |||||
| uint64_t GetProfilingModule(); | uint64_t GetProfilingModule(); | ||||
| void UpdateDeviceIdModuleMap(string prof_type, uint64_t module, const vector<int32_t> &device_list); | void UpdateDeviceIdModuleMap(string prof_type, uint64_t module, const vector<int32_t> &device_list); | ||||
| bool is_load_profiling_ = false; | bool is_load_profiling_ = false; | ||||
| @@ -121,7 +121,7 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager { | |||||
| string system_trace_conf_; | string system_trace_conf_; | ||||
| string task_trace_conf_; | string task_trace_conf_; | ||||
| const ProfilingEngineImpl engine_; | const ProfilingEngineImpl engine_; | ||||
| map<int32_t, uint64_t> device_id_module_map_; // key: device_id, value: profiling on module | |||||
| map<int32_t, uint64_t> device_id_module_map_; // key: device_id, value: profiling on module | |||||
| std::mutex mutex_; | std::mutex mutex_; | ||||
| }; | }; | ||||
| } // namespace ge | } // namespace ge | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -135,7 +135,7 @@ std::string PropertiesManager::Trim(const std::string &str) { | |||||
| // Get property value, if not found, return "" | // Get property value, if not found, return "" | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::string PropertiesManager::GetPropertyValue( | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::string PropertiesManager::GetPropertyValue( | ||||
| const std::string &map_key) { | |||||
| const std::string &map_key) { | |||||
| std::lock_guard<std::mutex> lock(mutex_); | std::lock_guard<std::mutex> lock(mutex_); | ||||
| auto iter = properties_map_.find(map_key); | auto iter = properties_map_.find(map_key); | ||||
| if (properties_map_.end() != iter) { | if (properties_map_.end() != iter) { | ||||
| @@ -166,14 +166,14 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void PropertiesManager::SetProp | |||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY DumpProperties &PropertiesManager::GetDumpProperties( | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY DumpProperties &PropertiesManager::GetDumpProperties( | ||||
| uint64_t session_id) { | |||||
| uint64_t session_id) { | |||||
| std::lock_guard<std::mutex> lock(mutex_); | std::lock_guard<std::mutex> lock(mutex_); | ||||
| // If session_id is not found in dump_properties_map_, operator[] will insert one. | // If session_id is not found in dump_properties_map_, operator[] will insert one. | ||||
| return dump_properties_map_[session_id]; | return dump_properties_map_[session_id]; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void PropertiesManager::AddDumpProperties( | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void PropertiesManager::AddDumpProperties( | ||||
| uint64_t session_id, const DumpProperties &dump_properties) { | |||||
| uint64_t session_id, const DumpProperties &dump_properties) { | |||||
| std::lock_guard<std::mutex> lock(mutex_); | std::lock_guard<std::mutex> lock(mutex_); | ||||
| dump_properties_map_.emplace(session_id, dump_properties); | dump_properties_map_.emplace(session_id, dump_properties); | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /** | /** | ||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||