def fusion_rl_tune(self, task_id, json_info): """ RL tune for fusion op :param task_id: task id for this op to tune :param json_info: op's info :return: tune result """ if 'fusion_op' not in json_info or not json_info['fusion_op']: raise ValueError("Json string Errors, key:fusion_op not found.") kernel_name = json_info["fusion_op"]["fusion_op_name"] full_name = json_info["fusion_op"]["full_name"] set_current_op_name(kernel_name) converted_json = fusion_to_fusion(json.dumps(json_info), tune_mode="RL") job_type = RL_COMPILE base_kernel = './kernel_meta/' + kernel_name + '.o' try: fusion_op(converted_json) # pylint: disable=broad-except except Exception: exc_type, exc_value, _ = sys.exc_info() log.error("exc_type:{}, exc_value:{}, exc_traceback:{}".format( exc_type, exc_value, traceback.format_exc())) return False, job_type if self.offline_tune: job_type = RL_OFFLINE dump_fusion_json(converted_json, self.offline_dump_path) else: job_type = RL_ONLINE graph_id = 0 l1size = 0 ret = dispatch_fusion_tune_task(graph_id, task_id, l1size, base_kernel, kernel_name, full_name, converted_json) return ret, job_type
def compile_fusion_op(json_str): """ compile fusion op with input args json_str Args: json_str (str): op function input args Raises: Exception: If specific keyword is not found. """ args = json.loads(json_str) te_set_version(args['fusion_op']["socVersion"]) if 'fusion_op' not in args or not args['fusion_op']: raise ValueError("Json string Errors, key:fusion_op not found.") fusion_op_arg = args['fusion_op'] return fusion_op(json.dumps(fusion_op_arg))
def compile_fusion_op(json_str): """ compile fusion op with input args json_str Args: json_str (str): op function input args Raises: Exception: If specific keyword is not found. """ args = json.loads(json_str) if 'fusion_op' not in args or not args['fusion_op']: raise ValueError("Json string Errors, key:fusion_op not found.") if 'prebuild_ops' not in args or not args['prebuild_ops']: raise ValueError("Json string Errors, key:prebuild_ops not found.") pre_build_op_list = args['prebuild_ops'] for op in pre_build_op_list: build_op(op_pre_build, json.dumps(op)) fusion_op_arg = args['fusion_op'] return fusion_op(json.dumps(fusion_op_arg))